Document new way of registering local plugins

The way plugins has changed with flake8 2.5, document the new way.

Change-Id: I2d952cecaf7e267893f478427e396a5db88e7190
This commit is contained in:
Andreas Jaeger 2020-03-30 11:42:04 +02:00 committed by Andreas Jaeger
parent d5486f9dd3
commit d35b660536
1 changed files with 28 additions and 14 deletions

View File

@ -114,24 +114,38 @@ For example to enable H106 and H203:
Local Checks
hacking supports having local changes in a source tree. They can be configured
to run in two different ways. They can be registered individually, or with
a factory function.
hacking supports having local changes in a source tree. They need to
be registered individually in tox.ini:
For individual registration, put a comma separated list of pep8 compatible
check functions into the hacking section of tox.ini. E.g.:
Add to tox.ini a new section `flake8:local-plugins` and list each plugin with
its entry-point. Additionally, you can add the path to the files
containing the plugins so that the repository does not need to be
installed with the `paths` directive.
.. code-block:: ini
local-check = nova.tests.hacking.bad_code_is_terrible
extension =
N307 = checks:import_no_db_in_virt
N325 = checks:CheckForStrUnicodeExc
paths =
Alternately, you can specify the location of a callable that will be called
at registration time and will be passed the registration function. The callable
should expect to call the passed in function on everything if wants to
register. Such as:
The plugins, in the example above they live in
`nova/hacking/`, need to annotate all functions with `@core.flake8ext`
.. code-block:: ini
.. code-block:: python
local-check-factory = nova.tests.hacking.factory
from hacking import core
def import_no_db_in_virt(logical_line, filename):
class CheckForStrUnicodeExc(BaseASTChecker):
name = "check_for_str_unicode_exc"
version = "1.0"
Further details are part of the `flake8 documentation