File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -255,6 +255,14 @@ def add_child(self, obj: "Object") -> None: # noqa: WPS231 (not complex)
255255 elif isinstance (obj , Method ):
256256 self .methods .append (obj ) # type: ignore
257257 elif isinstance (obj , Attribute ):
258+ # Dataclass attributes with default values will already be present in `self.attributes` as they are
259+ # resolved differently by the python interpreter. Aas they have a concrete value, they are already present
260+ # in the "original" class. They should be overridden with the new "dataclass" attribute coming in here
261+ # (having the "dataclass_field" property set)
262+ new_attribute_name = obj .name
263+ for attribute in self .attributes :
264+ if attribute .name == new_attribute_name :
265+ self .attributes .remove (attribute )
258266 self .attributes .append (obj ) # type: ignore
259267 obj .parent = self
260268
You can’t perform that action at this time.
0 commit comments