Skip to content

Commit 4fe3618

Browse files
committed
fix pyright type errors after typeshed bump
1 parent d22ac7b commit 4fe3618

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

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

0 commit comments

Comments
 (0)