Skip to content

Commit b29073c

Browse files
[pre-commit.ci] pre-commit autoupdate (#390)
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.11.13 → v0.12.2](astral-sh/ruff-pre-commit@v0.11.13...v0.12.2) - [github.com/pre-commit/mirrors-mypy: v1.16.0 → v1.16.1](pre-commit/mirrors-mypy@v1.16.0...v1.16.1) - [github.com/RobertCraigie/pyright-python: v1.1.401 → v1.1.402](RobertCraigie/pyright-python@v1.1.401...v1.1.402) - [github.com/macisamuele/language-formatters-pre-commit-hooks: v2.14.0 → v2.15.0](macisamuele/language-formatters-pre-commit-hooks@v2.14.0...v2.15.0) * fix pyright type errors after typeshed bump * also fix new errors from ruff --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: jakkdl <h6+github@pm.me>
1 parent 6358bf9 commit b29073c

File tree

6 files changed

+23
-16
lines changed

6 files changed

+23
-16
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ ci:
99

1010
repos:
1111
- repo: https://github.com/astral-sh/ruff-pre-commit
12-
rev: v0.11.13
12+
rev: v0.12.2
1313
hooks:
1414
- id: ruff
1515
args: [--fix]
@@ -38,14 +38,14 @@ repos:
3838
- id: isort
3939

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

4747
- repo: https://github.com/RobertCraigie/pyright-python
48-
rev: v1.1.401
48+
rev: v1.1.402
4949
hooks:
5050
- id: pyright
5151
# ignore warnings about new version being available, no other warnings
@@ -92,7 +92,7 @@ repos:
9292
- id: yamlfmt
9393

9494
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
95-
rev: v2.14.0
95+
rev: v2.15.0
9696
hooks:
9797
- id: pretty-format-toml
9898
args: [--autofix]

flake8_async/base.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,6 @@ def __repr__(self) -> str: # pragma: no cover
102102
def __str__(self) -> str:
103103
# flake8 adds 1 to the yielded column from `__iter__`, so we do the same here
104104
return f"{self.line}:{self.col+1}: {self.format_message()}"
105+
106+
def __hash__(self) -> int:
107+
return hash(self.cmp())

flake8_async/visitors/helpers.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,14 @@ def iter_guaranteed_once(iterable: ast.expr) -> bool:
140140
else:
141141
return True
142142
return False
143-
143+
# once we drop 3.9 we can add `and not isinstance(iterable.value, types.EllipsisType)`
144+
# to get rid of `type: ignore`. Or just live with the fact that pyright doesn't
145+
# make use of the `hasattr`.
144146
if isinstance(iterable, ast.Constant):
145-
return hasattr(iterable.value, "__len__") and len(iterable.value) > 0
147+
return (
148+
hasattr(iterable.value, "__len__")
149+
and len(iterable.value) > 0 # pyright: ignore[reportArgumentType]
150+
)
146151

147152
if isinstance(iterable, ast.Dict):
148153
for key, val in zip(iterable.keys, iterable.values):

flake8_async/visitors/visitor102_120.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def __init__(self, node: ast.Call, funcname: str):
4646
for kw in node.keywords:
4747
# Only accepts constant values
4848
if kw.arg == "shield" and isinstance(kw.value, ast.Constant):
49-
self.shielded = kw.value.value
49+
self.shielded = bool(kw.value.value)
5050

5151
def __init__(self, *args: Any, **kwargs: Any):
5252
super().__init__(*args, **kwargs)
@@ -200,7 +200,7 @@ def visit_Assign(self, node: ast.Assign):
200200
)
201201
)
202202
):
203-
scope.shielded = node.value.value
203+
scope.shielded = bool(node.value.value)
204204

205205
def visit_FunctionDef(
206206
self, node: ast.FunctionDef | ast.AsyncFunctionDef | ast.Lambda

tests/check_changelog_and_version.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from pathlib import Path
99
from typing import TYPE_CHECKING, NamedTuple, TypeVar
1010

11+
from git.repo import Repo
1112
from typing_extensions import Self
1213

1314
if TYPE_CHECKING:
@@ -90,8 +91,6 @@ def test_version_increments_are_correct() -> None:
9091

9192

9293
def ensure_tagged() -> None:
93-
from git.repo import Repo
94-
9594
last_version = next(iter(get_releases()))
9695
repo = Repo(ROOT_PATH)
9796
if str(last_version) not in iter(map(str, repo.tags)):

tests/test_config_and_args.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def test_systemexit_0(
7676
tmp_path.joinpath("example.py").write_text("")
7777

7878
with pytest.raises(SystemExit) as exc_info:
79-
from flake8_async import __main__ # noqa: F401
79+
from flake8_async import __main__ # noqa: F401, PLC0415
8080

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

9393
with pytest.raises(SystemExit) as exc_info:
94-
from flake8_async import __main__ # noqa: F401
94+
from flake8_async import __main__ # noqa: F401, PLC0415
9595

9696
assert exc_info.value.code == 1
9797
out, err = capsys.readouterr()
@@ -174,7 +174,7 @@ def test_anyio_from_config(tmp_path: Path, capsys: pytest.CaptureFixture[str]):
174174
"""
175175
)
176176

177-
from flake8_async.visitors.visitor2xx import Visitor22X
177+
from flake8_async.visitors.visitor2xx import Visitor22X # noqa: PLC0415
178178

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

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

198198
returnvalue = main(
199199
argv=[
@@ -246,7 +246,7 @@ def test_200_from_config_flake8_internals(
246246
# replace ./ with tmp_path/
247247
err_msg = str(tmp_path) + EXAMPLE_PY_TEXT[1:]
248248

249-
from flake8.main.cli import main
249+
from flake8.main.cli import main # noqa: PLC0415
250250

251251
returnvalue = main(
252252
argv=[
@@ -330,7 +330,7 @@ def test_900_default_off():
330330

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

335335
returnvalue = main(
336336
argv=[

0 commit comments

Comments
 (0)