File tree 2 files changed +21
-4
lines changed 2 files changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -808,9 +808,13 @@ def check_method_override_for_base_with_name(
808
808
# Map the overridden method type to subtype context so that
809
809
# it can be checked for compatibility.
810
810
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 )
814
818
if isinstance (original_type , FunctionLike ):
815
819
original = map_type_from_supertype (
816
820
method_type (original_type ),
@@ -824,7 +828,6 @@ def check_method_override_for_base_with_name(
824
828
base .name (),
825
829
defn )
826
830
else :
827
- assert original_type is not None
828
831
self .msg .signature_incompatible_with_supertype (
829
832
defn .name (), name , base .name (), defn )
830
833
Original file line number Diff line number Diff line change @@ -1002,6 +1002,20 @@ main:1: note: In module imported here:
1002
1002
tmp/a.py:3: error: Argument 1 to "dec" has incompatible type "int"; expected "str"
1003
1003
tmp/a.py:5: error: "str" not callable
1004
1004
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
+
1005
1019
1006
1020
-- Conditional function definition
1007
1021
-- -------------------------------
You can’t perform that action at this time.
0 commit comments