From ad731e78eecc677e85bbe80d89a7cdf87fbd7922 Mon Sep 17 00:00:00 2001 From: Michal Nowikowski Date: Tue, 4 Nov 2014 08:08:19 +0100 Subject: Documentation improvements - added intros to features page, - fixed PyLint to Pylint in text, - improved ide-integration doc page, - updated pylintrc in examples and - regenerated pylint manual --- ChangeLog | 2 +- Makefile | 2 +- checkers/classes.py | 4 +- checkers/newstyle.py | 2 +- checkers/variables.py | 2 +- doc/ide-integration.rst | 36 +++++----- doc/options.rst | 10 +-- examples/pylintrc | 171 +++++++++++++++++++++++++++++------------------- interfaces.py | 2 +- lint.py | 2 +- man/pylint.1 | 138 ++++++++++++++++++++++---------------- utils.py | 55 ++++++++++------ 12 files changed, 249 insertions(+), 177 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0ef5c07..b753419 100644 --- a/ChangeLog +++ b/ChangeLog @@ -166,7 +166,7 @@ ChangeLog for Pylint * Allow hanging continued indentation for implicitly concatenated strings. Closes issue #232. - * PyLint works under Python 2.5 again, and its test suite passes. + * Pylint works under Python 2.5 again, and its test suite passes. * Fix some false positives for the cellvar-from-loop warnings. Closes issue #233. diff --git a/Makefile b/Makefile index b566c2b..daf2bff 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -# Makefile for handling various tasks of PyLint sources +# Makefile for handling various tasks of Pylint sources PYVE=pyve PIP=$(PYVE)/bin/pip TOX=$(PYVE)/bin/tox diff --git a/checkers/classes.py b/checkers/classes.py index 3be5bd7..14aa90f 100644 --- a/checkers/classes.py +++ b/checkers/classes.py @@ -106,7 +106,7 @@ def _is_attribute_property(name, klass): MSGS = { 'F0202': ('Unable to check methods signature (%s / %s)', 'method-check-failed', - 'Used when PyLint has been unable to check methods signature \ + 'Used when Pylint has been unable to check methods signature \ compatibility for an unexpected reason. Please report this kind \ if you don\'t make sense of it.'), @@ -193,7 +193,7 @@ MSGS = { ), 'F0220': ('failed to resolve interfaces implemented by %s (%s)', # W0224 'unresolved-interface', - 'Used when a PyLint as failed to find interfaces implemented by \ + 'Used when a Pylint as failed to find interfaces implemented by \ a class'), diff --git a/checkers/newstyle.py b/checkers/newstyle.py index 335b052..4fae401 100644 --- a/checkers/newstyle.py +++ b/checkers/newstyle.py @@ -43,7 +43,7 @@ MSGS = { {'maxversion': (3, 0)}), 'W1001': ('Use of "property" on an old style class', 'property-on-old-class', - 'Used when PyLint detect the use of the builtin "property" \ + 'Used when Pylint detect the use of the builtin "property" \ on an old style class while this is relying on new style \ classes features.', {'maxversion': (3, 0)}), diff --git a/checkers/variables.py b/checkers/variables.py index b5ea34f..4420356 100644 --- a/checkers/variables.py +++ b/checkers/variables.py @@ -201,7 +201,7 @@ MSGS = { 'W0603': ('Using the global statement', # W0121 'global-statement', 'Used when you use the "global" statement to update a global \ - variable. PyLint just try to discourage this \ + variable. Pylint just try to discourage this \ usage. That doesn\'t mean you can not use it !'), 'W0604': ('Using the global statement at the module level', # W0103 'global-at-module-level', diff --git a/doc/ide-integration.rst b/doc/ide-integration.rst index de5116c..7507fb1 100644 --- a/doc/ide-integration.rst +++ b/doc/ide-integration.rst @@ -3,35 +3,33 @@ IDE integration ================= -To use Pylint with Emacs, see http://www.emacswiki.org/emacs/PythonProgrammingInEmacs#toc8 +To use Pylint with: -To use Pylint with Vim, see -http://www.vim.org/scripts/script.php?script_id=891 + - Emacs_, see http://www.emacswiki.org/emacs/PythonProgrammingInEmacs#toc8, + - Vim_, see http://www.vim.org/scripts/script.php?script_id=891, + - Eclipse_ and PyDev_, see http://pydev.org/manual_adv_pylint.html, + - Komodo_, see http://mateusz.loskot.net/posts/2006/01/15/running-pylint-from-komodo/, + - gedit_, see https://launchpad.net/gedit-pylint-2 or https://wiki.gnome.org/Apps/Gedit/PylintPlugin, + - WingIDE_, see http://www.wingware.com/doc/edit/pylint, + - PyCharm_, see http://blog.saturnlaboratories.co.za/archive/2012/09/10/running-pylint-pycharm. -To use Pylint with Eclipse, see http://pydev.org +Pylint is integrated in: -To use Pylint with Komodo_, see -http://mateusz.loskot.net/2006/01/15/running-pylint-from-komodo/ - -To use Pylint with gedit_, see -http://live.gnome.org/Gedit/PylintPlugin - -To use Pylint with WingIDE_, see -http://www.wingware.com/doc/edit/pylint - -Pylint is integrated in Eric_ IDE, see the `Project > Check` menu. - -Pylint is integrated in Spyder_, see http://packages.python.org/spyder/pylint.html - -Pylint is integrated in pyscripter_, see the `Tool -> Tools` menu. + - Eric_ IDE, see the `Project > Check` menu, + - Spyder_, see http://packages.python.org/spyder/pylint.html, + - pyscripter_, see the `Tool -> Tools` menu. +.. _Emacs: http://www.gnu.org/software/emacs/ +.. _Vim: http://www.vim.org/ +.. _Eclipse: https://www.eclipse.org/ .. _Eric: http://eric-ide.python-projects.org/ .. _pyscripter: http://code.google.com/p/pyscripter/ .. _pydev: http://pydev.org .. _Komodo: http://www.activestate.com/Products/Komodo/ -.. _gedit: http://www.gnome.org/projects/gedit/ +.. _gedit: https://wiki.gnome.org/Apps/Gedit .. _WingIDE: http://www.wingware.com/ .. _spyder: http://code.google.com/p/spyderlib/ +.. _PyCharm: http://www.jetbrains.com/pycharm/ Using Pylint thru flymake in Emacs ================================== diff --git a/doc/options.rst b/doc/options.rst index 702d93c..d005dd2 100644 --- a/doc/options.rst +++ b/doc/options.rst @@ -1,13 +1,13 @@ .. -*- coding: utf-8 -*- =============== - Configuration + Configuration =============== Naming Styles ------------- -PyLint recognizes a number of different name types internally. With a few +Pylint recognizes a number of different name types internally. With a few exceptions, the type of the name is governed by the location the assignment to a name is found in, and not the type of object assigned. @@ -88,10 +88,10 @@ Large code bases that have been worked on for multiple years often exhibit an evolution in style as well. In some cases, modules can be in the same package, but still have different naming style based on the stratum they belong to. However, intra-module consistency should still be required, to make changes -inside a single file easier. For this case, PyLint supports regular expression -with several named capturing group. +inside a single file easier. For this case, Pylint supports regular expression +with several named capturing group. -Rather than emitting name warnings immediately, PyLint will determine the +Rather than emitting name warnings immediately, Pylint will determine the prevalent naming style inside each module and enforce it on all names. Consider the following (simplified) example:: diff --git a/examples/pylintrc b/examples/pylintrc index 5f21f58..69f0ee1 100644 --- a/examples/pylintrc +++ b/examples/pylintrc @@ -12,7 +12,7 @@ profile=no # Add files or directories to the blacklist. They should be base names, not # paths. -ignore=.hg,test +ignore=CVS # Pickle collected data for later comparisons. persistent=yes @@ -27,9 +27,16 @@ include-ids=no # DEPRECATED symbols=no +# Use multiple processes to speed up Pylint. +jobs=1 + [MESSAGES CONTROL] +# Only show warnings with the listed confidence levels. Leave empty to show +# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED +confidence= + # Enable the message, report, category or checker with the given id(s). You can # either give multiple identifier separated by comma (,) or put this option # multiple time. See also the "--disable" option for examples. @@ -85,30 +92,22 @@ comment=no logging-modules=logging -[FORMAT] - -# Maximum number of characters on a single line. -max-line-length=80 - -# Regexp for a line that is allowed to be longer than the limit. -ignore-long-lines=^\s*(# )??$ - -# Allow the body of an if to be on the same line as the test if there is no -# else. -single-line-if-stmt=no +[VARIABLES] -# List of optional constructs for which whitespace checking is disabled -no-space-check=trailing-comma,dict-separator +# Tells whether we should check for unused import in __init__ files. +init-import=no -# Maximum number of lines in a module -max-module-lines=1000 +# A regular expression matching the name of dummy variables (i.e. expectedly +# not used). +dummy-variables-rgx=_$|dummy -# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 -# tab). -indent-string=' ' +# List of additional names supposed to be defined in builtins. Remember that +# you should avoid to define new builtins when possible. +additional-builtins= -# Number of spaces of indent required inside a hanging or continued line. -indent-after-paren=4 +# List of strings which can identify a callback function by name. A callback +# name must start or end with one of those strings. +callbacks=cb_,_cb [BASIC] @@ -117,7 +116,7 @@ indent-after-paren=4 required-attributes= # List of builtins function names that should not be used, separated by a comma -bad-functions=map,filter,apply,input +bad-functions=map,filter,input # Good variable names which should always be accepted, separated by a comma good-names=i,j,k,ex,Run,_ @@ -201,21 +200,6 @@ no-docstring-rgx=__.*__ docstring-min-length=-1 -[SIMILARITIES] - -# Minimum lines number of a similarity. -min-similarity-lines=4 - -# Ignore comments when computing similarities. -ignore-comments=yes - -# Ignore docstrings when computing similarities. -ignore-docstrings=yes - -# Ignore imports when computing similarities. -ignore-imports=no - - [MISCELLANEOUS] # List of note tags to take in consideration, separated by a comma. @@ -247,36 +231,85 @@ zope=no generated-members=REQUEST,acl_users,aq_parent -[VARIABLES] +[SPELLING] -# Tells whether we should check for unused import in __init__ files. -init-import=no +# Spelling dictionary name. Available dictionaries: none. To make it working +# install python-enchant package. +spelling-dict= -# A regular expression matching the name of dummy variables (i.e. expectedly -# not used). -dummy-variables-rgx=_|dummy +# List of comma separated words that should not be checked. +spelling-ignore-words= -# List of additional names supposed to be defined in builtins. Remember that -# you should avoid to define new builtins when possible. -additional-builtins= +# A path to a file that contains private dictionary; one word per line. +spelling-private-dict-file= +# Tells whether to store unknown words to indicated private dictionary in +# --spelling-private-dict-file option instead of raising a message. +spelling-store-unknown-words=no -[IMPORTS] -# Deprecated modules which should not be used, separated by a comma -deprecated-modules=regsub,string,TERMIOS,Bastion,rexec +[FORMAT] -# Create a graph of every (i.e. internal and external) dependencies in the -# given file (report RP0402 must not be disabled) -import-graph= +# Maximum number of characters on a single line. +max-line-length=80 -# Create a graph of external dependencies in the given file (report RP0402 must -# not be disabled) -ext-import-graph= +# Regexp for a line that is allowed to be longer than the limit. +ignore-long-lines=^\s*(# )??$ -# Create a graph of internal dependencies in the given file (report RP0402 must -# not be disabled) -int-import-graph= +# Allow the body of an if to be on the same line as the test if there is no +# else. +single-line-if-stmt=no + +# List of optional constructs for which whitespace checking is disabled +no-space-check=trailing-comma,dict-separator + +# Maximum number of lines in a module +max-module-lines=1000 + +# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1 +# tab). +indent-string=' ' + +# Number of spaces of indent required inside a hanging or continued line. +indent-after-paren=4 + +# Expected format of line ending, e.g. empty (any line ending), LF or CRLF. +expected-line-ending-format= + + +[SIMILARITIES] + +# Minimum lines number of a similarity. +min-similarity-lines=4 + +# Ignore comments when computing similarities. +ignore-comments=yes + +# Ignore docstrings when computing similarities. +ignore-docstrings=yes + +# Ignore imports when computing similarities. +ignore-imports=no + + +[CLASSES] + +# List of interface methods to ignore, separated by a comma. This is used for +# instance to not check methods defines in Zope's Interface base class. +ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by + +# List of method names used to declare (i.e. assign) instance attributes. +defining-attr-methods=__init__,__new__,setUp + +# List of valid names for the first argument in a class method. +valid-classmethod-first-arg=cls + +# List of valid names for the first argument in a metaclass class method. +valid-metaclass-classmethod-first-arg=mcs + +# List of member names, which should be excluded from the protected access +# warning. +exclude-protected=_asdict,_fields,_replace,_source,_make [DESIGN] @@ -313,20 +346,22 @@ min-public-methods=2 max-public-methods=20 -[CLASSES] +[IMPORTS] -# List of interface methods to ignore, separated by a comma. This is used for -# instance to not check methods defines in Zope's Interface base class. -ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by +# Deprecated modules which should not be used, separated by a comma +deprecated-modules=regsub,TERMIOS,Bastion,rexec -# List of method names used to declare (i.e. assign) instance attributes. -defining-attr-methods=__init__,__new__,setUp +# Create a graph of every (i.e. internal and external) dependencies in the +# given file (report RP0402 must not be disabled) +import-graph= -# List of valid names for the first argument in a class method. -valid-classmethod-first-arg=cls +# Create a graph of external dependencies in the given file (report RP0402 must +# not be disabled) +ext-import-graph= -# List of valid names for the first argument in a metaclass class method. -valid-metaclass-classmethod-first-arg=mcs +# Create a graph of internal dependencies in the given file (report RP0402 must +# not be disabled) +int-import-graph= [EXCEPTIONS] diff --git a/interfaces.py b/interfaces.py index ea3b40f..067aaa6 100644 --- a/interfaces.py +++ b/interfaces.py @@ -10,7 +10,7 @@ # You should have received a copy of the GNU General Public License along with # this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -"""Interfaces for PyLint objects""" +"""Interfaces for Pylint objects""" from collections import namedtuple from logilab.common.interface import Interface diff --git a/lint.py b/lint.py index 9ef818f..b82ae04 100644 --- a/lint.py +++ b/lint.py @@ -349,7 +349,7 @@ class PyLinter(OptionsManagerMixIn, MessagesHandlerMixIn, ReportsHandlerMixIn, {'type' : 'int', 'metavar': '', 'short': 'j', 'default': 1, - 'help' : '''Use multiple processes to speed up PyLint.''', + 'help' : '''Use multiple processes to speed up Pylint.''', }), # jobs ) diff --git a/man/pylint.1 b/man/pylint.1 index 57954c8..3a5c3e9 100644 --- a/man/pylint.1 +++ b/man/pylint.1 @@ -1,4 +1,4 @@ -.TH pylint 1 "2014-7-25" pylint +.TH pylint 1 "2014-11-4" pylint .SH NAME .B pylint \- python code static checker @@ -45,23 +45,29 @@ Python code to execute, usually for sys.path manipulation such as pygtk.require( .IP "--errors-only, -E" In error mode, checkers without error messages are disabled and for others, only the ERROR messages are displayed, and no reports are done by default .IP "--ignore=[,...]" -Add files or directories to the blacklist. They should be base names, not paths. [current: .hg,test] +Add files or directories to the blacklist. They should be base names, not paths. [current: CVS] .IP "--persistent=" Pickle collected data for later comparisons. [current: yes] .IP "--load-plugins=" List of plugins (as comma separated values of python modules names) to load, usually to register additional checkers. [current: none] +.IP "--jobs=, -j " +Use multiple processes to speed up Pylint. [current: 1] .SH COMMANDS .IP "--help-msg=" Display a help message for the given message id and exit. The value may be a comma separated list of message ids. .IP "--list-msgs" Generate pylint's messages. +.IP "--list-conf-levels" +Generate pylint's messages. .IP "--full-documentation" Generate pylint's full documentation. .IP "--generate-rcfile" Generate a sample configuration file according to the current configuration. You can put other options before this one to get them in the generated configuration. .SH MESSAGES CONTROL +.IP "--confidence=" +Only show warnings with the listed confidence levels. Leave empty to show all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED [current: none] .IP "--enable=, -e " Enable the message, report, category or checker with the given id(s). You can either give multiple identifier separated by comma (,) or put this option multiple time. See also the "--disable" option for examples. .IP "--disable=, -d " @@ -81,20 +87,36 @@ Add a comment according to your evaluation note. This is used by the global eval .IP "--msg-template=