From 28873963341cff94cdeb02f8569b09f47c1b68a7 Mon Sep 17 00:00:00 2001 From: gram Date: Thu, 14 Jan 2021 14:06:42 +0100 Subject: [PATCH] sort imports --- .gitignore | 1 + Taskfile.yml | 2 +- flake8_codes/__main__.py | 2 ++ flake8_codes/_cli.py | 5 ++++- flake8_codes/_codes/__init__.py | 2 ++ flake8_codes/_codes/_adhoc.py | 30 ++++++++++++++++++++++++++++-- flake8_codes/_codes/_extract.py | 3 ++- flake8_codes/_codes/_hardcoded.py | 3 +++ flake8_codes/_codes/_registry.py | 2 ++ flake8_codes/_codes/_renamed.py | 4 +++- flake8_codes/_plugins/__init__.py | 3 ++- pyproject.toml | 1 + tests/test_codes.py | 4 +++- tests/test_plugins.py | 3 +++ 14 files changed, 57 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 5a95477..e32bdf7 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ .pytest_cache/ __pycache__/ /venvs/ +/.task/ diff --git a/Taskfile.yml b/Taskfile.yml index 8877e4a..eb3a77f 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -86,6 +86,6 @@ tasks: - task: flit:install vars: ENV: "{{.ISORT_ENV}}" - EXTRA: plugins,dev + EXTRA: dev cmds: - "{{.ISORT_ENV}}/bin/isort ." diff --git a/flake8_codes/__main__.py b/flake8_codes/__main__.py index 3ddce2b..0c3a976 100644 --- a/flake8_codes/__main__.py +++ b/flake8_codes/__main__.py @@ -1,3 +1,5 @@ +# app from ._cli import entrypoint + entrypoint() diff --git a/flake8_codes/_cli.py b/flake8_codes/_cli.py index bfa153c..11f812c 100644 --- a/flake8_codes/_cli.py +++ b/flake8_codes/_cli.py @@ -1,11 +1,14 @@ +# built-in import sys from argparse import ArgumentParser from typing import Iterator, List, NamedTuple, NoReturn, TextIO +# external from flake8.main.application import Application +# app from ._codes import extract -from ._plugins import get_installed, Plugin +from ._plugins import Plugin, get_installed TEMPLATE = '{c.plugin.name:20} | {c.code:8} | {c.message}' diff --git a/flake8_codes/_codes/__init__.py b/flake8_codes/_codes/__init__.py index 77493f3..57ec2bf 100644 --- a/flake8_codes/_codes/__init__.py +++ b/flake8_codes/_codes/__init__.py @@ -1,3 +1,5 @@ +# app from ._extract import extract + __all__ = ['extract'] diff --git a/flake8_codes/_codes/_adhoc.py b/flake8_codes/_codes/_adhoc.py index 86ef3c4..4493616 100644 --- a/flake8_codes/_codes/_adhoc.py +++ b/flake8_codes/_codes/_adhoc.py @@ -5,12 +5,14 @@ from pathlib import Path from typing import Dict -from ._registry import registry +# app from ._default import extract_default +from ._registry import registry @registry.add def extract_flake8_commas() -> Dict[str, str]: + # external from flake8_commas._base import ERRORS return dict(ERRORS.values()) @@ -18,12 +20,14 @@ def extract_flake8_commas() -> Dict[str, str]: @registry.add def extract_flake8_debugger() -> Dict[str, str]: + # external from flake8_debugger import DEBUGGER_ERROR_CODE return {DEBUGGER_ERROR_CODE: 'trace found'} @registry.add def extract_flake8_mutable() -> Dict[str, str]: + # external from mutable_defaults import MutableDefaultChecker return {MutableDefaultChecker._code: MutableDefaultChecker._error_tmpl} @@ -31,6 +35,7 @@ def extract_flake8_mutable() -> Dict[str, str]: @registry.add def extract_flake8_fixme() -> Dict[str, str]: + # external from flake8_fixme import WORD_CODES return {code: 'fixme found ({})'.format(word) for word, code in WORD_CODES.items()} @@ -38,6 +43,7 @@ def extract_flake8_fixme() -> Dict[str, str]: @registry.add def extract_pep8_naming() -> Dict[str, str]: + # external import pep8ext_naming codes = dict() @@ -53,6 +59,7 @@ def extract_pep8_naming() -> Dict[str, str]: @registry.add def extract_flake8_pyi() -> Dict[str, str]: + # external import pyi codes = dict() for name, value in vars(pyi).items(): @@ -63,6 +70,7 @@ def extract_flake8_pyi() -> Dict[str, str]: @registry.add def extract_flake8_pytest_style() -> Dict[str, str]: + # external from flake8_pytest_style import errors codes = dict() for error in vars(errors).values(): @@ -78,6 +86,7 @@ def extract_flake8_pytest_style() -> Dict[str, str]: @registry.add def extract_flake8_annotations_complexity() -> Dict[str, str]: + # external from flake8_annotations_complexity.checker import AnnotationsComplexityChecker with suppress(ImportError): @@ -91,6 +100,7 @@ def extract_flake8_annotations_complexity() -> Dict[str, str]: @registry.add def extract_flake8_future_import() -> Dict[str, str]: + # external from flake8_future_import import ALL_FEATURES codes = dict() tmpl = 'FI{}' @@ -105,6 +115,7 @@ def extract_flake8_future_import() -> Dict[str, str]: @registry.add def extract_flake8_string_format() -> Dict[str, str]: + # external from flake8_string_format import StringFormatChecker return {'P{}'.format(c): m for c, m in StringFormatChecker.ERRORS.items()} @@ -112,6 +123,7 @@ def extract_flake8_string_format() -> Dict[str, str]: @registry.add def extract_flake8_bandit() -> Dict[str, str]: + # external from bandit.core.extension_loader import MANAGER codes = dict() @@ -127,10 +139,13 @@ def extract_flake8_bandit() -> Dict[str, str]: @registry.add def extract_pylint() -> Dict[str, str]: + # external import pylint.checkers try: + # external from pylint.lint import MSGS except ImportError: + # external from pylint.lint.pylinter import MSGS codes = dict() @@ -155,6 +170,7 @@ def extract_pylint() -> Dict[str, str]: @registry.add def extract_pyflakes() -> Dict[str, str]: + # external from flake8.plugins.pyflakes import FLAKE8_PYFLAKES_CODES from pyflakes import messages @@ -166,6 +182,7 @@ def extract_pyflakes() -> Dict[str, str]: @registry.add def extract_flake8_rst_docstrings() -> Dict[str, str]: + # external from flake8_rst_docstrings import code_mappings_by_level codes = dict() @@ -178,6 +195,7 @@ def extract_flake8_rst_docstrings() -> Dict[str, str]: @registry.add def extract_flake8_django() -> Dict[str, str]: + # external import flake8_django.checkers codes = dict() @@ -195,6 +213,7 @@ def extract_flake8_django() -> Dict[str, str]: @registry.add def extract_flake8_scrapy() -> Dict[str, str]: + # external from flake8_scrapy import ScrapyStyleIssueFinder codes = dict() @@ -206,6 +225,7 @@ def extract_flake8_scrapy() -> Dict[str, str]: @registry.add def extract_flake8_executable() -> Dict[str, str]: + # external import flake8_executable path = Path(flake8_executable.__file__) @@ -218,6 +238,7 @@ def extract_flake8_executable() -> Dict[str, str]: @registry.add def extract_flake8_strict() -> Dict[str, str]: + # external from flake8_strict import ErrorCode codes = dict() @@ -228,6 +249,7 @@ def extract_flake8_strict() -> Dict[str, str]: @registry.add def extract_flake8_docstrings() -> Dict[str, str]: + # external from pydocstyle.violations import ErrorRegistry codes = dict() @@ -239,6 +261,7 @@ def extract_flake8_docstrings() -> Dict[str, str]: @registry.add def extract_dlint() -> Dict[str, str]: + # external from dlint.linters import ALL codes = dict() @@ -250,7 +273,8 @@ def extract_dlint() -> Dict[str, str]: @registry.add def extract_flake8_mock() -> Dict[str, str]: - from flake8_mock import MOCK_ERROR_CODE, ERROR_MESSAGE + # external + from flake8_mock import ERROR_MESSAGE, MOCK_ERROR_CODE message = ERROR_MESSAGE.split(' ', maxsplit=1)[1] return {MOCK_ERROR_CODE: message} @@ -258,6 +282,7 @@ def extract_flake8_mock() -> Dict[str, str]: @registry.add def extract_flake8_pytest() -> Dict[str, str]: + # external from flake8_pytest import PYTEST_ERROR_CODE, PYTEST_ERROR_MESSAGE return {PYTEST_ERROR_CODE: PYTEST_ERROR_MESSAGE} @@ -265,6 +290,7 @@ def extract_flake8_pytest() -> Dict[str, str]: @registry.add def extract_wemake_python_styleguide() -> Dict[str, str]: + # external from wemake_python_styleguide import violations codes = dict() diff --git a/flake8_codes/_codes/_extract.py b/flake8_codes/_codes/_extract.py index 1c04be7..642d333 100644 --- a/flake8_codes/_codes/_extract.py +++ b/flake8_codes/_codes/_extract.py @@ -1,7 +1,8 @@ # built-in -from typing import Dict from importlib import import_module +from typing import Dict +# app from ._default import extract_default from ._registry import registry diff --git a/flake8_codes/_codes/_hardcoded.py b/flake8_codes/_codes/_hardcoded.py index 1242ada..e8db5b5 100644 --- a/flake8_codes/_codes/_hardcoded.py +++ b/flake8_codes/_codes/_hardcoded.py @@ -1,5 +1,7 @@ # built-in from typing import Dict + +# app from ._registry import registry @@ -24,6 +26,7 @@ def extract_flake8_import_order() -> Dict[str, str]: @registry.add def extract_flake8_black() -> Dict[str, str]: + # external from flake8_black import black_prefix return { diff --git a/flake8_codes/_codes/_registry.py b/flake8_codes/_codes/_registry.py index 3aceee5..c5e5b2f 100644 --- a/flake8_codes/_codes/_registry.py +++ b/flake8_codes/_codes/_registry.py @@ -1,7 +1,9 @@ +# built-in from typing import Callable, Dict, Optional + ExtractorType = Callable[[], Dict[str, str]] diff --git a/flake8_codes/_codes/_renamed.py b/flake8_codes/_codes/_renamed.py index 38ad518..f62380d 100644 --- a/flake8_codes/_codes/_renamed.py +++ b/flake8_codes/_codes/_renamed.py @@ -1,6 +1,8 @@ +# built-in from typing import Dict -from ._default import extract_default +# app +from ._default import extract_default from ._registry import registry diff --git a/flake8_codes/_plugins/__init__.py b/flake8_codes/_plugins/__init__.py index 83f53e9..8e6fe87 100644 --- a/flake8_codes/_plugins/__init__.py +++ b/flake8_codes/_plugins/__init__.py @@ -1,4 +1,5 @@ -from ._discover import get_installed, Plugin +# app +from ._discover import Plugin, get_installed __all__ = ['get_installed', 'Plugin'] diff --git a/pyproject.toml b/pyproject.toml index 3e07180..246824e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,6 +13,7 @@ line_length = 90 combine_as_imports = true balanced_wrapping = true lines_after_imports = 2 +skip = "venvs/" not_skip = "__init__.py" multi_line_output = 5 include_trailing_comma = true diff --git a/tests/test_codes.py b/tests/test_codes.py index 27eeb7b..1c689b8 100644 --- a/tests/test_codes.py +++ b/tests/test_codes.py @@ -2,11 +2,13 @@ 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 +# app +from ._constants import KNOWN_PLUGINS + @pytest.mark.parametrize('plugin_name', KNOWN_PLUGINS) def test_smoke_extract(plugin_name): diff --git a/tests/test_plugins.py b/tests/test_plugins.py index fc56793..9a78a8f 100644 --- a/tests/test_plugins.py +++ b/tests/test_plugins.py @@ -5,8 +5,11 @@ import pytest from flake8.main.application import Application +# project from flake8_codes._codes import extract from flake8_codes._plugins import get_installed + +# app from ._constants import KNOWN_PLUGINS