File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -808,9 +808,13 @@ def check_method_override_for_base_with_name(
808808 # Map the overridden method type to subtype context so that
809809 # it can be checked for compatibility.
810810 original_type = base_attr .type
811- if original_type is None and isinstance (base_attr .node ,
812- FuncDef ):
813- original_type = self .function_type (base_attr .node )
811+ if original_type is None :
812+ if isinstance (base_attr .node , FuncDef ):
813+ original_type = self .function_type (base_attr .node )
814+ elif isinstance (base_attr .node , Decorator ):
815+ original_type = self .function_type (base_attr .node .func )
816+ else :
817+ assert False , str (base_attr .node )
814818 if isinstance (original_type , FunctionLike ):
815819 original = map_type_from_supertype (
816820 method_type (original_type ),
@@ -824,7 +828,6 @@ def check_method_override_for_base_with_name(
824828 base .name (),
825829 defn )
826830 else :
827- assert original_type is not None
828831 self .msg .signature_incompatible_with_supertype (
829832 defn .name (), name , base .name (), defn )
830833
Original file line number Diff line number Diff line change @@ -1002,6 +1002,20 @@ main:1: note: In module imported here:
10021002tmp/a.py:3: error: Argument 1 to "dec" has incompatible type "int"; expected "str"
10031003tmp/a.py:5: error: "str" not callable
10041004
1005+ [case testUndefinedDecoratorInImportCycle]
1006+ # cmd: mypy -m foo.base
1007+ [file foo/__init__.py]
1008+ import foo.base
1009+ class Derived(foo.base.Base):
1010+ def method(self) -> None: pass
1011+ [file foo/base.py]
1012+ import foo
1013+ class Base:
1014+ @decorator
1015+ def method(self) -> None: pass
1016+ [out]
1017+ tmp/foo/base.py:3: error: Name 'decorator' is not defined
1018+
10051019
10061020-- Conditional function definition
10071021-- -------------------------------
You can’t perform that action at this time.
0 commit comments