Skip to content

[pre-commit.ci] pre-commit autoupdate #390

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

Merged
merged 3 commits into from
Jul 11, 2025
Merged
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
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ci:

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.13
rev: v0.12.2
hooks:
- id: ruff
args: [--fix]
Expand Down Expand Up @@ -38,14 +38,14 @@ repos:
- id: isort

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.16.0
rev: v1.16.1
hooks:
- id: mypy
# uses py311 syntax, mypy configured for py39
exclude: tests/(eval|autofix)_files/.*_py(310|311).py

- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.401
rev: v1.1.402
hooks:
- id: pyright
# ignore warnings about new version being available, no other warnings
Expand Down Expand Up @@ -92,7 +92,7 @@ repos:
- id: yamlfmt

- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.14.0
rev: v2.15.0
hooks:
- id: pretty-format-toml
args: [--autofix]
Expand Down
3 changes: 3 additions & 0 deletions flake8_async/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,6 @@ def __repr__(self) -> str: # pragma: no cover
def __str__(self) -> str:
# flake8 adds 1 to the yielded column from `__iter__`, so we do the same here
return f"{self.line}:{self.col+1}: {self.format_message()}"

def __hash__(self) -> int:
return hash(self.cmp())
9 changes: 7 additions & 2 deletions flake8_async/visitors/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,14 @@ def iter_guaranteed_once(iterable: ast.expr) -> bool:
else:
return True
return False

# once we drop 3.9 we can add `and not isinstance(iterable.value, types.EllipsisType)`
# to get rid of `type: ignore`. Or just live with the fact that pyright doesn't
# make use of the `hasattr`.
if isinstance(iterable, ast.Constant):
return hasattr(iterable.value, "__len__") and len(iterable.value) > 0
return (
hasattr(iterable.value, "__len__")
and len(iterable.value) > 0 # pyright: ignore[reportArgumentType]
)

if isinstance(iterable, ast.Dict):
for key, val in zip(iterable.keys, iterable.values):
Expand Down
4 changes: 2 additions & 2 deletions flake8_async/visitors/visitor102_120.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __init__(self, node: ast.Call, funcname: str):
for kw in node.keywords:
# Only accepts constant values
if kw.arg == "shield" and isinstance(kw.value, ast.Constant):
self.shielded = kw.value.value
self.shielded = bool(kw.value.value)

def __init__(self, *args: Any, **kwargs: Any):
super().__init__(*args, **kwargs)
Expand Down Expand Up @@ -200,7 +200,7 @@ def visit_Assign(self, node: ast.Assign):
)
)
):
scope.shielded = node.value.value
scope.shielded = bool(node.value.value)

def visit_FunctionDef(
self, node: ast.FunctionDef | ast.AsyncFunctionDef | ast.Lambda
Expand Down
3 changes: 1 addition & 2 deletions tests/check_changelog_and_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from pathlib import Path
from typing import TYPE_CHECKING, NamedTuple, TypeVar

from git.repo import Repo
from typing_extensions import Self

if TYPE_CHECKING:
Expand Down Expand Up @@ -90,8 +91,6 @@ def test_version_increments_are_correct() -> None:


def ensure_tagged() -> None:
from git.repo import Repo

last_version = next(iter(get_releases()))
repo = Repo(ROOT_PATH)
if str(last_version) not in iter(map(str, repo.tags)):
Expand Down
12 changes: 6 additions & 6 deletions tests/test_config_and_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def test_systemexit_0(
tmp_path.joinpath("example.py").write_text("")

with pytest.raises(SystemExit) as exc_info:
from flake8_async import __main__ # noqa: F401
from flake8_async import __main__ # noqa: F401, PLC0415

assert exc_info.value.code == 0
out, err = capsys.readouterr()
Expand All @@ -91,7 +91,7 @@ def test_systemexit_1(
monkeypatch_argv(monkeypatch, tmp_path)

with pytest.raises(SystemExit) as exc_info:
from flake8_async import __main__ # noqa: F401
from flake8_async import __main__ # noqa: F401, PLC0415

assert exc_info.value.code == 1
out, err = capsys.readouterr()
Expand Down Expand Up @@ -174,7 +174,7 @@ def test_anyio_from_config(tmp_path: Path, capsys: pytest.CaptureFixture[str]):
"""
)

from flake8_async.visitors.visitor2xx import Visitor22X
from flake8_async.visitors.visitor2xx import Visitor22X # noqa: PLC0415

err_msg = Visitor22X.error_codes["ASYNC220"].format(
"subprocess.Popen",
Expand All @@ -193,7 +193,7 @@ def test_anyio_from_config(tmp_path: Path, capsys: pytest.CaptureFixture[str]):

# construct the full error message
expected = f"{err_file}:{lineno}:5: ASYNC220 {err_msg}\n"
from flake8.main.cli import main
from flake8.main.cli import main # noqa: PLC0415

returnvalue = main(
argv=[
Expand Down Expand Up @@ -246,7 +246,7 @@ def test_200_from_config_flake8_internals(
# replace ./ with tmp_path/
err_msg = str(tmp_path) + EXAMPLE_PY_TEXT[1:]

from flake8.main.cli import main
from flake8.main.cli import main # noqa: PLC0415

returnvalue = main(
argv=[
Expand Down Expand Up @@ -330,7 +330,7 @@ def test_900_default_off():

@pytest.mark.skipif(flake8 is None, reason="flake8 is not installed")
def test_900_default_off_flake8(capsys: pytest.CaptureFixture[str]):
from flake8.main.cli import main
from flake8.main.cli import main # noqa: PLC0415

returnvalue = main(
argv=[
Expand Down
Loading