File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -936,12 +936,16 @@ def analyze_var(
936936 ):
937937 # Unwrap nonmember similar to class-level access
938938 result = p_result .args [0 ]
939+ dataclass_metadata = var .info .metadata .get ("dataclass" , {})
940+ is_dataclass_field = any (
941+ attribute .get ("name" ) == name for attribute in dataclass_metadata .get ("attributes" , [])
942+ )
939943 # A read-only property has already applied descriptor access to its getter
940- # result. Settable properties may represent dataclass-transform descriptors,
941- # which still require the normal descriptor access on instance reads.
944+ # result. Dataclass fields are represented as synthetic properties, but
945+ # their descriptor access still needs to happen on instance reads.
942946 if (
943947 result
944- and not (var .is_property and not var .is_settable_property )
948+ and not (var .is_property and not var .is_settable_property and not is_dataclass_field )
945949 and not (implicit or var .info .is_protocol and is_instance_var (var ))
946950 ):
947951 result = analyze_descriptor_access (result , mx )
You can’t perform that action at this time.
0 commit comments