Skip to content

Commit fdc6399

Browse files
committed
Fix #21030
1 parent ef03ccd commit fdc6399

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

mypy/semanal.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2113,6 +2113,8 @@ def analyze_typeddict_classdef(self, defn: ClassDef) -> bool:
21132113
and not has_placeholder(defn.info.typeddict_type)
21142114
):
21152115
# This is a valid TypedDict, and it is fully analyzed.
2116+
for decorator in defn.decorators:
2117+
decorator.accept(self)
21162118
return True
21172119
is_typeddict, info = self.typed_dict_analyzer.analyze_typeddict_classdef(defn)
21182120
if is_typeddict:

test-data/unit/check-typeddict.test

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,20 @@ reveal_type(d) # N: Revealed type is "TypedDict('__main__.D', {})"
235235
[builtins fixtures/dict.pyi]
236236
[typing fixtures/typing-typeddict.pyi]
237237

238+
[case testTypedDictDecoratorUndefinedNames]
239+
from typing import TypedDict
240+
241+
@abc # E: Name "abc" is not defined
242+
@efg.hij # E: Name "efg" is not defined
243+
@klm[nop] # E: Name "klm" is not defined \
244+
# E: Name "nop" is not defined
245+
@qrs.tuv[wxy] # E: Name "qrs" is not defined \
246+
# E: Name "wxy" is not defined
247+
class A(TypedDict):
248+
x: int
249+
[builtins fixtures/dict.pyi]
250+
[typing fixtures/typing-typeddict.pyi]
251+
238252
[case testTypedDictWithClassmethodAlternativeConstructorDoesNotCrash]
239253
# https://github.com/python/mypy/issues/5653
240254
from typing import TypedDict

0 commit comments

Comments
 (0)