mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-04 20:26:53 +00:00
Remove unused and broken flake8.listen plugin type
This commit is contained in:
parent
6ad56f73da
commit
be88d26396
11 changed files with 19 additions and 525 deletions
|
|
@ -4,15 +4,13 @@ Plugin Handling
|
|||
Plugin Management
|
||||
-----------------
|
||||
|
||||
|Flake8| 3.0 added support for two other plugins besides those which define
|
||||
|Flake8| 3.0 added support for other plugins besides those which define
|
||||
new checks. It now supports:
|
||||
|
||||
- extra checks
|
||||
|
||||
- alternative report formatters
|
||||
|
||||
- listeners to auto-correct violations of checks
|
||||
|
||||
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
|
||||
|
|
@ -38,12 +36,10 @@ the |PTM| will subclass it and specify the ``namespace``, e.g.,
|
|||
|
||||
This provides a few extra methods via the |PluginManager|'s ``map`` method.
|
||||
|
||||
Finally, we create three classes of plugins:
|
||||
Finally, we create two classes of plugins:
|
||||
|
||||
- :class:`~flake8.plugins.manager.Checkers`
|
||||
|
||||
- :class:`~flake8.plugins.manager.Listeners`
|
||||
|
||||
- :class:`~flake8.plugins.manager.ReportFormatters`
|
||||
|
||||
These are used to interact with each of the types of plugins individually.
|
||||
|
|
@ -53,29 +49,6 @@ These are used to interact with each of the types of plugins individually.
|
|||
Our inspiration for our plugin handling comes from the author's extensive
|
||||
experience with ``stevedore``.
|
||||
|
||||
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. 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.
|
||||
If ``E112`` is returned, then only ``E1`` (and any other listeners) would be
|
||||
notified.
|
||||
|
||||
To implement this goal, we needed an object to store listeners in that would
|
||||
allow for efficient look up - a Trie (or Prefix Tree). Given that none of the
|
||||
existing packages on PyPI allowed for storing data on each node of the trie,
|
||||
it was left up to write our own as :class:`~flake8.plugins._trie.Trie`. On
|
||||
top of that we layer our :class:`~flake8.plugins.notifier.Notifier` class.
|
||||
|
||||
Now when |Flake8| receives an error or warning, we can easily call the
|
||||
:meth:`~flake8.plugins.notifier.Notifier.notify` method and let plugins act on
|
||||
that knowledge.
|
||||
|
||||
Default Plugins
|
||||
---------------
|
||||
|
||||
|
|
@ -103,7 +76,7 @@ API Documentation
|
|||
|
||||
.. autoclass:: flake8.plugins.manager.PluginManager
|
||||
:members:
|
||||
:special-members: __init__, __contains__, __getitem__
|
||||
:special-members: __init__
|
||||
|
||||
.. autoclass:: flake8.plugins.manager.Plugin
|
||||
:members:
|
||||
|
|
@ -115,15 +88,8 @@ API Documentation
|
|||
.. autoclass:: flake8.plugins.manager.Checkers
|
||||
:members:
|
||||
|
||||
.. autoclass:: flake8.plugins.manager.Listeners
|
||||
:members: build_notifier
|
||||
|
||||
.. autoclass:: flake8.plugins.manager.ReportFormatters
|
||||
|
||||
.. autoclass:: flake8.plugins.notifier.Notifier
|
||||
|
||||
.. autoclass:: flake8.plugins._trie.Trie
|
||||
|
||||
.. |PluginManager| replace:: :class:`~flake8.plugins.manager.PluginManager`
|
||||
.. |Plugin| replace:: :class:`~flake8.plugins.manager.Plugin`
|
||||
.. |PTM| replace:: :class:`~flake8.plugins.manager.PluginTypeManager`
|
||||
|
|
|
|||
|
|
@ -86,13 +86,10 @@ grouping of entry-points that flake8 should look in.
|
|||
|
||||
- ``flake8.extension``
|
||||
|
||||
- ``flake8.listen``
|
||||
|
||||
- ``flake8.report``
|
||||
|
||||
If your plugin is one that adds checks to |Flake8|, you will use
|
||||
``flake8.extension``. If your plugin automatically fixes errors in code, you
|
||||
will use ``flake8.listen``. Finally, if your plugin performs extra report
|
||||
``flake8.extension``. If your plugin performs extra report
|
||||
handling (formatting, filtering, etc.) it will use ``flake8.report``.
|
||||
|
||||
If our ``ExamplePlugin`` is something that adds checks, our code would look
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue