Skip to content

Commit c7119c5

Browse files
[doc] Better more useful links for ide integration
1 parent 3cd2c40 commit c7119c5

10 files changed

+286
-278
lines changed

doc/conf.py

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
# "<source>": "<target>"
5555
"intro": "index.html",
5656
"support": "contact.html",
57+
"ide-integration": "installation.html",
5758
}
5859

5960
# Add any paths that contain templates here, relative to this directory.

doc/faq.rst

-5
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,6 @@ For example::
8282

8383
pylint --disable=bare-except,invalid-name --class-rgx='[A-Z][a-z]+' --generate-toml-config
8484

85-
3.4 I'd rather not run Pylint from the command line. Can I integrate it with my editor?
86-
---------------------------------------------------------------------------------------
87-
88-
Much probably. Read :ref:`user_guide/installation:ide-integration`
89-
9085
3.5 I need to run pylint over all modules and packages in my project directory.
9186
-------------------------------------------------------------------------------
9287

doc/user_guide/ide-integration.rst

-232
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
Using Pylint through Flymake in Emacs
2+
=====================================
3+
4+
To enable Flymake for Python, insert the following into your .emacs:
5+
6+
.. sourcecode:: common-lisp
7+
8+
;; Configure Flymake for Python
9+
(when (load "flymake" t)
10+
(defun flymake-pylint-init ()
11+
(let* ((temp-file (flymake-init-create-temp-buffer-copy
12+
'flymake-create-temp-inplace))
13+
(local-file (file-relative-name
14+
temp-file
15+
(file-name-directory buffer-file-name))))
16+
(list "epylint" (list local-file))))
17+
(add-to-list 'flymake-allowed-file-name-masks
18+
'("\\.py\\'" flymake-pylint-init)))
19+
20+
;; Set as a minor mode for Python
21+
(add-hook 'python-mode-hook '(lambda () (flymake-mode)))
22+
23+
Above stuff is in ``pylint/elisp/pylint-flymake.el``, which should be automatically
24+
installed on Debian systems, in which cases you don't have to put it in your ``.emacs`` file.
25+
26+
Other things you may find useful to set:
27+
28+
.. sourcecode:: common-lisp
29+
30+
;; Configure to wait a bit longer after edits before starting
31+
(setq-default flymake-no-changes-timeout '3)
32+
33+
;; Keymaps to navigate to the errors
34+
(add-hook 'python-mode-hook '(lambda () (define-key python-mode-map "\C-cn" 'flymake-goto-next-error)))
35+
(add-hook 'python-mode-hook '(lambda () (define-key python-mode-map "\C-cp" 'flymake-goto-prev-error)))
36+
37+
38+
Finally, by default Flymake only displays the extra information about the error when you
39+
hover the mouse over the highlighted line. The following will use the minibuffer to display
40+
messages when you the cursor is on the line.
41+
42+
.. sourcecode:: common-lisp
43+
44+
;; To avoid having to mouse hover for the error message, these functions make Flymake error messages
45+
;; appear in the minibuffer
46+
(defun show-fly-err-at-point ()
47+
"If the cursor is sitting on a Flymake error, display the message in the minibuffer"
48+
(require 'cl)
49+
(interactive)
50+
(let ((line-no (line-number-at-pos)))
51+
(dolist (elem flymake-err-info)
52+
(if (eq (car elem) line-no)
53+
(let ((err (car (second elem))))
54+
(message "%s" (flymake-ler-text err)))))))
55+
56+
(add-hook 'post-command-hook 'show-fly-err-at-point)
57+
58+
59+
Alternative, if you only wish to pollute the minibuffer after an explicit flymake-goto-* then use
60+
the following instead of a post-command-hook
61+
62+
.. sourcecode:: common-lisp
63+
64+
(defadvice flymake-goto-next-error (after display-message activate compile)
65+
"Display the error in the mini-buffer rather than having to mouse over it"
66+
(show-fly-err-at-point))
67+
68+
(defadvice flymake-goto-prev-error (after display-message activate compile)
69+
"Display the error in the mini-buffer rather than having to mouse over it"
70+
(show-fly-err-at-point))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
###########################
2+
Editor and IDE integration
3+
###########################
4+
5+
.. toctree::
6+
:maxdepth: 2
7+
:titlesonly:
8+
9+
flymake-emacs.rst
10+
pylint-pycharm.rst
11+
textmate.rst
12+
visual-studio-code.rst
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
Integrate Pylint with PyCharm
2+
=============================
3+
4+
.. _pylint_in_pycharm:
5+
6+
Install Pylint the usual way::
7+
8+
pip install pylint
9+
10+
Remember the path at which it's installed::
11+
12+
which pylint
13+
14+
Using pylint-pycharm plugin
15+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
16+
17+
#. In PyCharm go to *Preferences* > *Plugins* > *Browse repositories...*
18+
#. Right-click on the plugin named **Pylint**, select **Download and Install** and restart PyCharm when prompted
19+
20+
If the plugin is not finding the Pylint executable (e.g. is not inside the PATH environmental variable), you can
21+
specify it manually using the plugin settings:
22+
23+
#. *Preferences* > *Other Settings* > *Pylint* or simply click the gear icon from the side bar of the Pylint tool window
24+
#. Type the path directly or use the Browse button to open a file selection dialog
25+
#. Press the Test button to check if the plugin is able to run the executable
26+
27+
For more info on how to use the plugin please check the `official plugin documentation <https://github.com/leinardi/pylint-pycharm/blob/master/README.md>`_.
28+
29+
Using External Tools
30+
~~~~~~~~~~~~~~~~~~~~
31+
32+
Within PyCharm:
33+
34+
#. Navigate to the preferences window
35+
#. Select "External Tools"
36+
#. Click the plus sign at the bottom of the dialog to add a new external task
37+
#. In the dialog, populate the following fields:
38+
39+
:Name: Pylint
40+
:Description: A Python source code analyzer which looks for programming errors, helps enforcing a coding standard and sniffs for some code smells.
41+
:Synchronize files after execution: unchecked
42+
:Program: ``/path/to/pylint``
43+
:Parameters: ``$FilePath$``
44+
45+
#. Click OK
46+
47+
The option to check the current file with Pylint should now be available in *Tools* > *External Tools* > *Pylint*.

0 commit comments

Comments
 (0)