-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Burst run's documentation between user guide and dev guide, merge FAQ's run questions in the user guide #6658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Pierre-Sassoulas
merged 8 commits into
pylint-dev:main
from
Pierre-Sassoulas:burst-run-between-user-guide-and-dev-guide
May 22, 2022
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
45a586c
Burst run into user guide and dev guide
Pierre-Sassoulas ac2713a
[doc] Merge run help from the FAQ to the user guide doc
Pierre-Sassoulas 2242a2a
Update doc/development_guide/run.rst
Pierre-Sassoulas c4242d6
Rename
Pierre-Sassoulas 0789f49
Separate epylint
Pierre-Sassoulas 1421a73
Rename run to API for dev doc
Pierre-Sassoulas 34ebbca
Add a text for the api index
Pierre-Sassoulas e87b2ce
Apply change from https://github.com/PyCQA/pylint/pull/6658\#discussiβ¦
Pierre-Sassoulas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
======= | ||
epylint | ||
======= | ||
|
||
To silently run epylint on a ``module_name.py`` module, and get its standard output and error: | ||
|
||
.. sourcecode:: python | ||
|
||
from pylint import epylint as lint | ||
|
||
(pylint_stdout, pylint_stderr) = lint.py_run('module_name.py', return_std=True) | ||
|
||
It is also possible to include additional Pylint options in the first argument to ``py_run``: | ||
|
||
.. sourcecode:: python | ||
|
||
from pylint import epylint as lint | ||
|
||
(pylint_stdout, pylint_stderr) = lint.py_run('module_name.py --disable C0114', return_std=True) | ||
|
||
The options ``--msg-template="{path}:{line}: {category} ({msg_id}, {symbol}, {obj}) {msg}"`` and | ||
``--reports=n`` are set implicitly inside the ``epylint`` module. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
### | ||
API | ||
### | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should probably write something here. https://pylint--6658.org.readthedocs.build/en/6658/development_guide/api/index.html feels a bit empty. |
||
You can call ``Pylint``, ``epylint``, ``symilar`` and ``pyreverse`` from another | ||
Python program thanks to their APIs: | ||
|
||
.. sourcecode:: python | ||
|
||
from pylint import run_pylint, run_epylint, run_pyreverse, run_symilar | ||
|
||
run_pylint("--disable=C", "myfile.py") | ||
run_epylint(...) | ||
run_pyreverse(...) | ||
run_symilar(...) | ||
|
||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
:hidden: | ||
|
||
pylint | ||
epylint |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
======= | ||
Pylint | ||
======= | ||
|
||
As you would launch the command line | ||
------------------------------------ | ||
|
||
You can use the ``run_pylint`` function, which is the same function | ||
called by the command line (using ``sys.argv``). You can supply | ||
arguments yourself: | ||
|
||
.. sourcecode:: python | ||
|
||
from pylint import run_pylint | ||
|
||
run_pylint(argv=["--disable=line-too-long", "myfile.py"]) | ||
|
||
|
||
Recover the result in a stream | ||
------------------------------ | ||
|
||
You can also use ``pylint.lint.Run`` directly if you want to do something that | ||
can't be done using only pylint's command line options. Here's the basic example: | ||
|
||
.. sourcecode:: python | ||
|
||
from pylint.lint import Run | ||
|
||
Run(argv=["--disable=line-too-long", "myfile.py"]) | ||
|
||
With ``Run`` it is possible to invoke pylint programmatically with a | ||
reporter initialized with a custom stream: | ||
|
||
.. sourcecode:: python | ||
|
||
from io import StringIO | ||
|
||
from pylint.lint import Run | ||
from pylint.reporters.text import TextReporter | ||
|
||
pylint_output = StringIO() # Custom open stream | ||
reporter = TextReporter(pylint_output) | ||
Run(["test_file.py"], reporter=reporter, do_exit=False) | ||
print(pylint_output.getvalue()) # Retrieve and print the text report | ||
|
||
The reporter can accept any stream object as as parameter. In this example, | ||
the stream outputs to a file: | ||
|
||
.. sourcecode:: python | ||
|
||
from pylint.lint import Run | ||
from pylint.reporters.text import TextReporter | ||
|
||
with open("report.out", "w") as f: | ||
reporter = TextReporter(f) | ||
Run(["test_file.py"], reporter=reporter, do_exit=False) | ||
|
||
This would be useful to capture pylint output in an open stream which | ||
can be passed onto another program. | ||
|
||
If your program expects that the files being linted might be edited | ||
between runs, you will need to clear pylint's inference cache: | ||
|
||
.. sourcecode:: python | ||
|
||
from pylint.lint import pylinter | ||
pylinter.MANAGER.clear_cache() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,5 @@ Development | |
|
||
contribute | ||
testing | ||
api/index | ||
profiling |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole section of
API
should probably go intoUser guide
? It's more usage related than development related right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me everything that is not doable by using the pylint executable with options is development. (Beside creating a file to call epylint's API is development ?).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But
Development
is about developingpylint
right? Sincepylint
is a developer's tool everything related to it will be "development", but I feel like this is more part of "using pylint" than "developing or contributing to pylint". We never use these APIs in our own development and you don't really need them when writing a checker.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, it's still unclear what is what. How about this:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that! Although I would perhaps put Developers and Contributing under a more general header of "Development" like black does. That would also allow showing some of the sub-headers of Usage in the sidebar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we're almost ready to do the big table of content revamp then π .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm planning on adding readme and release.md first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll let you choose, but I'd prefer a PR that sets up the TOC first. It's quite hard to review content + redirects + new pages at the same time.
If we create one PR with all pages/sections we want to have and make sure redirects work we can then do the content afterwards. I would even be okay with adding some blank pages for now considering that you're working on this quite hard at the moment.