mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-01 19:36:54 +00:00
Merge branch 'patch-1' into 'master'
Recommend registering plugin options using `add_options` and `parse_options`... See merge request pycqa/flake8!272
This commit is contained in:
commit
c645a6761d
1 changed files with 7 additions and 7 deletions
|
|
@ -65,10 +65,10 @@ once per file. The parameters listed above can be combined with
|
|||
Registering Options
|
||||
===================
|
||||
|
||||
Any plugin that has callable attributes ``provide_options`` and
|
||||
``register_options`` can parse option information and register new options.
|
||||
Any plugin that has callable attributes ``add_options`` and
|
||||
``parse_options`` can parse option information and register new options.
|
||||
|
||||
Your ``register_options`` function should expect to receive an instance of
|
||||
Your ``add_options`` function should expect to receive an instance of
|
||||
|OptionManager|. An |OptionManager| instance behaves very similarly to
|
||||
:class:`optparse.OptionParser`. It, however, uses the layer that |Flake8| has
|
||||
developed on top of :mod:`optparse` to also handle configuration file parsing.
|
||||
|
|
@ -157,19 +157,19 @@ documentation of :mod:`optparse`.
|
|||
Accessing Parsed Options
|
||||
========================
|
||||
|
||||
When a plugin has a callable ``provide_options`` attribute, |Flake8| will call
|
||||
When a plugin has a callable ``parse_options`` attribute, |Flake8| will call
|
||||
it and attempt to provide the |OptionManager| instance, the parsed options
|
||||
which will be an instance of :class:`optparse.Values`, and the extra arguments
|
||||
that were not parsed by the |OptionManager|. If that fails, we will just pass
|
||||
the :class:`optparse.Values`. In other words, your ``provide_options``
|
||||
the :class:`optparse.Values`. In other words, your ``parse_options``
|
||||
callable will have one of the following signatures:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
def provide_options(option_manager, options, args):
|
||||
def parse_options(option_manager, options, args):
|
||||
pass
|
||||
# or
|
||||
def provide_options(options):
|
||||
def parse_options(options):
|
||||
pass
|
||||
|
||||
.. substitutions
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue