-
Notifications
You must be signed in to change notification settings - Fork 9
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
Make annotations work #21
Conversation
Codecov Report
@@ Coverage Diff @@
## master #21 +/- ##
==========================================
+ Coverage 95.20% 95.46% +0.26%
==========================================
Files 1 1
Lines 396 419 +23
==========================================
+ Hits 377 400 +23
Misses 19 19
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wow. amazing! very clever with the etree strategy. so you fixed pretty much everything but one that will probably never work, yeah?
I did have to tell Pydantic to allow arbitrary classes as types
where is this done?
It was part of my experiment in typing class Config:
arbitrary_types_allowed = True
@dataclass(config=Config)
class XMLAnnotation... For those arbitrary types, pydantic validates by just checking
Right, but the lack of support for non-positive years in |
ah! I see... sorry i misunderstood. Yeah I've seen that pydantic config setting before.
wow. that's strange... might they be doing something dynamic on import?
lol ok... thanks for this! |
This was straightfoward except for the XMLAnnotation. I wanted to present the "any" XML sub-tree as something usable and not just a stringified serialization that would have to be re-parsed anyway. An xml.etree.ElementTree.Element object is perfect, however I had trouble getting the validation to work with that as the attribute type. I did have to tell Pydantic to allow arbitrary classes as types, but for some reason the isinstance check it does fails mysteriously. I typed it Any just to move on but it's something to revisit later.
I had to disable the mypy warn_unused_ignores setting because it's triggered by
value: Any = _no_default # type: ignore
. With some work on the code generation that could be added back in later.