@@ -842,10 +842,13 @@ def analyze_func_def(self, defn: FuncDef) -> None:
842
842
# Mark protocol methods with empty bodies and None-incompatible return types as abstract.
843
843
if self .is_class_scope () and defn .type is not None :
844
844
assert self .type is not None and isinstance (defn .type , CallableType )
845
- if (not self .is_stub_file and self .type .is_protocol and
846
- (not isinstance (self .scope .function , OverloadedFuncDef )
847
- or defn .is_property ) and
848
- not can_be_none (defn .type .ret_type ) and is_trivial_body (defn .body )):
845
+ if (
846
+ not self .is_stub_file
847
+ and self .type .is_protocol
848
+ and (not isinstance (self .scope .function , OverloadedFuncDef ) or defn .is_property )
849
+ and not can_be_none (defn .type .ret_type )
850
+ and is_trivial_body (defn .body )
851
+ ):
849
852
defn .is_abstract = True
850
853
851
854
if (
@@ -6110,7 +6113,7 @@ def can_be_none(t: Type) -> bool:
6110
6113
"""Can a variable of the given type be None?"""
6111
6114
t = get_proper_type (t )
6112
6115
return (
6113
- isinstance (t , NoneType ) or
6114
- isinstance (t , AnyType ) or
6115
- (isinstance (t , UnionType ) and any (can_be_none (ut ) for ut in t .items ))
6116
+ isinstance (t , NoneType )
6117
+ or isinstance (t , AnyType )
6118
+ or (isinstance (t , UnionType ) and any (can_be_none (ut ) for ut in t .items ))
6116
6119
)
0 commit comments