-
Notifications
You must be signed in to change notification settings - Fork 2
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
Fix utils.parse_object() #46
Conversation
…ing tests. Reduced code dublication. Hopefully addressed comments by Thomas in PR #44
Codecov ReportBase: 74.25% // Head: 74.69% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #46 +/- ##
==========================================
+ Coverage 74.25% 74.69% +0.43%
==========================================
Files 12 12
Lines 703 727 +24
==========================================
+ Hits 522 543 +21
- Misses 181 184 +3
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
tests/test_utils.py
Outdated
@@ -20,6 +20,47 @@ | |||
assert infer_iri(coll.meta) == coll.meta.uri | |||
assert infer_iri(coll) == coll.uuid | |||
|
|||
# We have no dependencies on pydantic, hence don't assume that it is installed |
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.
A good starting point could be to use (or expand on) this datamodel: https://github.com/SINTEF/soft7/blob/main/s7/pydantic_models/soft7.py
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.
OK, I renamed uri
to identity
in the test. With that it seems that we are pretty much matching the soft7 datamodel.
However, it is confusing and not very useful to have two different names for the same thing in soft7 and dlite. I have nothing in principle against updating dlite, but it would take several hours to change uri
to identity
allover dlite when also keeping backward compatibility. It is time I don't have. Great if someone would like to do it, otherwise I would suggest to update soft7 instead.
try: | ||
from pydantic import AnyUrl, BaseModel, Field | ||
except ImportError: | ||
pass |
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.
Try to avoid except pass - they are notoriously difficult to reason about
) | ||
# Format not supported in Python < 3.11 |
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.
Remove commented-out code
@@ -112,7 +158,5 @@ def h(): | |||
assert parse_object(XSD.int) == XSD.int | |||
assert parse_object(f'"42"^^{XSD.integer}') == Literal("42", datatype=XSD.integer) | |||
assert parse_object(f'"4.2"^^{XSD.double}') == Literal("4.2", datatype=XSD.double) | |||
|
|||
# __FIXME__: parse_object() currently fails for the following cases: |
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.
Remove commented-out code
Closes #45
General cleanup
__eq__()
and__hash__()
methods to Literal. The__eq__()
method is required for proper testing...