diff --git a/mypy/semanal.py b/mypy/semanal.py index d944c60cd16e4..f718a0b4f6a10 100644 --- a/mypy/semanal.py +++ b/mypy/semanal.py @@ -2113,6 +2113,8 @@ def analyze_typeddict_classdef(self, defn: ClassDef) -> bool: and not has_placeholder(defn.info.typeddict_type) ): # This is a valid TypedDict, and it is fully analyzed. + for decorator in defn.decorators: + decorator.accept(self) return True is_typeddict, info = self.typed_dict_analyzer.analyze_typeddict_classdef(defn) if is_typeddict: diff --git a/test-data/unit/check-typeddict.test b/test-data/unit/check-typeddict.test index 43fcf13e7be17..261a32e692a97 100644 --- a/test-data/unit/check-typeddict.test +++ b/test-data/unit/check-typeddict.test @@ -235,6 +235,20 @@ reveal_type(d) # N: Revealed type is "TypedDict('__main__.D', {})" [builtins fixtures/dict.pyi] [typing fixtures/typing-typeddict.pyi] +[case testTypedDictDecoratorUndefinedNames] +from typing import TypedDict + +@abc # E: Name "abc" is not defined +@efg.hij # E: Name "efg" is not defined +@klm[nop] # E: Name "klm" is not defined \ + # E: Name "nop" is not defined +@qrs.tuv[wxy] # E: Name "qrs" is not defined \ + # E: Name "wxy" is not defined +class A(TypedDict): + x: int +[builtins fixtures/dict.pyi] +[typing fixtures/typing-typeddict.pyi] + [case testTypedDictWithClassmethodAlternativeConstructorDoesNotCrash] # https://github.com/python/mypy/issues/5653 from typing import TypedDict