We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
This replaces:
It looks like there are some situations where foward ref detection falsely assumes no forward reference when it should use one
This is because _sort_classes is applied prior to writing classes, but the following code operates over the asserted sort order
_sort_classes
linkml/linkml/generators/pythongen.py
Lines 921 to 938 in 5ecd9c4
this replicates the issue:
id: http://example.org/issue-1168 name: issue_1168 description: Tests forward reference edge case see_also: - https://github.com/linkml/linkml/issues/1168 classes: C: is_a: D attributes: d: range: D D: attributes: c: range: C
the order becomes D, C:
@dataclass class D(YAMLRoot): _inherited_slots: ClassVar[List[str]] = [] class_class_uri: ClassVar[URIRef] = URIRef("http://example.org/issue-1168/D") class_class_curie: ClassVar[str] = None class_name: ClassVar[str] = "D" class_model_uri: ClassVar[URIRef] = URIRef("http://example.org/issue-1168/D") c: Optional[Union[dict, C]] = None ... @dataclass class C(D):
which yields
NameError: name 'C' is not defined
The workaround is to order elements with your schema accordingly, but this should not be necessary
The text was updated successfully, but these errors were encountered:
Note: an alternative approach here is simply to record when a class definition is written, and always forward ref if it has not been written
Sorry, something went wrong.
WIP: forward reference bug.
2948a85
When this PR is merged, it fixes #1168
hsolbrig
Successfully merging a pull request may close this issue.
This replaces:
It looks like there are some situations where foward ref detection falsely assumes no forward reference when it should use one
This is because
_sort_classes
is applied prior to writing classes, but the following code operates over the asserted sort orderlinkml/linkml/generators/pythongen.py
Lines 921 to 938 in 5ecd9c4
this replicates the issue:
the order becomes D, C:
which yields
The workaround is to order elements with your schema accordingly, but this should not be necessary
The text was updated successfully, but these errors were encountered: