From 1aa8ef8f9d8fd8f8f98c6b5165690af15fec6566 Mon Sep 17 00:00:00 2001 From: jakkdl Date: Mon, 26 Feb 2024 15:19:32 +0100 Subject: [PATCH 1/3] rename files, update references to them --- .pre-commit-hooks.yaml | 6 +++--- CONTRIBUTING.md | 6 +++--- {flake8_trio => flake8_async}/__init__.py | 8 ++++---- {flake8_trio => flake8_async}/__main__.py | 0 {flake8_trio => flake8_async}/base.py | 0 {flake8_trio => flake8_async}/runner.py | 8 ++++---- {flake8_trio => flake8_async}/visitors/__init__.py | 2 +- .../visitors/flake8asyncvisitor.py | 0 {flake8_trio => flake8_async}/visitors/helpers.py | 2 +- {flake8_trio => flake8_async}/visitors/visitor100.py | 2 +- {flake8_trio => flake8_async}/visitors/visitor101.py | 2 +- {flake8_trio => flake8_async}/visitors/visitor102.py | 2 +- .../visitors/visitor103_104.py | 2 +- {flake8_trio => flake8_async}/visitors/visitor105.py | 2 +- {flake8_trio => flake8_async}/visitors/visitor111.py | 2 +- {flake8_trio => flake8_async}/visitors/visitor118.py | 2 +- {flake8_trio => flake8_async}/visitors/visitor2xx.py | 2 +- {flake8_trio => flake8_async}/visitors/visitor91x.py | 2 +- .../visitors/visitor_utility.py | 2 +- {flake8_trio => flake8_async}/visitors/visitors.py | 2 +- pyproject.toml | 6 +++--- setup.py | 8 ++++---- tests/test_all_visitors_imported.py | 6 +++--- tests/test_changelog_and_version.py | 4 ++-- tests/test_config_and_args.py | 12 ++++++------ tests/test_decorator.py | 6 +++--- tests/test_exception_on_invalid_code.py | 2 +- tests/{test_flake8_trio.py => test_flake8_async.py} | 8 ++++---- tests/test_formatting.py | 2 +- tests/test_messages_documented.py | 4 ++-- tox.ini | 6 +++--- 31 files changed, 59 insertions(+), 59 deletions(-) rename {flake8_trio => flake8_async}/__init__.py (98%) rename {flake8_trio => flake8_async}/__main__.py (100%) rename {flake8_trio => flake8_async}/base.py (100%) rename {flake8_trio => flake8_async}/runner.py (95%) rename {flake8_trio => flake8_async}/visitors/__init__.py (93%) rename flake8_trio/visitors/flake8triovisitor.py => flake8_async/visitors/flake8asyncvisitor.py (100%) rename {flake8_trio => flake8_async}/visitors/helpers.py (99%) rename {flake8_trio => flake8_async}/visitors/visitor100.py (98%) rename {flake8_trio => flake8_async}/visitors/visitor101.py (97%) rename {flake8_trio => flake8_async}/visitors/visitor102.py (98%) rename {flake8_trio => flake8_async}/visitors/visitor103_104.py (99%) rename {flake8_trio => flake8_async}/visitors/visitor105.py (97%) rename {flake8_trio => flake8_async}/visitors/visitor111.py (98%) rename {flake8_trio => flake8_async}/visitors/visitor118.py (96%) rename {flake8_trio => flake8_async}/visitors/visitor2xx.py (99%) rename {flake8_trio => flake8_async}/visitors/visitor91x.py (99%) rename {flake8_trio => flake8_async}/visitors/visitor_utility.py (98%) rename {flake8_trio => flake8_async}/visitors/visitors.py (99%) rename tests/{test_flake8_trio.py => test_flake8_async.py} (99%) diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 53d6bad..935a318 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -1,6 +1,6 @@ --- - - id: flake8-trio - name: flake8-trio - entry: flake8-trio + - id: flake8-async + name: flake8-async + entry: flake8-async language: python types: [python] diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 889155e..8d32ce0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -25,7 +25,7 @@ tox -p --develop ``` ## Meta-tests -To check that all codes are tested and documented there's a test that error codes mentioned in `README.md`, `CHANGELOG.md` (matching `TRIO\d\d\d`), the keys in `flake8_trio.Error_codes` and codes parsed from filenames and files in `tests/eval_files/`, are all equal. +To check that all codes are tested and documented there's a test that error codes mentioned in `README.md`, `CHANGELOG.md` (matching `TRIO\d\d\d`), the keys in `flake8_async.Error_codes` and codes parsed from filenames and files in `tests/eval_files/`, are all equal. ## Test generator Tests are automatically generated for files in the `tests/eval_files/` directory, with the code that it's testing interpreted from the file name. The file extension is split off, if there's a match for for `_py\d*` it strips that off and uses it to determine if there's a minimum python version for which the test should only run. @@ -36,7 +36,7 @@ During tests the result of running the checker on the eval file with autofix ena Files without this marker will be checked that they *don't* modify the file content. ### `error:` -Lines containing `error:` are parsed as expecting an error of the code matching the file name, with everything on the line after the colon `eval`'d and passed as arguments to `flake8_trio.Error_codes[].str_format`. The `globals` argument to `eval` contains a `lineno` variable assigned the current line number, and the `flake8_trio.Statement` namedtuple. The first element after `error:` *must* be an integer containing the column where the error on that line originates. +Lines containing `error:` are parsed as expecting an error of the code matching the file name, with everything on the line after the colon `eval`'d and passed as arguments to `flake8_async.Error_codes[].str_format`. The `globals` argument to `eval` contains a `lineno` variable assigned the current line number, and the `flake8_async.Statement` namedtuple. The first element after `error:` *must* be an integer containing the column where the error on that line originates. #### `TRIOxxx:` You can instead of `error` specify the error code. @@ -73,6 +73,6 @@ or rote memorization of an arbitrary convention. We want to ship bigfixes or new features as soon as they're ready, so our release process is automated: -1. Increment `__version__` in `src/flake8_trio.py` +1. Increment `__version__` in `src/flake8_async.py` 2. Ensure there's a corresponding entry in `CHANGELOG.md` with same version 3. Merge to master, and CI will do the rest! diff --git a/flake8_trio/__init__.py b/flake8_async/__init__.py similarity index 98% rename from flake8_trio/__init__.py rename to flake8_async/__init__.py index d3c301c..9bb1378 100644 --- a/flake8_trio/__init__.py +++ b/flake8_async/__init__.py @@ -24,7 +24,7 @@ import libcst as cst from .base import Options, error_has_subidentifier -from .runner import Flake8TrioRunner, Flake8TrioRunner_cst +from .runner import Flake8AsyncRunner, Flake8AsyncRunner_cst from .visitors import ERROR_CLASSES, ERROR_CLASSES_CST, default_disabled_error_codes if TYPE_CHECKING: @@ -75,7 +75,7 @@ def cst_parse_module_native(source: str) -> cst.Module: def main() -> int: - parser = ArgumentParser(prog="flake8-trio") + parser = ArgumentParser(prog="flake8-async") Plugin.add_options(parser) args = parser.parse_args() Plugin.parse_options(args) @@ -156,11 +156,11 @@ def run(self) -> Iterable[Error]: if not self.standalone: self.options.disable_noqa = True - cst_runner = Flake8TrioRunner_cst(self.options, self.module) + cst_runner = Flake8AsyncRunner_cst(self.options, self.module) # any noqa'd errors are suppressed upon being generated yield from cst_runner.run() - problems_ast = Flake8TrioRunner.run(self._tree, self.options) + problems_ast = Flake8AsyncRunner.run(self._tree, self.options) if self.options.disable_noqa: yield from problems_ast return diff --git a/flake8_trio/__main__.py b/flake8_async/__main__.py similarity index 100% rename from flake8_trio/__main__.py rename to flake8_async/__main__.py diff --git a/flake8_trio/base.py b/flake8_async/base.py similarity index 100% rename from flake8_trio/base.py rename to flake8_async/base.py diff --git a/flake8_trio/runner.py b/flake8_async/runner.py similarity index 95% rename from flake8_trio/runner.py rename to flake8_async/runner.py index a1b843d..3d9a136 100644 --- a/flake8_trio/runner.py +++ b/flake8_async/runner.py @@ -1,4 +1,4 @@ -"""Contains Flake8TrioRunner. +"""Contains Flake8AsyncRunner. The runner is what's run by the Plugin, and handles traversing the AST and letting all registered ERROR_CLASSES do their visit'ing on them. @@ -26,7 +26,7 @@ from libcst import Module from .base import Error, Options - from .visitors.flake8triovisitor import Flake8AsyncVisitor, Flake8AsyncVisitor_cst + from .visitors.flake8asyncvisitor import Flake8AsyncVisitor, Flake8AsyncVisitor_cst @dataclass @@ -53,7 +53,7 @@ def selected(self, error_codes: Mapping[str, str]) -> bool: return bool(set(error_codes) & enabled_or_autofix) -class Flake8TrioRunner(ast.NodeVisitor, __CommonRunner): +class Flake8AsyncRunner(ast.NodeVisitor, __CommonRunner): def __init__(self, options: Options): super().__init__(options) # utility visitors that need to run before the error-checking visitors @@ -110,7 +110,7 @@ def visit(self, node: ast.AST): subclass.set_state(subclass.outer.pop(node, {})) -class Flake8TrioRunner_cst(__CommonRunner): +class Flake8AsyncRunner_cst(__CommonRunner): def __init__(self, options: Options, module: Module): super().__init__(options) self.options = options diff --git a/flake8_trio/visitors/__init__.py b/flake8_async/visitors/__init__.py similarity index 93% rename from flake8_trio/visitors/__init__.py rename to flake8_async/visitors/__init__.py index ab392ba..d4f17c4 100644 --- a/flake8_trio/visitors/__init__.py +++ b/flake8_async/visitors/__init__.py @@ -10,7 +10,7 @@ from typing import TYPE_CHECKING if TYPE_CHECKING: - from .flake8triovisitor import Flake8AsyncVisitor, Flake8AsyncVisitor_cst + from .flake8asyncvisitor import Flake8AsyncVisitor, Flake8AsyncVisitor_cst __all__ = [ "ERROR_CLASSES", diff --git a/flake8_trio/visitors/flake8triovisitor.py b/flake8_async/visitors/flake8asyncvisitor.py similarity index 100% rename from flake8_trio/visitors/flake8triovisitor.py rename to flake8_async/visitors/flake8asyncvisitor.py diff --git a/flake8_trio/visitors/helpers.py b/flake8_async/visitors/helpers.py similarity index 99% rename from flake8_trio/visitors/helpers.py rename to flake8_async/visitors/helpers.py index 2eac570..40b5451 100644 --- a/flake8_trio/visitors/helpers.py +++ b/flake8_async/visitors/helpers.py @@ -25,7 +25,7 @@ if TYPE_CHECKING: from collections.abc import Iterable, Iterator, Sequence - from .flake8triovisitor import ( + from .flake8asyncvisitor import ( Flake8AsyncVisitor, Flake8AsyncVisitor_cst, HasLineCol, diff --git a/flake8_trio/visitors/visitor100.py b/flake8_async/visitors/visitor100.py similarity index 98% rename from flake8_trio/visitors/visitor100.py rename to flake8_async/visitors/visitor100.py index 7284372..454bde1 100644 --- a/flake8_trio/visitors/visitor100.py +++ b/flake8_async/visitors/visitor100.py @@ -13,7 +13,7 @@ import libcst as cst import libcst.matchers as m -from .flake8triovisitor import Flake8AsyncVisitor_cst +from .flake8asyncvisitor import Flake8AsyncVisitor_cst from .helpers import ( AttributeCall, error_class_cst, diff --git a/flake8_trio/visitors/visitor101.py b/flake8_async/visitors/visitor101.py similarity index 97% rename from flake8_trio/visitors/visitor101.py rename to flake8_async/visitors/visitor101.py index 29cbbf7..0ad77d8 100644 --- a/flake8_trio/visitors/visitor101.py +++ b/flake8_async/visitors/visitor101.py @@ -8,7 +8,7 @@ from typing import TYPE_CHECKING, Any -from .flake8triovisitor import Flake8AsyncVisitor_cst +from .flake8asyncvisitor import Flake8AsyncVisitor_cst from .helpers import ( cancel_scope_names, error_class_cst, diff --git a/flake8_trio/visitors/visitor102.py b/flake8_async/visitors/visitor102.py similarity index 98% rename from flake8_trio/visitors/visitor102.py rename to flake8_async/visitors/visitor102.py index 5afc63e..cb591da 100644 --- a/flake8_trio/visitors/visitor102.py +++ b/flake8_async/visitors/visitor102.py @@ -9,7 +9,7 @@ from typing import TYPE_CHECKING, Any from ..base import Statement -from .flake8triovisitor import Flake8AsyncVisitor +from .flake8asyncvisitor import Flake8AsyncVisitor from .helpers import cancel_scope_names, critical_except, error_class, get_matching_call if TYPE_CHECKING: diff --git a/flake8_trio/visitors/visitor103_104.py b/flake8_async/visitors/visitor103_104.py similarity index 99% rename from flake8_trio/visitors/visitor103_104.py rename to flake8_async/visitors/visitor103_104.py index 8ce2992..119d66b 100644 --- a/flake8_trio/visitors/visitor103_104.py +++ b/flake8_async/visitors/visitor103_104.py @@ -11,7 +11,7 @@ import ast from typing import TYPE_CHECKING, Any -from .flake8triovisitor import Flake8AsyncVisitor +from .flake8asyncvisitor import Flake8AsyncVisitor from .helpers import critical_except, error_class, iter_guaranteed_once if TYPE_CHECKING: diff --git a/flake8_trio/visitors/visitor105.py b/flake8_async/visitors/visitor105.py similarity index 97% rename from flake8_trio/visitors/visitor105.py rename to flake8_async/visitors/visitor105.py index 594ad89..c7e0ddf 100644 --- a/flake8_trio/visitors/visitor105.py +++ b/flake8_async/visitors/visitor105.py @@ -5,7 +5,7 @@ import ast from typing import TYPE_CHECKING, Any -from .flake8triovisitor import Flake8AsyncVisitor +from .flake8asyncvisitor import Flake8AsyncVisitor from .helpers import error_class if TYPE_CHECKING: diff --git a/flake8_trio/visitors/visitor111.py b/flake8_async/visitors/visitor111.py similarity index 98% rename from flake8_trio/visitors/visitor111.py rename to flake8_async/visitors/visitor111.py index 397d0a2..3134cf8 100644 --- a/flake8_trio/visitors/visitor111.py +++ b/flake8_async/visitors/visitor111.py @@ -5,7 +5,7 @@ import ast from typing import TYPE_CHECKING, Any, NamedTuple -from .flake8triovisitor import Flake8AsyncVisitor +from .flake8asyncvisitor import Flake8AsyncVisitor from .helpers import error_class, get_matching_call if TYPE_CHECKING: diff --git a/flake8_trio/visitors/visitor118.py b/flake8_async/visitors/visitor118.py similarity index 96% rename from flake8_trio/visitors/visitor118.py rename to flake8_async/visitors/visitor118.py index b8a1d04..4066f50 100644 --- a/flake8_trio/visitors/visitor118.py +++ b/flake8_async/visitors/visitor118.py @@ -10,7 +10,7 @@ import re from typing import TYPE_CHECKING -from .flake8triovisitor import Flake8AsyncVisitor +from .flake8asyncvisitor import Flake8AsyncVisitor from .helpers import error_class if TYPE_CHECKING: diff --git a/flake8_trio/visitors/visitor2xx.py b/flake8_async/visitors/visitor2xx.py similarity index 99% rename from flake8_trio/visitors/visitor2xx.py rename to flake8_async/visitors/visitor2xx.py index a7349f7..86a48ec 100644 --- a/flake8_trio/visitors/visitor2xx.py +++ b/flake8_async/visitors/visitor2xx.py @@ -14,7 +14,7 @@ import re from typing import TYPE_CHECKING, Any -from .flake8triovisitor import Flake8AsyncVisitor +from .flake8asyncvisitor import Flake8AsyncVisitor from .helpers import error_class, fnmatch_qualified_name, get_matching_call if TYPE_CHECKING: diff --git a/flake8_trio/visitors/visitor91x.py b/flake8_async/visitors/visitor91x.py similarity index 99% rename from flake8_trio/visitors/visitor91x.py rename to flake8_async/visitors/visitor91x.py index c1af6d9..bbc4739 100644 --- a/flake8_trio/visitors/visitor91x.py +++ b/flake8_async/visitors/visitor91x.py @@ -16,7 +16,7 @@ from libcst.metadata import PositionProvider from ..base import Statement -from .flake8triovisitor import Flake8AsyncVisitor_cst +from .flake8asyncvisitor import Flake8AsyncVisitor_cst from .helpers import ( disabled_by_default, error_class_cst, diff --git a/flake8_trio/visitors/visitor_utility.py b/flake8_async/visitors/visitor_utility.py similarity index 98% rename from flake8_trio/visitors/visitor_utility.py rename to flake8_async/visitors/visitor_utility.py index 81bdcf0..58784a9 100644 --- a/flake8_trio/visitors/visitor_utility.py +++ b/flake8_async/visitors/visitor_utility.py @@ -10,7 +10,7 @@ import libcst.matchers as m from libcst.metadata import PositionProvider -from .flake8triovisitor import Flake8AsyncVisitor, Flake8AsyncVisitor_cst +from .flake8asyncvisitor import Flake8AsyncVisitor, Flake8AsyncVisitor_cst from .helpers import utility_visitor, utility_visitor_cst if TYPE_CHECKING: diff --git a/flake8_trio/visitors/visitors.py b/flake8_async/visitors/visitors.py similarity index 99% rename from flake8_trio/visitors/visitors.py rename to flake8_async/visitors/visitors.py index 40d52a3..9293ab4 100644 --- a/flake8_trio/visitors/visitors.py +++ b/flake8_async/visitors/visitors.py @@ -5,7 +5,7 @@ import ast from typing import TYPE_CHECKING, Any, cast -from .flake8triovisitor import Flake8AsyncVisitor +from .flake8asyncvisitor import Flake8AsyncVisitor from .helpers import disabled_by_default, error_class, get_matching_call, has_decorator if TYPE_CHECKING: diff --git a/pyproject.toml b/pyproject.toml index d85b63a..1f8562c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,7 +38,7 @@ reportUninitializedInstanceVariable = true # can't enable until https://github.com/python/mypy/issues/12358 reportUnnecessaryTypeIgnoreComment = false reportUnusedCallResult = false -strict = ["*.py", "tests/*.py", "flake8_trio/**/*.py"] +strict = ["*.py", "tests/*.py", "flake8_async/**/*.py"] [tool.ruff] extend-exclude = [ @@ -104,10 +104,10 @@ select = ["ALL"] # docstrings, and arguments we can't modify "*.pyi" = ["D", 'FBT001', 'PLR0913', "PIE790", "PYI048"] # imports -"flake8_trio/visitors/__init__.py" = [ +"flake8_async/visitors/__init__.py" = [ "F401", "E402" ] # visitor_utility contains comments specifying how it parses noqa comments, which get # parsed as noqa comments -"flake8_trio/visitors/visitor_utility.py" = ["RUF100", "PGH004"] +"flake8_async/visitors/visitor_utility.py" = ["RUF100", "PGH004"] diff --git a/setup.py b/setup.py index 6e1555f..a1f4cdb 100755 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ def local_file(name: str) -> Path: return Path(__file__).parent / name -with open(Path(__file__).parent / "flake8_trio" / "__init__.py") as o: +with open(Path(__file__).parent / "flake8_async" / "__init__.py") as o: for line in o: if line.startswith("__version__"): _, __version__, _ = line.split('"') @@ -24,7 +24,7 @@ def local_file(name: str) -> Path: version=__version__, author="Zac Hatfield-Dodds, John Litborn, and Contributors", author_email="zac@zhd.dev", - packages=find_packages(include=["flake8_trio", "flake8_trio.*"]), + packages=find_packages(include=["flake8_async", "flake8_async.*"]), url="https://github.com/python-trio/flake8-trio", license="MIT", description="A highly opinionated flake8 plugin for Trio-related problems.", @@ -54,7 +54,7 @@ def local_file(name: str) -> Path: # You're not allowed to register error codes longer than 3 characters. But flake8 # doesn't enforce anything about the characters trailing the code, so we can say # the code is ASY and then just always happen to print NCxxx directly after it. - "flake8.extension": ["ASY = flake8_trio:Plugin"], - "console_scripts": ["flake8-async=flake8_trio:main"], + "flake8.extension": ["ASY = flake8_async:Plugin"], + "console_scripts": ["flake8-async=flake8_async:main"], }, ) diff --git a/tests/test_all_visitors_imported.py b/tests/test_all_visitors_imported.py index ffa881c..713de22 100644 --- a/tests/test_all_visitors_imported.py +++ b/tests/test_all_visitors_imported.py @@ -1,7 +1,7 @@ """Check that all visitors are imported. -Checks that all flake8_trio/visitor*.py files are imported in flake8_trio/visitor/__init__ -so their decorators are run. +Checks that all flake8_async/visitor*.py files are imported in +flake8_async/visitor/__init__.py so their decorators are run. """ from __future__ import annotations @@ -11,7 +11,7 @@ def test_all_visitors_imported(): - visitor_dir = Path(__file__).parent.parent / "flake8_trio" / "visitors" + visitor_dir = Path(__file__).parent.parent / "flake8_async" / "visitors" visitor_files = { f.stem for f in visitor_dir.iterdir() if f.stem.startswith("visitor") } diff --git a/tests/test_changelog_and_version.py b/tests/test_changelog_and_version.py index 628f8a5..e906801 100755 --- a/tests/test_changelog_and_version.py +++ b/tests/test_changelog_and_version.py @@ -14,7 +14,7 @@ ROOT_PATH = Path(__file__).parent.parent CHANGELOG = ROOT_PATH / "CHANGELOG.md" README = ROOT_PATH / "README.md" -INIT_FILE = ROOT_PATH / "flake8_trio" / "__init__.py" +INIT_FILE = ROOT_PATH / "flake8_async" / "__init__.py" T = TypeVar("T", bound="Version") @@ -86,7 +86,7 @@ def update_version() -> None: # If we've added a new version to the changelog, update __version__ to match last_version = next(iter(get_releases())) if last_version != VERSION: - INIT_FILE = ROOT_PATH / "flake8_trio" / "__init__.py" + INIT_FILE = ROOT_PATH / "flake8_async" / "__init__.py" subs = (f'__version__ = "{VERSION}"', f'__version__ = "{last_version}"') INIT_FILE.write_text(INIT_FILE.read_text().replace(*subs)) diff --git a/tests/test_config_and_args.py b/tests/test_config_and_args.py index 066bd43..ba3841b 100644 --- a/tests/test_config_and_args.py +++ b/tests/test_config_and_args.py @@ -9,9 +9,9 @@ import pytest -from flake8_trio import Plugin, main +from flake8_async import Plugin, main -from .test_flake8_trio import initialize_options +from .test_flake8_async import initialize_options EXAMPLE_PY_TEXT = """import trio with trio.move_on_after(10): @@ -47,7 +47,7 @@ def monkeypatch_argv( monkeypatch.setattr(sys, "argv", argv) -def test_run_flake8_trio(tmp_path: Path): +def test_run_flake8_async(tmp_path: Path): write_examplepy(tmp_path) res = subprocess.run( [ @@ -71,7 +71,7 @@ def test_systemexit_0( tmp_path.joinpath("example.py").write_text("") with pytest.raises(SystemExit) as exc_info: - from flake8_trio import __main__ # noqa: F401 + from flake8_async import __main__ # noqa: F401 assert exc_info.value.code == 0 out, err = capsys.readouterr() @@ -86,7 +86,7 @@ def test_systemexit_1( monkeypatch_argv(monkeypatch, tmp_path) with pytest.raises(SystemExit) as exc_info: - from flake8_trio import __main__ # noqa: F401 + from flake8_async import __main__ # noqa: F401 assert exc_info.value.code == 1 out, err = capsys.readouterr() @@ -168,7 +168,7 @@ def test_anyio_from_config(tmp_path: Path, capsys: pytest.CaptureFixture[str]): """ ) - from flake8_trio.visitors.visitor2xx import Visitor22X + from flake8_async.visitors.visitor2xx import Visitor22X err_msg = Visitor22X.error_codes["ASYNC220"].format( "subprocess.Popen", diff --git a/tests/test_decorator.py b/tests/test_decorator.py index f74a1ba..b3828ce 100644 --- a/tests/test_decorator.py +++ b/tests/test_decorator.py @@ -8,9 +8,9 @@ from flake8.main.application import Application -from flake8_trio.base import Statement -from flake8_trio.visitors.helpers import fnmatch_qualified_name -from flake8_trio.visitors.visitor91x import Visitor91X +from flake8_async.base import Statement +from flake8_async.visitors.helpers import fnmatch_qualified_name +from flake8_async.visitors.visitor91x import Visitor91X if TYPE_CHECKING: import pytest diff --git a/tests/test_exception_on_invalid_code.py b/tests/test_exception_on_invalid_code.py index 8371c56..dec3fd1 100644 --- a/tests/test_exception_on_invalid_code.py +++ b/tests/test_exception_on_invalid_code.py @@ -5,7 +5,7 @@ import libcst as cst import pytest -from flake8_trio.visitors.helpers import iter_guaranteed_once, iter_guaranteed_once_cst +from flake8_async.visitors.helpers import iter_guaranteed_once, iter_guaranteed_once_cst def _raises_on_code_cst(source: str): diff --git a/tests/test_flake8_trio.py b/tests/test_flake8_async.py similarity index 99% rename from tests/test_flake8_trio.py rename to tests/test_flake8_async.py index 39b800c..4d44670 100644 --- a/tests/test_flake8_trio.py +++ b/tests/test_flake8_async.py @@ -23,14 +23,14 @@ from hypothesis import HealthCheck, given, settings from hypothesmith import from_grammar, from_node -from flake8_trio import Plugin -from flake8_trio.base import Error, Statement -from flake8_trio.visitors import ERROR_CLASSES, ERROR_CLASSES_CST +from flake8_async import Plugin +from flake8_async.base import Error, Statement +from flake8_async.visitors import ERROR_CLASSES, ERROR_CLASSES_CST if TYPE_CHECKING: from collections.abc import Iterable, Sequence - from flake8_trio.visitors.flake8triovisitor import Flake8AsyncVisitor + from flake8_async.visitors.flake8asyncvisitor import Flake8AsyncVisitor AUTOFIX_DIR = Path(__file__).parent / "autofix_files" diff --git a/tests/test_formatting.py b/tests/test_formatting.py index bc01a0d..44dd025 100644 --- a/tests/test_formatting.py +++ b/tests/test_formatting.py @@ -1,6 +1,6 @@ """Test formatting in error codes.""" -from flake8_trio.visitors import ERROR_CLASSES +from flake8_async.visitors import ERROR_CLASSES def test_error_messages_ends_with_period(): diff --git a/tests/test_messages_documented.py b/tests/test_messages_documented.py index 33536c6..e31b00e 100755 --- a/tests/test_messages_documented.py +++ b/tests/test_messages_documented.py @@ -7,7 +7,7 @@ from pathlib import Path from typing import cast -from .test_flake8_trio import ERROR_CODES +from .test_flake8_async import ERROR_CODES ROOT_PATH = Path(__file__).parent.parent CHANGELOG = ROOT_PATH / "CHANGELOG.md" @@ -35,7 +35,7 @@ def test_messages_documented(): for error_msg in re.findall(r"TRIO\d\d\d|ASYNC\d\d\d", line): documented_errors[filename].add(rename_trio_to_async(error_msg)) - documented_errors["flake8_trio.py"] = set(ERROR_CODES) + documented_errors["flake8_async.py"] = set(ERROR_CODES) # get tested error codes from file names and from `# ARG --enable` lines documented_errors["eval_files"] = set() diff --git a/tox.ini b/tox.ini index 1222de8..b7e9feb 100644 --- a/tox.ini +++ b/tox.ini @@ -24,7 +24,7 @@ commands = [pytest] addopts = --tb=native - --cov=flake8_trio + --cov=flake8_async --cov-branch --cov-report=term-missing:skip-covered --cov-fail-under=100 @@ -33,8 +33,8 @@ filterwarnings = [coverage:paths] source = - flake8_trio - */site-packages/flake8_trio + flake8_async + */site-packages/flake8_async [coverage:report] exclude_lines = From a347611fc4609292b46216d81bd44b2937b2f1eb Mon Sep 17 00:00:00 2001 From: jakkdl Date: Mon, 26 Feb 2024 16:07:46 +0100 Subject: [PATCH 2/3] rename eval_files --- .pre-commit-config.yaml | 2 +- tests/autofix_files/{trio100.py => async100.py} | 0 tests/autofix_files/{trio100.py.diff => async100.py.diff} | 0 .../{trio100_simple_autofix.py => async100_simple_autofix.py} | 0 ...simple_autofix.py.diff => async100_simple_autofix.py.diff} | 0 tests/autofix_files/{trio910.py => async910.py} | 0 tests/autofix_files/{trio910.py.diff => async910.py.diff} | 0 tests/autofix_files/{trio911.py => async911.py} | 0 tests/autofix_files/{trio911.py.diff => async911.py.diff} | 0 .../autofix_files/{trio91x_autofix.py => async91x_autofix.py} | 0 .../{trio91x_autofix.py.diff => async91x_autofix.py.diff} | 0 tests/eval_files/{trio100.py => async100.py} | 0 .../{trio100_noautofix.py => async100_noautofix.py} | 0 .../{trio100_simple_autofix.py => async100_simple_autofix.py} | 0 tests/eval_files/{trio101.py => async101.py} | 0 tests/eval_files/{trio102.py => async102.py} | 0 tests/eval_files/{trio102_anyio.py => async102_anyio.py} | 0 tests/eval_files/{trio102_trio.py => async102_trio.py} | 0 tests/eval_files/{trio103.py => async103.py} | 0 .../{trio103_both_imported.py => async103_both_imported.py} | 0 tests/eval_files/{trio103_no_104.py => async103_no_104.py} | 0 tests/eval_files/{trio103_trio.py => async103_trio.py} | 0 tests/eval_files/{trio104.py => async104.py} | 0 tests/eval_files/{trio104_anyio.py => async104_anyio.py} | 0 tests/eval_files/{trio104_trio.py => async104_trio.py} | 0 tests/eval_files/{trio105.py => async105.py} | 0 tests/eval_files/{trio105_anyio.py => async105_anyio.py} | 0 tests/eval_files/{trio106.py => async106.py} | 0 tests/eval_files/{trio109.py => async109.py} | 0 tests/eval_files/{trio110.py => async110.py} | 0 tests/eval_files/{trio111.py => async111.py} | 0 tests/eval_files/{trio112.py => async112.py} | 0 tests/eval_files/{trio113.py => async113.py} | 0 tests/eval_files/{trio113_trio.py => async113_trio.py} | 0 tests/eval_files/{trio114.py => async114.py} | 0 tests/eval_files/{trio115.py => async115.py} | 0 tests/eval_files/{trio116.py => async116.py} | 0 tests/eval_files/{trio118.py => async118.py} | 0 tests/eval_files/{trio200.py => async200.py} | 0 tests/eval_files/{trio210.py => async210.py} | 0 tests/eval_files/{trio211.py => async211.py} | 0 tests/eval_files/{trio212.py => async212.py} | 0 tests/eval_files/{trio22x.py => async22x.py} | 0 tests/eval_files/{trio232.py => async232.py} | 0 tests/eval_files/{trio23x.py => async23x.py} | 0 tests/eval_files/{trio240.py => async240.py} | 0 tests/eval_files/{trio900.py => async900.py} | 0 tests/eval_files/{trio910.py => async910.py} | 0 tests/eval_files/{trio911.py => async911.py} | 0 tests/eval_files/{trio91x_autofix.py => async91x_autofix.py} | 0 .../{trio91x_noautofix.py => async91x_noautofix.py} | 0 tests/test_messages_documented.py | 4 ++-- 52 files changed, 3 insertions(+), 3 deletions(-) rename tests/autofix_files/{trio100.py => async100.py} (100%) rename tests/autofix_files/{trio100.py.diff => async100.py.diff} (100%) rename tests/autofix_files/{trio100_simple_autofix.py => async100_simple_autofix.py} (100%) rename tests/autofix_files/{trio100_simple_autofix.py.diff => async100_simple_autofix.py.diff} (100%) rename tests/autofix_files/{trio910.py => async910.py} (100%) rename tests/autofix_files/{trio910.py.diff => async910.py.diff} (100%) rename tests/autofix_files/{trio911.py => async911.py} (100%) rename tests/autofix_files/{trio911.py.diff => async911.py.diff} (100%) rename tests/autofix_files/{trio91x_autofix.py => async91x_autofix.py} (100%) rename tests/autofix_files/{trio91x_autofix.py.diff => async91x_autofix.py.diff} (100%) rename tests/eval_files/{trio100.py => async100.py} (100%) rename tests/eval_files/{trio100_noautofix.py => async100_noautofix.py} (100%) rename tests/eval_files/{trio100_simple_autofix.py => async100_simple_autofix.py} (100%) rename tests/eval_files/{trio101.py => async101.py} (100%) rename tests/eval_files/{trio102.py => async102.py} (100%) rename tests/eval_files/{trio102_anyio.py => async102_anyio.py} (100%) rename tests/eval_files/{trio102_trio.py => async102_trio.py} (100%) rename tests/eval_files/{trio103.py => async103.py} (100%) rename tests/eval_files/{trio103_both_imported.py => async103_both_imported.py} (100%) rename tests/eval_files/{trio103_no_104.py => async103_no_104.py} (100%) rename tests/eval_files/{trio103_trio.py => async103_trio.py} (100%) rename tests/eval_files/{trio104.py => async104.py} (100%) rename tests/eval_files/{trio104_anyio.py => async104_anyio.py} (100%) rename tests/eval_files/{trio104_trio.py => async104_trio.py} (100%) rename tests/eval_files/{trio105.py => async105.py} (100%) rename tests/eval_files/{trio105_anyio.py => async105_anyio.py} (100%) rename tests/eval_files/{trio106.py => async106.py} (100%) rename tests/eval_files/{trio109.py => async109.py} (100%) rename tests/eval_files/{trio110.py => async110.py} (100%) rename tests/eval_files/{trio111.py => async111.py} (100%) rename tests/eval_files/{trio112.py => async112.py} (100%) rename tests/eval_files/{trio113.py => async113.py} (100%) rename tests/eval_files/{trio113_trio.py => async113_trio.py} (100%) rename tests/eval_files/{trio114.py => async114.py} (100%) rename tests/eval_files/{trio115.py => async115.py} (100%) rename tests/eval_files/{trio116.py => async116.py} (100%) rename tests/eval_files/{trio118.py => async118.py} (100%) rename tests/eval_files/{trio200.py => async200.py} (100%) rename tests/eval_files/{trio210.py => async210.py} (100%) rename tests/eval_files/{trio211.py => async211.py} (100%) rename tests/eval_files/{trio212.py => async212.py} (100%) rename tests/eval_files/{trio22x.py => async22x.py} (100%) rename tests/eval_files/{trio232.py => async232.py} (100%) rename tests/eval_files/{trio23x.py => async23x.py} (100%) rename tests/eval_files/{trio240.py => async240.py} (100%) rename tests/eval_files/{trio900.py => async900.py} (100%) rename tests/eval_files/{trio910.py => async910.py} (100%) rename tests/eval_files/{trio911.py => async911.py} (100%) rename tests/eval_files/{trio91x_autofix.py => async91x_autofix.py} (100%) rename tests/eval_files/{trio91x_noautofix.py => async91x_noautofix.py} (100%) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6edab0d..774e774 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -23,7 +23,7 @@ repos: hooks: - id: pyupgrade args: [--py39-plus] - exclude: tests/eval_files/trio103.py + exclude: tests/eval_files/async103.py - repo: https://github.com/pycqa/isort rev: 5.13.2 diff --git a/tests/autofix_files/trio100.py b/tests/autofix_files/async100.py similarity index 100% rename from tests/autofix_files/trio100.py rename to tests/autofix_files/async100.py diff --git a/tests/autofix_files/trio100.py.diff b/tests/autofix_files/async100.py.diff similarity index 100% rename from tests/autofix_files/trio100.py.diff rename to tests/autofix_files/async100.py.diff diff --git a/tests/autofix_files/trio100_simple_autofix.py b/tests/autofix_files/async100_simple_autofix.py similarity index 100% rename from tests/autofix_files/trio100_simple_autofix.py rename to tests/autofix_files/async100_simple_autofix.py diff --git a/tests/autofix_files/trio100_simple_autofix.py.diff b/tests/autofix_files/async100_simple_autofix.py.diff similarity index 100% rename from tests/autofix_files/trio100_simple_autofix.py.diff rename to tests/autofix_files/async100_simple_autofix.py.diff diff --git a/tests/autofix_files/trio910.py b/tests/autofix_files/async910.py similarity index 100% rename from tests/autofix_files/trio910.py rename to tests/autofix_files/async910.py diff --git a/tests/autofix_files/trio910.py.diff b/tests/autofix_files/async910.py.diff similarity index 100% rename from tests/autofix_files/trio910.py.diff rename to tests/autofix_files/async910.py.diff diff --git a/tests/autofix_files/trio911.py b/tests/autofix_files/async911.py similarity index 100% rename from tests/autofix_files/trio911.py rename to tests/autofix_files/async911.py diff --git a/tests/autofix_files/trio911.py.diff b/tests/autofix_files/async911.py.diff similarity index 100% rename from tests/autofix_files/trio911.py.diff rename to tests/autofix_files/async911.py.diff diff --git a/tests/autofix_files/trio91x_autofix.py b/tests/autofix_files/async91x_autofix.py similarity index 100% rename from tests/autofix_files/trio91x_autofix.py rename to tests/autofix_files/async91x_autofix.py diff --git a/tests/autofix_files/trio91x_autofix.py.diff b/tests/autofix_files/async91x_autofix.py.diff similarity index 100% rename from tests/autofix_files/trio91x_autofix.py.diff rename to tests/autofix_files/async91x_autofix.py.diff diff --git a/tests/eval_files/trio100.py b/tests/eval_files/async100.py similarity index 100% rename from tests/eval_files/trio100.py rename to tests/eval_files/async100.py diff --git a/tests/eval_files/trio100_noautofix.py b/tests/eval_files/async100_noautofix.py similarity index 100% rename from tests/eval_files/trio100_noautofix.py rename to tests/eval_files/async100_noautofix.py diff --git a/tests/eval_files/trio100_simple_autofix.py b/tests/eval_files/async100_simple_autofix.py similarity index 100% rename from tests/eval_files/trio100_simple_autofix.py rename to tests/eval_files/async100_simple_autofix.py diff --git a/tests/eval_files/trio101.py b/tests/eval_files/async101.py similarity index 100% rename from tests/eval_files/trio101.py rename to tests/eval_files/async101.py diff --git a/tests/eval_files/trio102.py b/tests/eval_files/async102.py similarity index 100% rename from tests/eval_files/trio102.py rename to tests/eval_files/async102.py diff --git a/tests/eval_files/trio102_anyio.py b/tests/eval_files/async102_anyio.py similarity index 100% rename from tests/eval_files/trio102_anyio.py rename to tests/eval_files/async102_anyio.py diff --git a/tests/eval_files/trio102_trio.py b/tests/eval_files/async102_trio.py similarity index 100% rename from tests/eval_files/trio102_trio.py rename to tests/eval_files/async102_trio.py diff --git a/tests/eval_files/trio103.py b/tests/eval_files/async103.py similarity index 100% rename from tests/eval_files/trio103.py rename to tests/eval_files/async103.py diff --git a/tests/eval_files/trio103_both_imported.py b/tests/eval_files/async103_both_imported.py similarity index 100% rename from tests/eval_files/trio103_both_imported.py rename to tests/eval_files/async103_both_imported.py diff --git a/tests/eval_files/trio103_no_104.py b/tests/eval_files/async103_no_104.py similarity index 100% rename from tests/eval_files/trio103_no_104.py rename to tests/eval_files/async103_no_104.py diff --git a/tests/eval_files/trio103_trio.py b/tests/eval_files/async103_trio.py similarity index 100% rename from tests/eval_files/trio103_trio.py rename to tests/eval_files/async103_trio.py diff --git a/tests/eval_files/trio104.py b/tests/eval_files/async104.py similarity index 100% rename from tests/eval_files/trio104.py rename to tests/eval_files/async104.py diff --git a/tests/eval_files/trio104_anyio.py b/tests/eval_files/async104_anyio.py similarity index 100% rename from tests/eval_files/trio104_anyio.py rename to tests/eval_files/async104_anyio.py diff --git a/tests/eval_files/trio104_trio.py b/tests/eval_files/async104_trio.py similarity index 100% rename from tests/eval_files/trio104_trio.py rename to tests/eval_files/async104_trio.py diff --git a/tests/eval_files/trio105.py b/tests/eval_files/async105.py similarity index 100% rename from tests/eval_files/trio105.py rename to tests/eval_files/async105.py diff --git a/tests/eval_files/trio105_anyio.py b/tests/eval_files/async105_anyio.py similarity index 100% rename from tests/eval_files/trio105_anyio.py rename to tests/eval_files/async105_anyio.py diff --git a/tests/eval_files/trio106.py b/tests/eval_files/async106.py similarity index 100% rename from tests/eval_files/trio106.py rename to tests/eval_files/async106.py diff --git a/tests/eval_files/trio109.py b/tests/eval_files/async109.py similarity index 100% rename from tests/eval_files/trio109.py rename to tests/eval_files/async109.py diff --git a/tests/eval_files/trio110.py b/tests/eval_files/async110.py similarity index 100% rename from tests/eval_files/trio110.py rename to tests/eval_files/async110.py diff --git a/tests/eval_files/trio111.py b/tests/eval_files/async111.py similarity index 100% rename from tests/eval_files/trio111.py rename to tests/eval_files/async111.py diff --git a/tests/eval_files/trio112.py b/tests/eval_files/async112.py similarity index 100% rename from tests/eval_files/trio112.py rename to tests/eval_files/async112.py diff --git a/tests/eval_files/trio113.py b/tests/eval_files/async113.py similarity index 100% rename from tests/eval_files/trio113.py rename to tests/eval_files/async113.py diff --git a/tests/eval_files/trio113_trio.py b/tests/eval_files/async113_trio.py similarity index 100% rename from tests/eval_files/trio113_trio.py rename to tests/eval_files/async113_trio.py diff --git a/tests/eval_files/trio114.py b/tests/eval_files/async114.py similarity index 100% rename from tests/eval_files/trio114.py rename to tests/eval_files/async114.py diff --git a/tests/eval_files/trio115.py b/tests/eval_files/async115.py similarity index 100% rename from tests/eval_files/trio115.py rename to tests/eval_files/async115.py diff --git a/tests/eval_files/trio116.py b/tests/eval_files/async116.py similarity index 100% rename from tests/eval_files/trio116.py rename to tests/eval_files/async116.py diff --git a/tests/eval_files/trio118.py b/tests/eval_files/async118.py similarity index 100% rename from tests/eval_files/trio118.py rename to tests/eval_files/async118.py diff --git a/tests/eval_files/trio200.py b/tests/eval_files/async200.py similarity index 100% rename from tests/eval_files/trio200.py rename to tests/eval_files/async200.py diff --git a/tests/eval_files/trio210.py b/tests/eval_files/async210.py similarity index 100% rename from tests/eval_files/trio210.py rename to tests/eval_files/async210.py diff --git a/tests/eval_files/trio211.py b/tests/eval_files/async211.py similarity index 100% rename from tests/eval_files/trio211.py rename to tests/eval_files/async211.py diff --git a/tests/eval_files/trio212.py b/tests/eval_files/async212.py similarity index 100% rename from tests/eval_files/trio212.py rename to tests/eval_files/async212.py diff --git a/tests/eval_files/trio22x.py b/tests/eval_files/async22x.py similarity index 100% rename from tests/eval_files/trio22x.py rename to tests/eval_files/async22x.py diff --git a/tests/eval_files/trio232.py b/tests/eval_files/async232.py similarity index 100% rename from tests/eval_files/trio232.py rename to tests/eval_files/async232.py diff --git a/tests/eval_files/trio23x.py b/tests/eval_files/async23x.py similarity index 100% rename from tests/eval_files/trio23x.py rename to tests/eval_files/async23x.py diff --git a/tests/eval_files/trio240.py b/tests/eval_files/async240.py similarity index 100% rename from tests/eval_files/trio240.py rename to tests/eval_files/async240.py diff --git a/tests/eval_files/trio900.py b/tests/eval_files/async900.py similarity index 100% rename from tests/eval_files/trio900.py rename to tests/eval_files/async900.py diff --git a/tests/eval_files/trio910.py b/tests/eval_files/async910.py similarity index 100% rename from tests/eval_files/trio910.py rename to tests/eval_files/async910.py diff --git a/tests/eval_files/trio911.py b/tests/eval_files/async911.py similarity index 100% rename from tests/eval_files/trio911.py rename to tests/eval_files/async911.py diff --git a/tests/eval_files/trio91x_autofix.py b/tests/eval_files/async91x_autofix.py similarity index 100% rename from tests/eval_files/trio91x_autofix.py rename to tests/eval_files/async91x_autofix.py diff --git a/tests/eval_files/trio91x_noautofix.py b/tests/eval_files/async91x_noautofix.py similarity index 100% rename from tests/eval_files/trio91x_noautofix.py rename to tests/eval_files/async91x_noautofix.py diff --git a/tests/test_messages_documented.py b/tests/test_messages_documented.py index e31b00e..927fad8 100755 --- a/tests/test_messages_documented.py +++ b/tests/test_messages_documented.py @@ -44,8 +44,8 @@ def test_messages_documented(): if not file_path.is_file(): continue - if m := re.search(r"trio\d\d\d", str(file_path)): - documented_errors["eval_files"].add(rename_trio_to_async(m.group().upper())) + if m := re.search(r"async\d\d\d", str(file_path)): + documented_errors["eval_files"].add(m.group().upper()) with open(file_path) as file: for line in file: From 6281cb34e336898cca09f738ca1d802b4b33d50f Mon Sep 17 00:00:00 2001 From: jakkdl Date: Mon, 26 Feb 2024 16:18:33 +0100 Subject: [PATCH 3/3] remove rename_file and unrename_file --- tests/test_flake8_async.py | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/tests/test_flake8_async.py b/tests/test_flake8_async.py index 4d44670..2b53bce 100644 --- a/tests/test_flake8_async.py +++ b/tests/test_flake8_async.py @@ -35,23 +35,11 @@ AUTOFIX_DIR = Path(__file__).parent / "autofix_files" -# to be able to usefully view diffs on github+be able to run tests in each step -# we temporarily introduce these functions -# so we can do the *actual* renaming of files in a separate commit. -def rename_file(s: str) -> str: - return re.sub("TRIO", "ASYNC", s) - - -def unrename_file(s: str) -> str: - return re.sub("ASYNC", "TRIO", s) - - test_files: list[tuple[str, Path]] = sorted( - (rename_file(f.stem.upper()), f) - for f in (Path(__file__).parent / "eval_files").iterdir() + (f.stem.upper(), f) for f in (Path(__file__).parent / "eval_files").iterdir() ) autofix_files: dict[str, Path] = { - rename_file(f.stem.upper()): f for f in AUTOFIX_DIR.iterdir() if f.suffix == ".py" + f.stem.upper(): f for f in AUTOFIX_DIR.iterdir() if f.suffix == ".py" } # check that there's an eval file for each autofix file extra_autofix_files = set(autofix_files.keys()) - {f[0] for f in test_files} @@ -144,9 +132,9 @@ def check_autofix( # file contains a previous diff showing what's added/removed by the autofixer # i.e. a diff between "eval_files/{test}.py" and "autofix_files/{test}.py" - autofix_diff_file = AUTOFIX_DIR / f"{unrename_file(test).lower()}.py.diff" + autofix_diff_file = AUTOFIX_DIR / f"{test.lower()}.py.diff" if not autofix_diff_file.exists(): - assert generate_autofix, "autofix diff file doesn't exist" + assert generate_autofix, f"autofix diff file {autofix_diff_file} doesn't exist" # if generate_autofix is set, the diff content isn't used and the file # content will be created autofix_diff_content = ""