Skip to content
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
4 changes: 2 additions & 2 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.12.3
rev: v0.12.4
hooks:
- id: ruff
args: [--fix]
Expand Down Expand Up @@ -38,7 +38,7 @@ repos:
- id: isort

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.16.1
rev: v1.17.0
hooks:
- id: mypy
# uses py311 syntax, mypy configured for py39
Expand Down
4 changes: 1 addition & 3 deletions flake8_async/visitors/flake8asyncvisitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@

from ..runner import SharedState

HasLineCol = Union[
ast.expr, ast.stmt, ast.arg, ast.excepthandler, ast.alias, Statement
]
HasLineCol = Union[ast.expr, ast.stmt, ast.arg, ast.excepthandler, Statement]


class Flake8AsyncVisitor(ast.NodeVisitor, ABC):
Expand Down
10 changes: 3 additions & 7 deletions flake8_async/visitors/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from __future__ import annotations

import ast
from collections.abc import Sized
from dataclasses import dataclass
from fnmatch import fnmatch
from typing import TYPE_CHECKING, Generic, TypeVar, Union
Expand Down Expand Up @@ -140,14 +141,9 @@ 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 # pyright: ignore[reportArgumentType]
)
return isinstance(iterable.value, Sized) and len(iterable.value) > 0

if isinstance(iterable, ast.Dict):
for key, val in zip(iterable.keys, iterable.values):
Expand Down
Loading