-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
129 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
KNOWN_PLUGINS = ( | ||
'dlint', | ||
'flake8-2020', | ||
'flake8-alfred', | ||
'flake8-annotations-complexity', | ||
# 'flake8-bandit', | ||
'flake8-black', | ||
'flake8-broken-line', | ||
'flake8-builtins', | ||
'flake8-coding', | ||
'flake8-cognitive-complexity', | ||
'flake8-comprehensions', | ||
'flake8-debugger', | ||
'flake8-docstrings', | ||
'flake8-eradicate', | ||
'flake8-executable', | ||
'flake8-expression-complexity', | ||
'flake8-fixme', | ||
'flake8-functions', | ||
'flake8-logging-format', | ||
'flake8-mutable', | ||
'flake8-mypy', | ||
'flake8-pep3101', | ||
'flake8-pie', | ||
'flake8-print', | ||
'flake8-printf-formatting', | ||
'flake8-pyi', | ||
'flake8-quotes', | ||
'flake8-requirements', | ||
'flake8-rst-docstrings', | ||
'flake8-spellcheck', | ||
'flake8-sql', | ||
'flake8-strict', | ||
'flake8-string-format', | ||
'flake8-todo', | ||
'flake8-use-fstring', | ||
'flake8-variables-names', | ||
|
||
# framework-specific | ||
'flake8-django', | ||
'flake8-scrapy', | ||
'pandas-vet', | ||
|
||
# tests | ||
'flake8-aaa', | ||
'flake8-mock', | ||
'flake8-pytest', | ||
'flake8-pytest-style', | ||
|
||
# PyCQA | ||
'flake8-bugbear', | ||
'flake8-commas', | ||
'mccabe', | ||
'pep8-naming', | ||
|
||
# imports | ||
'flake8-future-import', | ||
'flake8-import-order', | ||
'flake8-isort', | ||
'flake8-absolute-import', | ||
'flake8-tidy-imports', | ||
|
||
# built-in in flake8 | ||
'pycodestyle', | ||
'pyflakes', | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# external | ||
import pytest | ||
|
||
# project | ||
from ._constants import KNOWN_PLUGINS | ||
from flake8_codes._codes import extract | ||
from flake8_codes._codes._default import extract_default | ||
from flake8_codes._codes._registry import registry | ||
|
||
|
||
@pytest.mark.parametrize('plugin_name', KNOWN_PLUGINS) | ||
def test_smoke_extract(plugin_name): | ||
codes = extract(plugin_name) | ||
assert codes | ||
|
||
for code, msg in codes.items(): | ||
assert type(code) is str, 'bad code type' | ||
assert type(msg) is str, 'bad message type' | ||
|
||
# that's not exactly true but all plugins follow this convention | ||
assert code[0].isalpha(), 'code must start from letter' | ||
assert code[0].isupper(), 'code must be uppercase' | ||
|
||
|
||
@pytest.mark.parametrize('plugin_name', KNOWN_PLUGINS) | ||
def test_no_custom_extractor_needed(plugin_name): | ||
extractor = registry.get(plugin_name) | ||
if extractor is None: | ||
return | ||
custom_codes = extractor() | ||
default_codes = extract_default(plugin_name) | ||
assert default_codes != custom_codes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# built-in | ||
from unittest.mock import patch | ||
|
||
# external | ||
import pytest | ||
from flake8.main.application import Application | ||
|
||
from flake8_codes._codes import extract | ||
from flake8_codes._plugins import get_installed | ||
from ._constants import KNOWN_PLUGINS | ||
|
||
|
||
@patch('sys.argv', ['flake8']) | ||
@pytest.mark.parametrize('plugin_name', KNOWN_PLUGINS) | ||
def test_smoke_prefixes(plugin_name): | ||
app = Application() | ||
plugins = {plugin.name: plugin for plugin in get_installed(app=app)} | ||
plugin = plugins[plugin_name] | ||
|
||
codes = extract(plugin_name) | ||
for code in codes: | ||
print(plugin_name, code, plugin.codes) | ||
assert code.startswith(tuple(plugin.codes)) |