Skip to content

Commit

Permalink
support darglint
Browse files Browse the repository at this point in the history
  • Loading branch information
orsinium committed May 23, 2022
1 parent f3cf4da commit fc94435
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion flake8_codes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
from ._plugins import Plugin, get_installed


__version__ = '0.2.1'
__version__ = '0.2.2'
__all__ = ['extract', 'Plugin', 'get_installed', '__version__']
18 changes: 18 additions & 0 deletions flake8_codes/_codes/_adhoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,24 @@ def extract_flake8_pie() -> Dict[str, str]:
return codes


@registry.add
def extract_darglint() -> Dict[str, str]:
# external
import darglint.errors

codes = dict()
for obj_name in dir(darglint.errors):
cls = getattr(darglint.errors, obj_name)
if not isinstance(cls, type):
continue
if not issubclass(cls, darglint.errors.DarglintError):
continue
if cls.error_code is None:
continue
codes[cls.error_code] = cls.description
return codes


@registry.add
def extract_flake8_docstrings() -> Dict[str, str]:
# external
Expand Down
1 change: 1 addition & 0 deletions flake8_codes/_plugins/_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
ALIASES = {
'aaa': 'flake8-aaa',
'flake-mutable': 'flake8-mutable',
'flake8-darglint': 'darglint',
'flake8-pandas-vet': 'pandas-vet',
'import-order': 'flake8-import-order',
'logging-format': 'flake8-logging-format',
Expand Down
7 changes: 6 additions & 1 deletion tests/test_codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@
import pytest

# project
from flake8_codes import extract
from flake8_codes import extract, get_installed
from flake8_codes._codes._default import extract_default
from flake8_codes._codes._registry import registry

# app
from ._constants import KNOWN_PLUGINS


def test_can_extract_all_installed():
for plugin in get_installed():
assert extract(plugin.name)


@pytest.mark.parametrize('plugin_name', KNOWN_PLUGINS)
def test_smoke_extract(plugin_name):
codes = extract(plugin_name)
Expand Down

0 comments on commit fc94435

Please sign in to comment.