Skip to content

Commit e04f7bb

Browse files
committed
fix typing errors
1 parent b801e7c commit e04f7bb

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

flake8_async/visitors/flake8asyncvisitor.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616

1717
from ..runner import SharedState
1818

19-
HasLineCol = Union[
20-
ast.expr, ast.stmt, ast.arg, ast.excepthandler, ast.alias, Statement
21-
]
19+
HasLineCol = Union[ast.expr, ast.stmt, ast.arg, ast.excepthandler, Statement]
2220

2321

2422
class Flake8AsyncVisitor(ast.NodeVisitor, ABC):

flake8_async/visitors/helpers.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from __future__ import annotations
77

88
import ast
9+
from collections.abc import Sized
910
from dataclasses import dataclass
1011
from fnmatch import fnmatch
1112
from typing import TYPE_CHECKING, Generic, TypeVar, Union
@@ -140,14 +141,9 @@ def iter_guaranteed_once(iterable: ast.expr) -> bool:
140141
else:
141142
return True
142143
return False
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`.
144+
146145
if isinstance(iterable, ast.Constant):
147-
return (
148-
hasattr(iterable.value, "__len__")
149-
and len(iterable.value) > 0 # pyright: ignore[reportArgumentType]
150-
)
146+
return isinstance(iterable.value, Sized) and len(iterable.value) > 0
151147

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

0 commit comments

Comments
 (0)