mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-10 06:44:18 +00:00
Grammar and clarity improvements.
This commit is contained in:
parent
fd5c7d009d
commit
330fdb5b56
15 changed files with 45 additions and 45 deletions
|
|
@ -2,17 +2,17 @@
|
|||
How Checks are Run
|
||||
====================
|
||||
|
||||
In Flake8 2.x, Flake8 delegated check running to pep8. In 3.0 we have taken
|
||||
that responsibility upon ourselves. This has allowed us to simplify our
|
||||
handling of the ``--jobs`` parameter (using :mod:`multiprocessing`) as well as
|
||||
simplifying our fallback in the event something goes awry with concurency.
|
||||
In Flake8 2.x, Flake8 delegated check running to pep8. In 3.0 flake8 takes
|
||||
on that responsibility. This has allowed for simpler
|
||||
handling of the ``--jobs`` parameter (using :mod:`multiprocessing`) and
|
||||
simplified our fallback if something goes awry with concurency.
|
||||
At the lowest level we have a |FileChecker|. Instances of |FileChecker| are
|
||||
created for *each* file to be analyzed by Flake8. Each instance, has a copy of
|
||||
all of the plugins registered with setuptools in the ``flake8.extension``
|
||||
entry-point group.
|
||||
|
||||
The |FileChecker| instances are managed by an instance of |Manager|. The
|
||||
|Manager| instance is what handles creating sub-processes with
|
||||
|Manager| instance handles creating sub-processes with
|
||||
:mod:`multiprocessing` module and falling back to running checks in serial if
|
||||
an operating system level error arises. When creating |FileChecker| instances,
|
||||
the |Manager| is responsible for determining if a particular file has been
|
||||
|
|
@ -23,10 +23,10 @@ Processing Files
|
|||
----------------
|
||||
|
||||
Unfortunately, since Flake8 took over check running from pep8/pycodestyle, it
|
||||
also was required to take over parsing and processing files for the checkers
|
||||
to use. Since we couldn't reuse pycodestyle's functionality (since it did not
|
||||
separate cleanly the processing from check running) we isolated that function
|
||||
into the :class:`~flake8.processor.FileProcessor` class. Further, we moved
|
||||
also had to take over parsing and processing files for the checkers
|
||||
to use. Since it couldn't reuse pycodestyle's functionality (since it did not
|
||||
separate cleanly the processing from check running) that function was isolated
|
||||
into the :class:`~flake8.processor.FileProcessor` class. We moved
|
||||
several helper functions into the :mod:`flake8.processor` module (see also
|
||||
:ref:`Processor Utility Functions <processor_utility_functions>`).
|
||||
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ command line, :func:`~flake8.main.cli.main` is run which handles
|
|||
management of the application.
|
||||
|
||||
User input is parsed *twice* to accomodate logging and verbosity options
|
||||
passed by the user as early as possible so as much logging can be produced as
|
||||
possible.
|
||||
passed by the user as early as possible.
|
||||
This is so as much logging can be produced as possible.
|
||||
|
||||
The default flake8 options are registered by
|
||||
:func:`~flake8.main.options.register_default_options`. Trying to register
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
Contributing to Flake8
|
||||
========================
|
||||
|
||||
We encourage multiple methods of participation in Flake8:
|
||||
There are many ways to contriubte to Flake8, and we encourage them all:
|
||||
|
||||
- contributing bug reports and feature requests
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ To contribute to Flake8's development, you simply need:
|
|||
|
||||
python<version> -m pip install --user tox
|
||||
|
||||
- and your favorite editor
|
||||
- your favorite editor
|
||||
|
||||
|
||||
Filing a Bug
|
||||
|
|
@ -166,7 +166,7 @@ Reviewing and Triaging Issues and Merge Requests
|
|||
================================================
|
||||
|
||||
When reviewing other people's merge requests and issues, please be
|
||||
**especially** mindful of how the words you choose can be ready by someone
|
||||
**especially** mindful of how the words you choose can be read by someone
|
||||
else. We strive for professional code reviews that do not insult the
|
||||
contributor's intelligence or impugn their character. The code review
|
||||
should be focused on the code, it's effectiveness, and whether it is
|
||||
|
|
@ -175,8 +175,8 @@ appropriate for Flake8.
|
|||
If you have the ability to edit an issue or merge request's labels, please do
|
||||
so to make search and prioritization easier.
|
||||
|
||||
Flake8 uses milestones with both issues and merge requests to provide
|
||||
other contributors direction about when an issue or merge request will be
|
||||
Flake8 uses milestones with both issues and merge requests. This provides
|
||||
direction for other contributors about when an issue or merge request will be
|
||||
delivered.
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ Default Formatter
|
|||
The |DefaultFormatter| continues to use the same default format string as
|
||||
pep8: ``'%(path)s:%(row)d:%(col)d: %(code)s %(text)s'``.
|
||||
|
||||
In order to provide the default functionality it overrides two methods:
|
||||
To provide the default functionality it overrides two methods:
|
||||
|
||||
#. ``after_init``
|
||||
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ Option Management
|
|||
|
||||
Command-line options are often also set in configuration files for Flake8.
|
||||
While not all options are meant to be parsed from configuration files, many
|
||||
default options are also parsed from configuration files as are most plugin
|
||||
options.
|
||||
default options are also parsed from configuration files as well as
|
||||
most plugin options.
|
||||
|
||||
In Flake8 2, plugins received a :class:`optparse.OptionParser` instance and
|
||||
called :meth:`optparse.OptionParser.add_option` to register options. If the
|
||||
|
|
@ -19,7 +19,7 @@ also had to do something like:
|
|||
parser.config_options.append('my_config_option')
|
||||
parser.config_options.extend(['config_opt1', 'config_opt2'])
|
||||
|
||||
This was previously undocumented and led to a lot of confusion as to why
|
||||
This was previously undocumented and led to a lot of confusion about why
|
||||
registered options were not automatically parsed from configuration files.
|
||||
|
||||
Since Flake8 3 was rewritten from scratch, we decided to take a different
|
||||
|
|
@ -40,8 +40,8 @@ three new parameters:
|
|||
- ``normalize_paths``
|
||||
|
||||
The last two are not specifically for configuration file handling, but they
|
||||
do improve that dramatically. We found that there were options that when
|
||||
specified in a configuration file, lended themselves to being split across
|
||||
do improve that dramatically. We found that there were options that, when
|
||||
specified in a configuration file, often necessitated being spit
|
||||
multiple lines and those options were almost always comma-separated. For
|
||||
example, let's consider a user's list of ignored error codes for a project:
|
||||
|
||||
|
|
@ -82,7 +82,7 @@ Presently OpenStack's Nova project has this line in their `tox.ini`_:
|
|||
|
||||
exclude = .venv,.git,.tox,dist,doc,*openstack/common/*,*lib/python*,*egg,build,tools/xenserver*,releasenotes
|
||||
|
||||
I think we can all agree that this would be easier to read like this:
|
||||
We think we can all agree that this would be easier to read like this:
|
||||
|
||||
.. code-block:: ini
|
||||
|
||||
|
|
@ -104,7 +104,7 @@ both ``comma_separated_list=True`` and ``normalize_paths=True`` because we
|
|||
want the paths to be provided to us with some consistency (either all absolute
|
||||
paths or not).
|
||||
|
||||
Now let's look at how this would actually be utilized. Most plugin developers
|
||||
Now let's look at how this will actually be used. Most plugin developers
|
||||
will receive an instance of :class:`~flake8.options.manager.OptionManager` so
|
||||
to ease the transition we kept the same API as the
|
||||
:class:`optparse.OptionParser` object. The only difference is that
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ checks. It now supports:
|
|||
|
||||
- listeners to auto-correct violations of checks
|
||||
|
||||
To facilitate this, Flake8 needed a more mature way of managing plugins. As
|
||||
such, we developed the |PluginManager| which accepts a namespace and will load
|
||||
To facilitate this, Flake8 needed a more mature way of managing plugins.
|
||||
Thus, we developed the |PluginManager| which accepts a namespace and will load
|
||||
the plugins for that namespace. A |PluginManager| creates and manages many
|
||||
|Plugin| instances.
|
||||
|
||||
|
|
@ -24,7 +24,7 @@ The entry-point will be loaded either by calling
|
|||
attribute. We also use this abstraction to retrieve options that the plugin
|
||||
wishes to register and parse.
|
||||
|
||||
The only public method that the |PluginManager| provides is
|
||||
The only public method the |PluginManager| provides is
|
||||
:meth:`~flake8.plugins.manager.PluginManager.map`. This will accept a function
|
||||
(or other callable) and call it with each plugin as the first parameter.
|
||||
|
||||
|
|
@ -59,7 +59,7 @@ Notifying Listener Plugins
|
|||
One of the interesting challenges with allowing plugins to be notified each
|
||||
time an error or warning is emitted by a checker is finding listeners quickly
|
||||
and efficiently. It makes sense to allow a listener to listen for a certain
|
||||
class of warnings or just a specific warning. As such, we need to allow all
|
||||
class of warnings or just a specific warning. Hence, we need to allow all
|
||||
plugins that listen to a specific warning or class to be notified. For
|
||||
example, someone might register a listener for ``E1`` and another for ``E111``
|
||||
if ``E111`` is triggered by the code, both listeners should be notified.
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ argument so we can check the parameters of the plugin consistently.
|
|||
|
||||
.. autofunction:: flake8.utils.parse_unified_diff
|
||||
|
||||
In order to handle usage of :option:`flake8 --diff`, Flake8 needs to be able
|
||||
To handle usage of :option:`flake8 --diff`, Flake8 needs to be able
|
||||
to parse the name of the files in the diff as well as the ranges indicated the
|
||||
sections that have been changed. This function either accepts the diff as an
|
||||
argument or reads the diff from standard-in. It then returns a dictionary with
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue