You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When type_designators are used on a slot s, pythongen can inject an additional attribute unknown_s into the post_init. This generally doesn't cause issues but can be confusing if an object is introspected with vars.
This can be seen on the current compliance tests for type_designator. The test passes, but can be seen in the generated class: tests/test_compliance/output/test_designates_type/Rstring/generated/python_dataclasses.py:
def__post_init__(self, *_: List[str], **kwargs: Dict[str, Any]):
self.type=str(self.class_name)
super().__post_init__(**kwargs)
self.unknown_type=str(self.class_name)
def__new__(cls, *args, **kwargs):
type_designator="type"ifnottype_designatorinkwargs:
returnsuper().__new__(cls,*args,**kwargs)
else:
type_designator_value=kwargs[type_designator]
target_cls=cls._class_for("class_name", type_designator_value)
iftarget_clsisNone:
raiseValueError(f"Wrong type designator value: class {cls.__name__} "f"has no subclass with ['class_name']='{kwargs[type_designator]}'")
returnsuper().__new__(target_cls,*args,**kwargs)
The text was updated successfully, but these errors were encountered:
cmungall
added a commit
to linkml/linkml-owl
that referenced
this issue
May 13, 2024
When type_designators are used on a slot
s
, pythongen can inject an additional attributeunknown_s
into the post_init. This generally doesn't cause issues but can be confusing if an object is introspected withvars
.This can be seen on the current compliance tests for type_designator. The test passes, but can be seen in the generated class:
tests/test_compliance/output/test_designates_type/Rstring/generated/python_dataclasses.py
:The text was updated successfully, but these errors were encountered: