-
-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
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
XML Schema restrictions are not reflected within __dataclass_fields__ due to inheritance #854
Comments
When a restriction is set, the ideal situation for the datamodel would be that only the properties that fall under the restriction are available. From https://www.reddit.com/r/learnpython/comments/12qhzi6/dataclasses_with_inheritance/ I found that kw_only was used to resolve the issue with non-default argument 'class name' follows default argument.
Important comment: |
Hey @skinkie can you please provide a simple example of the behavior that needs to change? I am sorry netex is too complicated to follow. |
I think I already have an example schema somewhere. I'll try to post it tonight. |
Needed to be a bit more creative. As you can see from the (valid) XML example test3 is not allowed in the output. But the attribute version is correctly inherited. This has been described by O'Reilly. xsdata (current version) incorrently inherits test3, while it is not part of the restriction, thus should not be part of the final object. |
Our options here are
|
RestrictedVar looks nice :-) Should I reuse is_prohibited, instead of my introduction of is_null? |
the |
Hrm my suggestion doesn't work either mypy complaints with
|
I have yesterday encountered a situation where there was a presumable recursive definition of an object. NeTEx-CEN/NeTEx#526 I have learned this definitionis actually prevented by an XML Schema restriction, which implicitly removes the fields that are not in use. xsData seems to do the right job, but for anyone that is using inspection on the dataclasses is faced with inheritance from the subsitutionGroup.
Is transformed into:
But the effect when looking at AlternativeText.dataclass_fields still include the fields outside the restriction inhereted via VersionedChildStructure:
I have been naively started to experiment if there was a clean way to clear the upstream inheritance, which was surprisingly simple. By just setting the already created field to None, dataclass_fields would ignore it.
The text was updated successfully, but these errors were encountered: