diff --git a/README.rst b/README.rst index 0b2eb39..d419b4b 100644 --- a/README.rst +++ b/README.rst @@ -156,7 +156,7 @@ flake8 codes ============== ==================================== Code Description ============== ==================================== -DALL000 Module lacks __all__. +DAL000 Module lacks __all__. ============== ==================================== diff --git a/doc-source/usage.rst b/doc-source/usage.rst index 2610a16..388e1fc 100644 --- a/doc-source/usage.rst +++ b/doc-source/usage.rst @@ -11,12 +11,12 @@ Flake8 codes .. flake8-codes:: flake8_dunder_all - DALL000 + DAL000 .. note:: In version ``0.3.1`` the entry point changed from ``DALL`` to ``DAL``, due to changes in flake8 itself. - However, the codes remain ``DALLXXX`` and should continue to work as normal. + Furthermore, in version ``0.4.0`` the codes also changed from ``DALLXXX`` to ``DALXXX`` and need to be updated. ``ensure-dunder-all`` script diff --git a/flake8_dunder_all/__init__.py b/flake8_dunder_all/__init__.py index 2f4fdb0..a865b00 100644 --- a/flake8_dunder_all/__init__.py +++ b/flake8_dunder_all/__init__.py @@ -46,12 +46,12 @@ __author__: str = "Dominic Davis-Foster" __copyright__: str = "2020 Dominic Davis-Foster" __license__: str = "MIT" -__version__: str = "0.3.1" +__version__: str = "0.4.0" __email__: str = "dominic@davis-foster.co.uk" -__all__ = ("Visitor", "Plugin", "check_and_add_all", "DALL000") +__all__ = ("Visitor", "Plugin", "check_and_add_all", "DAL000") -DALL000 = "DALL000 Module lacks __all__." +DAL000 = "DAL000 Module lacks __all__." class Visitor(ast.NodeVisitor): @@ -219,7 +219,7 @@ def run(self) -> Generator[Tuple[int, int, str, Type[Any]], None, None]: elif not visitor.members: return else: - yield 1, 0, DALL000, type(self) + yield 1, 0, DAL000, type(self) def check_and_add_all(filename: PathLike, quote_type: str = '"', use_tuple: bool = False) -> int: @@ -233,13 +233,13 @@ def check_and_add_all(filename: PathLike, quote_type: str = '"', use_tuple: bool :returns: * ``0`` if the file already contains a ``__all__`` declaration, - has no function or class definitions, or has a `` # noqa: DALL000 ` comment. + has no function or class definitions, or has a `` # noqa: DAL000 ` comment. * ``1`` If ``__all__`` is absent. * ``4`` if an error was encountered when parsing the file. .. versionchanged:: 0.2.0 - Now returns ``0`` and doesn't add ``__all__`` if the file contains a ``noqa: DALL000`` comment. + Now returns ``0`` and doesn't add ``__all__`` if the file contains a ``noqa: DAL000`` comment. .. versionchanged:: 0.3.0 Added the ``use_tuple`` argument. """ @@ -254,7 +254,7 @@ def check_and_add_all(filename: PathLike, quote_type: str = '"', use_tuple: bool if noqas["codes"]: # pylint: disable=loop-invariant-statement noqa_list: List[str] = noqas["codes"].rstrip().upper().split(',') - if "DALL000" in noqa_list: + if "DAL000" in noqa_list: return 0 # pylint: enable=loop-invariant-statement diff --git a/tests/test_flake8_dunder_all.py b/tests/test_flake8_dunder_all.py index b9deb7b..bc4ed59 100644 --- a/tests/test_flake8_dunder_all.py +++ b/tests/test_flake8_dunder_all.py @@ -38,20 +38,20 @@ pytest.param("import foo", set(), id="just an import"), pytest.param('"""a docstring"""', set(), id="just a docstring"), pytest.param(testing_source_a, set(), id="import and docstring"), - pytest.param(testing_source_b, {"1:0: DALL000 Module lacks __all__."}, id="function no __all__"), - pytest.param(testing_source_c, {"1:0: DALL000 Module lacks __all__."}, id="class no __all__"), + pytest.param(testing_source_b, {"1:0: DAL000 Module lacks __all__."}, id="function no __all__"), + pytest.param(testing_source_c, {"1:0: DAL000 Module lacks __all__."}, id="class no __all__"), pytest.param( - testing_source_d, {"1:0: DALL000 Module lacks __all__."}, + testing_source_d, {"1:0: DAL000 Module lacks __all__."}, id="function and class no __all__" ), pytest.param(testing_source_e, set(), id="function and class with __all__"), pytest.param(testing_source_f, set(), id="function and class with __all__ and extra variable"), pytest.param( - testing_source_g, {"1:0: DALL000 Module lacks __all__."}, id="async function no __all__" + testing_source_g, {"1:0: DAL000 Module lacks __all__."}, id="async function no __all__" ), pytest.param(testing_source_h, set(), id="from import"), - pytest.param(testing_source_i, {"1:0: DALL000 Module lacks __all__."}, id="lots of lines"), - pytest.param(testing_source_j, {"1:0: DALL000 Module lacks __all__."}, id="multiline import"), + pytest.param(testing_source_i, {"1:0: DAL000 Module lacks __all__."}, id="lots of lines"), + pytest.param(testing_source_j, {"1:0: DAL000 Module lacks __all__."}, id="multiline import"), ] ) def test_plugin(source: str, expects: Set[str]): diff --git a/tests/test_main.py b/tests/test_main.py index 39327a9..7ef1ebe 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -48,7 +48,7 @@ pytest.param(testing_source_h, [], 0, id="from import"), pytest.param(testing_source_i, [], 1, id="lots of lines"), pytest.param( - f" # noqa: DALL000 \n{testing_source_g}", + f" # noqa: DAL000 \n{testing_source_g}", [], 0, id="async function no __all__ and noqa", diff --git a/tests/test_subprocess.py b/tests/test_subprocess.py index 7daf197..c503590 100644 --- a/tests/test_subprocess.py +++ b/tests/test_subprocess.py @@ -25,7 +25,7 @@ def test_subprocess(tmp_pathplus: PathPlus, monkeypatch): assert result.returncode == 1 assert result.stderr == b'' assert result.stdout == b"""\ -code.py:1:1: DALL000 Module lacks __all__. +code.py:1:1: DAL000 Module lacks __all__. code.py:2:1: W191 indentation contains tabs code.py:2:1: W293 blank line contains whitespace code.py:4:1: W191 indentation contains tabs @@ -36,19 +36,19 @@ def test_subprocess(tmp_pathplus: PathPlus, monkeypatch): with in_directory(tmp_pathplus): result = subprocess.run( - [sys.executable, "-m", "flake8", "code.py", "--select", "DALL000"], + [sys.executable, "-m", "flake8", "code.py", "--select", "DAL000"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) assert result.returncode == 1 assert result.stderr == b'' - assert result.stdout == b"code.py:1:1: DALL000 Module lacks __all__.\n" + assert result.stdout == b"code.py:1:1: DAL000 Module lacks __all__.\n" (tmp_pathplus / "tox.ini").write_text(""" [flake8] -select = DALL000 +select = DAL000 """) with in_directory(tmp_pathplus): @@ -60,15 +60,15 @@ def test_subprocess(tmp_pathplus: PathPlus, monkeypatch): assert result.returncode == 1 assert result.stderr == b'' - assert result.stdout == b"code.py:1:1: DALL000 Module lacks __all__.\n" + assert result.stdout == b"code.py:1:1: DAL000 Module lacks __all__.\n" tox_ini = tmp_pathplus / "tox.ini" tox_ini.write_text(""" [flake8] -select = DALL000 +select = DAL000 per-file-ignores = - code.py: DALL000 + code.py: DAL000 """) with in_directory(tmp_pathplus): @@ -89,7 +89,7 @@ def test_subprocess_noqa(tmp_pathplus: PathPlus, monkeypatch): monkeypatch.delenv("COV_CORE_DATAFILE", raising=False) monkeypatch.setenv("PYTHONWARNINGS", "ignore") - (tmp_pathplus / "code.py").write_text("# noq" + "a: DALL000\n\n\t\ndef foo():\n\tpass\n\t") + (tmp_pathplus / "code.py").write_text("# noq" + "a: DAL000\n\n\t\ndef foo():\n\tpass\n\t") with in_directory(tmp_pathplus): result = subprocess.run( @@ -111,7 +111,7 @@ def test_subprocess_noqa(tmp_pathplus: PathPlus, monkeypatch): with in_directory(tmp_pathplus): result = subprocess.run( - [sys.executable, "-m", "flake8", "code.py", "--select", "DALL000"], + [sys.executable, "-m", "flake8", "code.py", "--select", "DAL000"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, ) @@ -123,7 +123,7 @@ def test_subprocess_noqa(tmp_pathplus: PathPlus, monkeypatch): (tmp_pathplus / "tox.ini").write_text(""" [flake8] -select = DALL000 +select = DAL000 """) with in_directory(tmp_pathplus): @@ -141,9 +141,9 @@ def test_subprocess_noqa(tmp_pathplus: PathPlus, monkeypatch): tox_ini.write_text(""" [flake8] -select = DALL000 +select = DAL000 per-file-ignores = - code.py: DALL000 + code.py: DAL000 """) with in_directory(tmp_pathplus): diff --git a/tox.ini b/tox.ini index 15041cb..f4e65c5 100644 --- a/tox.ini +++ b/tox.ini @@ -193,7 +193,7 @@ commands = [flake8] max-line-length = 120 -select = E111 E112 E113 E121 E122 E125 E127 E128 E129 E131 E133 E201 E202 E203 E211 E222 E223 E224 E225 E225 E226 E227 E228 E231 E241 E242 E251 E261 E262 E265 E271 E272 E303 E304 E306 E402 E502 E703 E711 E712 E713 E714 E721 W291 W292 W293 W391 W504 YTT101 YTT102 YTT103 YTT201 YTT202 YTT203 YTT204 YTT301 YTT302 YTT303 STRFTIME001 STRFTIME002 SXL001 PT001 PT002 PT003 PT006 PT007 PT008 PT009 PT010 PT011 PT012 PT013 PT014 PT015 PT016 PT017 PT018 PT019 PT020 PT021 RST201 RST202 RST203 RST204 RST205 RST206 RST207 RST208 RST210 RST211 RST212 RST213 RST214 RST215 RST216 RST217 RST218 RST219 RST299 RST301 RST302 RST303 RST304 RST305 RST306 RST399 RST401 RST499 RST900 RST901 RST902 RST903 Q001 Q002 Q003 A001 A002 TYP001 TYP002 TYP003 TYP004 TYP005 TYP006 ENC001 ENC002 ENC003 ENC004 ENC011 ENC012 ENC021 ENC022 ENC023 ENC024 ENC025 ENC026 Y001,Y002 Y003 Y004 Y005 Y006 Y007 Y008 Y009 Y010 Y011 Y012 Y013 Y014 Y015 Y090 Y091 NQA001 NQA002 NQA003 NQA004 NQA005 NQA102 NQA103 E301 E302 E305 D100 D101 D102 D103 D104 D106 D201 D204 D207 D208 D209 D210 D211 D212 D213 D214 D215 D300 D301 D400 D402 D403 D404 D415 D417 DALL000 SLOT000 SLOT001 SLOT002 +select = E111 E112 E113 E121 E122 E125 E127 E128 E129 E131 E133 E201 E202 E203 E211 E222 E223 E224 E225 E225 E226 E227 E228 E231 E241 E242 E251 E261 E262 E265 E271 E272 E303 E304 E306 E402 E502 E703 E711 E712 E713 E714 E721 W291 W292 W293 W391 W504 YTT101 YTT102 YTT103 YTT201 YTT202 YTT203 YTT204 YTT301 YTT302 YTT303 STRFTIME001 STRFTIME002 SXL001 PT001 PT002 PT003 PT006 PT007 PT008 PT009 PT010 PT011 PT012 PT013 PT014 PT015 PT016 PT017 PT018 PT019 PT020 PT021 RST201 RST202 RST203 RST204 RST205 RST206 RST207 RST208 RST210 RST211 RST212 RST213 RST214 RST215 RST216 RST217 RST218 RST219 RST299 RST301 RST302 RST303 RST304 RST305 RST306 RST399 RST401 RST499 RST900 RST901 RST902 RST903 Q001 Q002 Q003 A001 A002 TYP001 TYP002 TYP003 TYP004 TYP005 TYP006 ENC001 ENC002 ENC003 ENC004 ENC011 ENC012 ENC021 ENC022 ENC023 ENC024 ENC025 ENC026 Y001,Y002 Y003 Y004 Y005 Y006 Y007 Y008 Y009 Y010 Y011 Y012 Y013 Y014 Y015 Y090 Y091 NQA001 NQA002 NQA003 NQA004 NQA005 NQA102 NQA103 E301 E302 E305 D100 D101 D102 D103 D104 D106 D201 D204 D207 D208 D209 D210 D211 D212 D213 D214 D215 D300 D301 D400 D402 D403 D404 D415 D417 DAL000 SLOT000 SLOT001 SLOT002 extend-exclude = doc-source,old,build,dist,__pkginfo__.py,setup.py,venv rst-directives = TODO @@ -203,8 +203,8 @@ rst-directives = license-info rst-roles = choosealicense per-file-ignores = - tests/*: D100 D101 D102 D103 D104 D106 D201 D204 D207 D208 D209 D210 D211 D212 D213 D214 D215 D300 D301 D400 D402 D403 D404 D415 D417 DALL000 SLOT000 SLOT001 SLOT002 - */*.pyi: E301 E302 E305 D100 D101 D102 D103 D104 D106 D201 D204 D207 D208 D209 D210 D211 D212 D213 D214 D215 D300 D301 D400 D402 D403 D404 D415 D417 DALL000 SLOT000 SLOT001 SLOT002 + tests/*: D100 D101 D102 D103 D104 D106 D201 D204 D207 D208 D209 D210 D211 D212 D213 D214 D215 D300 D301 D400 D402 D403 D404 D415 D417 DAL000 SLOT000 SLOT001 SLOT002 + */*.pyi: E301 E302 E305 D100 D101 D102 D103 D104 D106 D201 D204 D207 D208 D209 D210 D211 D212 D213 D214 D215 D300 D301 D400 D402 D403 D404 D415 D417 DAL000 SLOT000 SLOT001 SLOT002 pytest-parametrize-names-type = csv inline-quotes = " multiline-quotes = """