@@ -2147,16 +2147,11 @@ def check_method_override_for_base_with_name(
2147
2147
# it can be checked for compatibility.
2148
2148
original_type = get_proper_type (base_attr .type )
2149
2149
original_node = base_attr .node
2150
- always_allow_covariant = False
2151
- if is_settable_property (defn ) and (
2152
- is_settable_property (original_node ) or isinstance (original_node , Var )
2153
- ):
2154
- if is_custom_settable_property (defn ) or (is_custom_settable_property (original_node )):
2155
- always_allow_covariant = True
2156
- self .check_setter_type_override (defn , base_attr , base )
2157
2150
# `original_type` can be partial if (e.g.) it is originally an
2158
2151
# instance variable from an `__init__` block that becomes deferred.
2152
+ supertype_ready = True
2159
2153
if original_type is None or isinstance (original_type , PartialType ):
2154
+ supertype_ready = False
2160
2155
if self .pass_num < self .last_pass :
2161
2156
# If there are passes left, defer this node until next pass,
2162
2157
# otherwise try reconstructing the method type from available information.
@@ -2179,6 +2174,19 @@ def check_method_override_for_base_with_name(
2179
2174
else :
2180
2175
# Will always fail to typecheck below, since we know the node is a method
2181
2176
original_type = NoneType ()
2177
+
2178
+ always_allow_covariant = False
2179
+ if is_settable_property (defn ) and (
2180
+ is_settable_property (original_node ) or isinstance (original_node , Var )
2181
+ ):
2182
+ if is_custom_settable_property (defn ) or (is_custom_settable_property (original_node )):
2183
+ # Unlike with getter, where we try to construct some fallback type in case of
2184
+ # deferral during last_pass, we can't make meaningful setter checks if the
2185
+ # supertype is not known precisely.
2186
+ if supertype_ready :
2187
+ always_allow_covariant = True
2188
+ self .check_setter_type_override (defn , base_attr , base )
2189
+
2182
2190
if isinstance (original_node , (FuncDef , OverloadedFuncDef )):
2183
2191
original_class_or_static = original_node .is_class or original_node .is_static
2184
2192
elif isinstance (original_node , Decorator ):
0 commit comments