326326 make_coro_type,
327327 replace_fallback,
328328 replace_known_sequence_value,
329- set_self,
330329 stringify_object,
331330 tuple_members_from_value,
332331 type_param_to_value,
@@ -3412,14 +3411,6 @@ def _get_instance_only_annotation_value_for_class_key(
34123411 class_key, attr_name
34133412 )
34143413 if match is not None and self._is_instance_only_symbol(match[1].symbol):
3415- symbol = match[1].symbol
3416- if symbol.annotation is not None and any(
3417- isinstance(subval, TypeVarValue) and subval.typevar_param.is_self
3418- for subval in symbol.annotation.walk_values()
3419- ):
3420- return set_self(
3421- symbol.annotation, bound_self_type_from_class_key(class_key)
3422- )
34233414 return match[1].value
34243415 return UNINITIALIZED_VALUE
34253416
@@ -3620,7 +3611,7 @@ def resolve_property(
36203611 if obj.fget is None:
36213612 return UNINITIALIZED_VALUE
36223613
3623- getter = set_self( KnownValue(obj.fget), root_composite.value )
3614+ getter = KnownValue(obj.fget)
36243615 return self.check_call(node, getter, [root_composite])
36253616
36263617 def _can_assign_to_base(
@@ -13867,11 +13858,13 @@ def composite_from_attribute(self, node: ast.Attribute) -> Composite:
1386713858 root_composite = self._get_locally_narrowed_composite(root_composite, node)
1386813859 if self.in_annotation and isinstance(root_composite.value, KnownValue):
1386913860 try:
13870- value = KnownValue( getattr(root_composite.value.val, node.attr) )
13861+ attr_value = getattr(root_composite.value.val, node.attr)
1387113862 except AttributeError:
1387213863 pass
1387313864 else:
13874- return Composite(value, composite, node)
13865+ # Annotation metadata may need the exact runtime object. The
13866+ # normal attribute path can intentionally widen class attrs.
13867+ return Composite(KnownValue(attr_value), composite, node)
1387513868 if self._is_checking():
1387613869 if (
1387713870 isinstance(root_composite.value, KnownValue)
@@ -13888,28 +13881,6 @@ def composite_from_attribute(self, node: ast.Attribute) -> Composite:
1388813881 use_fallback=True,
1388913882 ignore_none=self.options.get_value_for(IgnoreNoneAttributes),
1389013883 )
13891- root_info = _attribute_root_class_info(root_composite.value)
13892- if (
13893- node.attr == "__slots__"
13894- and root_info.is_class_object is True
13895- and root_info.class_key is not None
13896- and (
13897- synthetic_class := self.checker.get_synthetic_class(
13898- root_info.class_key
13899- )
13900- )
13901- is not None
13902- and self._get_declared_symbol_initializer(
13903- synthetic_class.get_type_object(self.checker), "__slots__"
13904- )
13905- is None
13906- ):
13907- self._show_error_if_checking(
13908- node,
13909- f"{root_composite.value} has no attribute {node.attr!r}",
13910- ErrorCode.undefined_attribute,
13911- )
13912- value = AnyValue(AnySource.error)
1391313884 self._check_deprecated_property_getter(node, root_composite.value)
1391413885 self.check_deprecation(node, value)
1391513886 if self._should_use_varname_value(value):
@@ -14489,16 +14460,6 @@ def get_attribute(
1448914460 )
1449014461 if resolved_self_value is None:
1449114462 resolved_self_value = specialized_self_value
14492- if isinstance(root_composite.value, TypeVarValue):
14493- resolved_self_value = root_composite.value
14494- lookup_root_value = root_composite.value.get_fallback_value()
14495- elif isinstance(root_composite.value, SubclassValue) and isinstance(
14496- root_composite.value.typ, TypeVarValue
14497- ):
14498- resolved_self_value = root_composite.value
14499- lookup_root_value = SubclassValue.make(
14500- root_composite.value.typ.get_fallback_value()
14501- )
1450214463 if root_composite.value is NO_RETURN_VALUE:
1450314464 return NO_RETURN_VALUE
1450414465 fallback_root = replace_fallback(root_composite.value)
@@ -14535,8 +14496,6 @@ def get_attribute(
1453514496 # fallback values for regular attribute lookup so attributes.get_attribute()
1453614497 # never receives a MultiValuedValue/IntersectionValue directly.
1453714498 is_type_alias_symbol = _is_type_alias_symbol_composite(root_composite)
14538- if not isinstance(root_composite.value, TypeAliasValue):
14539- is_type_alias_symbol = False
1454014499 if not is_type_alias_symbol:
1454114500 resolved_value = root_composite.value
1454214501 while True:
@@ -14567,13 +14526,6 @@ def get_attribute(
1456714526 use_fallback=use_fallback,
1456814527 record_reads=record_reads,
1456914528 )
14570- if (
14571- subresult is UNINITIALIZED_VALUE
14572- and use_fallback
14573- and node is not None
14574- and not isinstance(subval_basic, IntersectionValue)
14575- ):
14576- subresult = self._get_attribute_fallback(subval, attr, node)
1457714529 subresult = _drop_uninitialized_value(subresult)
1457814530 if (
1457914531 subresult is UNINITIALIZED_VALUE
@@ -14723,12 +14675,6 @@ def _get_attribute_fallback(
1472314675 has_dynamic_getattr = _static_hasattr(root_value.val, "__getattr__")
1472414676 if has_dynamic_getattr and _is_typing_alias_value(root_value.val):
1472514677 has_dynamic_getattr = False
14726- if (
14727- attr == "__slots__"
14728- and isinstance(root_value.val, type)
14729- and self.checker.get_synthetic_class(root_value.val) is not None
14730- ):
14731- has_dynamic_getattr = False
1473214678 if not _has_only_known_attributes(
1473314679 self.checker.ts_finder, root_value.val
1473414680 ) and (has_dynamic_getattr or self._should_ignore_val(node)):
0 commit comments