File tree Expand file tree Collapse file tree 1 file changed +15
-10
lines changed Expand file tree Collapse file tree 1 file changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -838,16 +838,21 @@ def adjust_generator_classes_of_methods(mapper: Mapper) -> None:
838838 precise_ret_type = True
839839 if fn_ir .class_name is not None :
840840 class_ir = mapper .type_to_ir [fdef .info ]
841- for s in class_ir .subclasses ():
842- if name in s .method_decls :
843- m = s .method_decls [name ]
844- if (
845- m .is_generator != fn_ir .is_generator
846- or m .is_coroutine != fn_ir .is_coroutine
847- ):
848- # Override is of a different kind, and the optimization
849- # to use a precise generator return type doesn't work.
850- precise_ret_type = False
841+ subcls = class_ir .subclasses ()
842+ if subcls is None :
843+ # Override could be of a different type, so we can't make assumptions.
844+ precise_ret_type = False
845+ else :
846+ for s in subcls :
847+ if name in s .method_decls :
848+ m = s .method_decls [name ]
849+ if (
850+ m .is_generator != fn_ir .is_generator
851+ or m .is_coroutine != fn_ir .is_coroutine
852+ ):
853+ # Override is of a different kind, and the optimization
854+ # to use a precise generator return type doesn't work.
855+ precise_ret_type = False
851856 else :
852857 class_ir = None
853858
You can’t perform that action at this time.
0 commit comments