Skip to content

Commit ac2713a

Browse files
[doc] Merge run help from the FAQ to the user guide doc
1 parent 45a586c commit ac2713a

File tree

2 files changed

+30
-75
lines changed

2 files changed

+30
-75
lines changed

doc/faq.rst

+2-52
Original file line numberDiff line numberDiff line change
@@ -24,35 +24,7 @@ Pylint uses git. To get the latest version of Pylint from the repository, simply
2424
3. Running Pylint
2525
=================
2626

27-
3.1 Can I give pylint a file as an argument instead of a module?
28-
----------------------------------------------------------------
29-
30-
Pylint expects the name of a package or module as its argument. As a
31-
convenience, you can give it a file name if it's possible to guess a module name from
32-
the file's path using the python path. Some examples:
33-
34-
"pylint mymodule.py" should always work since the current working
35-
directory is automatically added on top of the python path
36-
37-
"pylint directory/mymodule.py" will work if "directory" is a python
38-
package (i.e. has an __init__.py file), an implicit namespace package
39-
or if "directory" is in the python path.
40-
41-
"pylint /whatever/directory/mymodule.py" will work if either:
42-
43-
- "/whatever/directory" is in the python path
44-
45-
- your cwd is "/whatever/directory"
46-
47-
- "directory" is a python package and "/whatever" is in the python
48-
path
49-
50-
- "directory" is an implicit namespace package and is in the python path.
51-
52-
- "directory" is a python package and your cwd is "/whatever" and so
53-
on...
54-
55-
3.2 Where is the persistent data stored to compare between successive runs?
27+
3.1 Where is the persistent data stored to compare between successive runs?
5628
---------------------------------------------------------------------------
5729

5830
Analysis data are stored as a pickle file in a directory which is
@@ -71,7 +43,7 @@ localized using the following rules:
7143
* ".pylint.d" directory in the current directory
7244

7345

74-
3.3 How do I find the option name corresponding to a specific command line option?
46+
3.2 How do I find the option name corresponding to a specific command line option?
7547
----------------------------------------------------------------------------------
7648

7749
You can generate a sample configuration file with ``--generate-toml-config``.
@@ -82,28 +54,6 @@ For example::
8254

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

85-
3.5 I need to run pylint over all modules and packages in my project directory.
86-
-------------------------------------------------------------------------------
87-
88-
By default the ``pylint`` command only accepts a list of python modules and packages. Using a
89-
directory which is not a package results in an error::
90-
91-
pylint mydir
92-
************* Module mydir
93-
mydir/__init__.py:1:0: F0010: error while code parsing: Unable to load file mydir/__init__.py:
94-
[Errno 2] No such file or directory: 'mydir/__init__.py' (parse-error)
95-
96-
To execute pylint over all modules and packages under the directory, the ``--recursive=y`` option must
97-
be provided. This option makes ``pylint`` attempt to discover all modules (files ending with ``.py`` extension)
98-
and all packages (all directories containing a ``__init__.py`` file).
99-
Those modules and packages are then analyzed::
100-
101-
pylint --recursive=y mydir
102-
103-
When ``--recursive=y`` option is used, modules and packages are also accepted as parameters::
104-
105-
pylint --recursive=y mydir mymodule mypackage
106-
10757
4. Message Control
10858
==================
10959

doc/user_guide/run.rst

+28-23
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,46 @@
22
Running Pylint
33
================
44

5-
From the command line
6-
---------------------
5+
On module packages or directories
6+
---------------------------------
77

88
Pylint is meant to be called from the command line. The usage is ::
99

1010
pylint [options] modules_or_packages
1111

12-
You should give Pylint the name of a python package or module, or some number
13-
of packages or modules. Pylint
14-
``will not import`` this package or module, though uses Python internals
15-
to locate them and as such is subject to the same rules and configuration.
16-
You should pay attention to your ``PYTHONPATH``, since it is a common error
17-
to analyze an installed version of a module instead of the
18-
development version.
12+
By default the ``pylint`` command only accepts a list of python modules and packages. Using a
13+
directory which is not a package results in an error::
14+
15+
pylint mydir
16+
************* Module mydir
17+
mydir/__init__.py:1:0: F0010: error while code parsing: Unable to load file mydir/__init__.py:
18+
[Errno 2] No such file or directory: 'mydir/__init__.py' (parse-error)
1919

20-
It is also possible to analyze Python files, with a few
21-
restrictions. The thing to keep in mind is that Pylint will try to
22-
convert the file name to a module name, and only be able to process
23-
the file if it succeeds. ::
20+
When ``--recursive=y`` option is used, modules and packages are also accepted as parameters::
2421

25-
pylint mymodule.py
22+
pylint --recursive=y mydir mymodule mypackage
2623

27-
should always work since the current working
28-
directory is automatically added on top of the python path ::
24+
This option makes ``pylint`` attempt to discover all modules (files ending with ``.py`` extension)
25+
and all packages (all directories containing a ``__init__.py`` file).
26+
27+
Pylint **will not import** this package or module, though uses Python internals
28+
to locate them and as such is subject to the same rules and configuration.
29+
You should pay attention to your ``PYTHONPATH``, since it is a common error
30+
to analyze an installed version of a module instead of the development version.
2931

30-
pylint directory/mymodule.py
32+
On files
33+
--------
3134

32-
will work if ``directory`` is a python package (i.e. has an __init__.py
33-
file or it is an implicit namespace package) or if "directory" is in the
34-
python path.
35+
It is also possible to analyze Python files, with a few restrictions. As a convenience,
36+
you can give it a file name if it's possible to guess a module name from the file's
37+
path using the python path. Some examples:
3538

36-
By default, pylint will exit with an error when one of the arguments is a directory which is not
37-
a python package. In order to run pylint over all modules and packages within the provided
38-
subtree of a directory, the ``--recursive=y`` option must be provided.
39+
``pylint mymodule.py`` should always work since the current working
40+
directory is automatically added on top of the python path
3941

42+
``pylint directory/mymodule.py`` will work if: ``directory`` is a python
43+
package (i.e. has an ``__init__.py`` file), an implicit namespace package
44+
or if ``directory`` is in the python path.
4045

4146
Command line options
4247
--------------------

0 commit comments

Comments
 (0)