Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix regex error with Flake8 5.0.4 #58

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ flake8 codes
============== ====================================
Code Description
============== ====================================
DALL000 Module lacks __all__.
DAL000 Module lacks __all__.
============== ====================================


Expand Down
4 changes: 2 additions & 2 deletions doc-source/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions flake8_dunder_all/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "[email protected]"

__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):
Expand Down Expand Up @@ -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:
Expand All @@ -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.
"""
Expand All @@ -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

Expand Down
12 changes: 6 additions & 6 deletions tests/test_flake8_dunder_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
24 changes: 12 additions & 12 deletions tests/test_subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand All @@ -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):
Expand All @@ -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(
Expand All @@ -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,
)
Expand All @@ -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):
Expand All @@ -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):
Expand Down
6 changes: 3 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 = """
Expand Down