4812N/APylint is a static code checker, meaning it can analyse your code
4812N/Awithout actually running it. Pylint checks for errors, tries to
4812N/Aenforce a coding standard, and tries to enforce a coding style.
4812N/A1.2 How is Pylint different from Pychecker?
4812N/A-------------------------------------------
4812N/AA major difference between Pylint and Pychecker is that Pylint checks
4812N/Afor style issues, while Pychecker explicitly does not. There are a few
4812N/Aother differences, such as the fact that Pylint does not import live
4812N/Amodules while Pychecker does (see 6.2 Why does Pychecker catch
4812N/Aproblems with imports that Pylint doesn't?).
4812N/APylint's main author and maintainer for the first ten years of its
4812N/Alife has been Sylvain Thénault, while he worked at Logilab where the
4812N/Aproject was born. For a full list of contributors, see the
4812N/A"Contributors" section of Pylint's README file.
4812N/AEverybody knows someone who uses Pylint.
4812N/A2.1 How do I install Pylint?
4812N/A----------------------------
4812N/A2.2 What kind of versioning system does Pylint use?
4812N/A---------------------------------------------------
4812N/APylint uses the Mercurial distributed version control system. The URL
4812N/Alatest version of Pylint from the repository, simply invoke
4812N/A2.3 What are Pylint's dependencies?
4812N/A-----------------------------------
4812N/APylint requires the latest astroid and logilab-common packages. It
4812N/Ashould be compatible with any Python version greater than 2.7.0.
4812N/A2.4 What versions of Python is Pylint supporting?
4812N/A-------------------------------------------------
4812N/ASince Pylint 1.4, we support only Python 2.7+ and Python 3.3+. Using
4812N/Athis strategy really helps in maintaining a code base compatible with
4812N/Aboth versions and from this benefits not only the maintainers, but the
4812N/Aend users as well, because it's easier to add and test new features.
4812N/AIf support for Python 2.6 is absolutely required, then the version
4812N/Afrom pylint-1.3 branch can be used. It will receive backports of bug
4812N/A3.1 Can I give pylint a file as an argument instead of a module?
4812N/A----------------------------------------------------------------
4812N/APylint expects the name of a package or module as its argument. As a
4812N/Aconvenience, you can give it a file name if it's possible to guess a
4812N/Amodule name from the file's path using the python path. Some examples
4812N/Adirectory is automatically added on top of the python path
4812N/A * "directory" is a python package and "/whatever" is in the
4812N/A * "directory" is a python package and your cwd is "/whatever" and
4812N/A3.2 Where is the persistent data stored to compare between successive runs?
4812N/A---------------------------------------------------------------------------
4812N/AAnalysis data are stored as a pickle file in a directory which is
4812N/Alocalized using the following rules:
4812N/A* value of the PYLINTHOME environment variable if set
4812N/A (not always findable on Windows platforms)
4812N/A3.3 How do I find the option name (for pylintrc) corresponding to a specific command line option?
4812N/A-------------------------------------------------------------------------------------------------
4812N/AYou can always generate a sample pylintrc file with --generate-rcfile
4812N/AEvery option present on the command line before this will be included
4812N/A pylint --disable=bare-except,invalid-name --class-rgx='[A-Z][a-z]+' --generate-rcfile
4812N/A3.4 I'd rather not run Pylint from the command line. Can I integrate it with my editor?
4812N/A---------------------------------------------------------------------------------------
4812N/A4.1 Is it possible to locally disable a particular message?
4812N/A-----------------------------------------------------------
4812N/AYes, this feature has been added in Pylint 0.11. This may be done by
4812N/Aadding "#pylint: disable=some-message,another-one" at the desired
4812N/Ablock level or at the end of the desired line of code
4812N/A4.2 Is there a way to disable a message for a particular module only?
4812N/A---------------------------------------------------------------------
4812N/AYes, you can disable or enable (globally disabled) messages at the
4812N/Amodule level by adding the corresponding option in a comment at the
4812N/A # pylint: disable=wildcard-import, method-hidden
4812N/A # pylint: enable=too-many-lines
4812N/A4.3 How can I tell Pylint to never check a given module?
4812N/A--------------------------------------------------------
4812N/AWith Pylint < 0.25, add "#pylint: disable-all" at the beginning of the
4812N/Amodule. Pylint 0.26.1 and up have renamed that directive to "#pylint:
4812N/Askip-file" (but the first version will be kept for backward
4812N/AIn order to ease finding which modules are ignored a Information-level
4812N/Amessage *file-ignored* is emited. With recent versions of Pylint, if
4812N/Ayou use the old syntax, an additional *deprecated-disable-all* message
4812N/A4.4 Do I have to remember all these numbers?
4812N/A--------------------------------------------
4812N/ANo, starting from 0.25.3, you can use symbolic names for messages:
4812N/A # pylint: disable=fixme, line-too-long
4812N/A4.5 I have a callback function where I have no control over received arguments. How do I avoid getting unused argument warnings?
4812N/A--------------------------------------------------------------------------------------------------------------------------------
4812N/APrefix (ui) the callback's name by *cb_*, as in cb_onclick(...). By
4812N/Adoing so arguments usage won't be checked. Another solution is to use
4812N/Aone of the names defined in the "dummy-variables" configuration
4812N/Avariable for unused argument ("_" and "dummy" by default).
4812N/A4.6 What is the format of the configuration file?
4812N/A-------------------------------------------------
4812N/APylint uses ConfigParser from the standard library to parse the
4812N/Aconfiguration file. It means that if you need to disable a lot of
4812N/Amessages, you can use tricks like:
4812N/A # disable wildcard-import, method-hidden and too-many-lines because I do
4812N/A5.1 When is Pylint considering a class as an interface?
4812N/A-------------------------------------------------------
4812N/AA class is considered as an interface if there is a class named
4812N/A"Interface" somewhere in its inheritance tree.
4812N/A5.2 When is Pylint considering that a class is implementing a given interface?
4812N/A------------------------------------------------------------------------------
4812N/APylint is using the Zope 2 interfaces conventions, and so is
4812N/Aconsidering that a class is implementing interfaces listed in its
4812N/A5.3 When is Pylint considering a class as an abstract class?
4812N/A------------------------------------------------------------
4812N/AA class is considered as an abstract class if at least one of its
4812N/Amethods is doing nothing but raising NotImplementedError.
4812N/A5.4 How do I avoid "access to undefined member" messages in my mixin classes?
4812N/A-----------------------------------------------------------------------------
4812N/ATo do so you have to set the ignore-mixin-members option to "yes"
4812N/A(this is the default value) and to name your mixin class with a name
4812N/Awhich ends with "mixin" (whatever case).
4812N/A6.1 Pylint gave my code a negative rating out of ten. That can't be right!
4812N/A--------------------------------------------------------------------------
4812N/AEven though the final rating Pylint renders is nominally out of ten,
4812N/Athere's no lower bound on it. By default, the formula to calculate
4812N/A 10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
4812N/AHowever, this option can be changed in the Pylint rc file. If having
4812N/Anegative values really bugs you, you can set the formula to be the
4812N/Amaximum of 0 and the above expression.
4812N/A6.2 Why does Pychecker catch problems with imports that Pylint doesn't?
4812N/A-----------------------------------------------------------------------
4812N/APychecker and Pylint use different approaches. pychecker imports the
4812N/Amodules and rummages around in the result, hence it sees my mangled
4812N/Adoesn't include any of import's side effects (good and bad). It
4812N/Atraverses an AST representation of the code.
4812N/A6.3 Pylint keeps crashing with *Maximum recursion depth exceeded*
4812N/A-----------------------------------------------------------------
4812N/APylint can crash with this error if you have a string in your analyzed
4812N/Aprogram, created by joining a lot of strings with the addition
4812N/Aoperator. Due to how Pylint works, visiting nodes on a AST tree and
4812N/Adue to how the BinOp node is represented (the node which represents
4812N/Athe string '1+1' for instance), the same visit method will be called
4812N/Aover and over again, leading to a maximum recursion error. You can
4812N/Aalleviate this problem by passing the flag *--optimize-ast=y* to
4812N/APylint. This will activate an optimization which will transform such
4812N/AAST subtrees into the final resulting string. This flag is off by
4812N/Adefault. If this is not the case, please report a bug!
4812N/A6.4 I think I found a bug in Pylint. What should I do?
4812N/A------------------------------------------------------
4812N/A6.5 I have a question about Pylint that isn't answered here.
4812N/A------------------------------------------------------------