diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index baa8b9c..72dd1e7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,7 +9,7 @@ ci: repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.14.14 + rev: v0.15.0 hooks: - id: ruff-check args: [--fix] diff --git a/flake8_async/base.py b/flake8_async/base.py index d0127b1..43f31a3 100644 --- a/flake8_async/base.py +++ b/flake8_async/base.py @@ -13,7 +13,7 @@ # several different ones are used for the same code. Used in e.g. Visitor103 def strip_error_subidentifier(s: str) -> str: """Turn e.g. ASYNC103_anyio_trio => ASYNC103.""" - return s.split("_")[0] + return s.split("_", maxsplit=1)[0] def error_has_subidentifier(s: str) -> bool: diff --git a/flake8_async/visitors/flake8asyncvisitor.py b/flake8_async/visitors/flake8asyncvisitor.py index 8e4297a..7774281 100644 --- a/flake8_async/visitors/flake8asyncvisitor.py +++ b/flake8_async/visitors/flake8asyncvisitor.py @@ -144,7 +144,7 @@ def walk(self, *body: ast.AST) -> Iterable[ast.AST]: @property def library(self) -> tuple[str, ...]: - return self.__state.library if self.__state.library else ("trio",) + return self.__state.library or ("trio",) @property def library_str(self) -> str: @@ -253,7 +253,7 @@ def should_autofix(self, node: cst.CSTNode, code: str | None = None) -> bool: @property def library(self) -> tuple[str, ...]: - return self.__state.library if self.__state.library else ("trio",) + return self.__state.library or ("trio",) # library_str not used in cst yet diff --git a/flake8_async/visitors/visitor91x.py b/flake8_async/visitors/visitor91x.py index 474bfe0..1ce0dbd 100644 --- a/flake8_async/visitors/visitor91x.py +++ b/flake8_async/visitors/visitor91x.py @@ -344,7 +344,7 @@ def __init__( @property def library(self) -> tuple[str, ...]: - return self.__library if self.__library else ("trio",) + return self.__library or ("trio",) def should_autofix(self, node: cst.CSTNode, code: str | None = None) -> bool: return not self.noautofix diff --git a/tests/test_flake8_async.py b/tests/test_flake8_async.py index 339fbdb..dbd36ee 100644 --- a/tests/test_flake8_async.py +++ b/tests/test_flake8_async.py @@ -395,7 +395,7 @@ def _parse_eval_file( ) -> tuple[list[Error], list[str], str]: # version check check_version(test) - test = test.split("_")[0] + test = test.split("_", maxsplit=1)[0] parsed_args = []