Skip to content

Commit

Permalink
Add examples of config file content to FAQ (#6195)
Browse files Browse the repository at this point in the history
Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com>
  • Loading branch information
bittner and Pierre-Sassoulas committed Apr 20, 2022
1 parent 000c6f8 commit e087b41
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 19 deletions.
61 changes: 43 additions & 18 deletions doc/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ supported.
.. _`astroid`: https://github.com/PyCQA/astroid

2.4 What versions of Python is Pylint supporting?
--------------------------------------------------
-------------------------------------------------

The supported running environment since Pylint 2.14.0 is Python 3.7.2+.

Expand All @@ -55,7 +55,7 @@ The supported running environment since Pylint 2.14.0 is Python 3.7.2+.
=================

3.1 Can I give pylint a file as an argument instead of a module?
-----------------------------------------------------------------
----------------------------------------------------------------

Pylint expects the name of a package or module as its argument. As a
convenience, you can give it a file name if it's possible to guess a module name from
Expand Down Expand Up @@ -83,7 +83,7 @@ or if "directory" is in the python path.
on...

3.2 Where is the persistent data stored to compare between successive runs?
----------------------------------------------------------------------------
---------------------------------------------------------------------------

Analysis data are stored as a pickle file in a directory which is
localized using the following rules:
Expand All @@ -100,8 +100,9 @@ localized using the following rules:

* ".pylint.d" directory in the current directory


3.3 How do I find the option name corresponding to a specific command line option?
--------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------

You can generate a sample configuration file with ``--generate-toml-config``.
Every option present on the command line before this will be included in
Expand Down Expand Up @@ -186,26 +187,52 @@ No, you can use symbolic names for messages::


4.5 I have a callback function where I have no control over received arguments. How do I avoid getting unused argument warnings?
----------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------

Prefix (ui) the callback's name by `cb_`, as in cb_onclick(...). By
doing so arguments usage won't be checked. Another solution is to
use one of the names defined in the "dummy-variables" configuration
variable for unused argument ("_" and "dummy" by default).

4.6 What is the format of the configuration file?
---------------------------------------------------
-------------------------------------------------

Pylint uses ConfigParser from the standard library to parse the configuration
file. It means that if you need to disable a lot of messages, you can use
tricks like: ::
any formatting accepted by ConfigParser, e.g.

.. code-block:: ini
[MASTER]
output-format = colorized
# disable wildcard-import, method-hidden and too-many-lines
disable=
wildcard-import,
method-hidden,
[Messages Control]
disable=method-hidden,too-many-lines,wildcard-import
.. code-block:: ini
[Messages Control]
disable =
method-hidden
too-many-lines
wildcard-import
Alternatively, if you use ``pyproject.toml``, e.g.

.. code-block:: toml
[tool.pylint.master]
output-format = "colorized"
[tool.pylint.messages_control]
disable = [
"method-hidden",
"too-many-lines",
"wildcard-import",
]
See also the :ref:`exhaustive list of possible options
<user_guide/configuration/all-options:all pylint options>`.

4.7 Why are there a bunch of messages disabled by default?
----------------------------------------------------------
Expand All @@ -214,9 +241,8 @@ pylint does have some messages disabled by default, either because
they are prone to false positives or that they are opinionated enough
for not being included as default messages.

You can see the plugin you need to explicitly `load in the technical reference`_

.. _`load in the technical reference`: https://pylint.pycqa.org/en/latest/technical_reference/extensions.html?highlight=load%20plugin
You can see the plugin you need to explicitly :ref:`load in the technical reference
<technical_reference/extensions:optional pylint checkers in the extensions module>`.

4.8 I am using another popular linter alongside pylint. Which messages should I disable to avoid duplicates?
------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -247,15 +273,14 @@ flake8-import-order_: wrong-import-order
5. Classes and Inheritance
==========================


5.1 When is Pylint considering a class as an abstract class?
-------------------------------------------------------------
------------------------------------------------------------

A class is considered as an abstract class if at least one of its
methods is doing nothing but raising NotImplementedError.
methods is doing nothing but raising ``NotImplementedError``.

5.2 How do I avoid "access to undefined member" messages in my mixin classes?
-------------------------------------------------------------------------------
-----------------------------------------------------------------------------

You should add the ``no-member`` message to your ``ignored-checks-for-mixins`` option
and name your mixin class with a name which ends with "Mixin" or "mixin" (default)
Expand Down
4 changes: 3 additions & 1 deletion doc/messages/messages_list.rst
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ All messages in the warning category:
warning/binary-op-exception.rst
warning/boolean-datetime.rst
warning/broad-except.rst
warning/cache-max-size-none.rst
warning/cell-var-from-loop.rst
warning/comparison-with-callable.rst
warning/confusing-with-statement.rst
Expand Down Expand Up @@ -250,6 +249,7 @@ All messages in the warning category:
warning/logging-fstring-interpolation.rst
warning/logging-not-lazy.rst
warning/lost-exception.rst
warning/method-cache-max-size-none.rst
warning/misplaced-future.rst
warning/missing-any-param-doc.rst
warning/missing-format-argument-key.rst
Expand Down Expand Up @@ -294,6 +294,7 @@ All messages in the warning category:
warning/subprocess-popen-preexec-fn.rst
warning/subprocess-run-check.rst
warning/super-init-not-called.rst
warning/super-without-brackets.rst
warning/too-many-try-statements.rst
warning/try-except-raise.rst
warning/unbalanced-tuple-unpacking.rst
Expand Down Expand Up @@ -329,6 +330,7 @@ All renamed messages in the warning category:
:maxdepth: 1
:titlesonly:

warning/cache-max-size-none.rst
warning/implicit-str-concat-in-sequence.rst
warning/lru-cache-decorating-method.rst
warning/old-assignment-from-none.rst
Expand Down

0 comments on commit e087b41

Please sign in to comment.