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
8 changes: 6 additions & 2 deletions pyflakes/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1585,7 +1585,9 @@ def _non_annotations(nodes: list[ast.AST]) -> None:
for k, v in iter_dict_children(node.args[1]):
_non_annotation(k)
_annotation(v)
_non_annotations(node.args[2:])
_non_annotations(node.args[2:])
else:
_non_annotations(node.args[1:])

# TypedDict("a", a=int)
if sys.version_info >= (3, 13): # pragma: >=3.13 cover
Expand All @@ -1608,7 +1610,9 @@ def _non_annotations(nodes: list[ast.AST]) -> None:
_annotations(elt.elts[1:])
else:
_non_annotation(elt)
_non_annotations(node.args[2:])
_non_annotations(node.args[2:])
else:
_non_annotations(node.args[1:])

# NamedTuple("a", a=int)
if sys.version_info >= (3, 15): # pragma: >=3.15 cover
Expand Down
15 changes: 15 additions & 0 deletions pyflakes/test/test_type_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,13 @@ def test_typeddict_key_value_ordering(self):
TypedDict("TD", {"k": (y := "V"), y: "V"})
""")

def test_typeddict_not_dict(self):
self.flakes("""
from typing import TypedDict
from x import y
TypedDict("TD", y)
""")

def test_namedtypes_classes(self):
self.flakes("""
from typing import TypedDict, NamedTuple
Expand All @@ -815,6 +822,14 @@ def test_namedtuple_non_tuple_args(self):
NT = NamedTuple("NT", [x])
""")

def test_namedtuple_non_list_args(self):
self.flakes("""
from typing import NamedTuple
from x import y

NamedTuple("NT", y)
""")

@skipIf(version_info < (3, 11), 'new in Python 3.11')
def test_variadic_generics(self): # pragma: >=3.11 cover
self.flakes("""
Expand Down
Loading