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
Add tests to confirm detection of various integer types #122
Conversation
This list of integer types was drawn from OWL 2. At the time of this test's initial implementation, only the lexical error in `"zero"^^xsd:integer` was detected. References: * The general style of this test was adapted from `/test/test_extra.py`. Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
@ashleysommer , I don't intend for this to block your plans to do a release soon. |
@ashleysommer , in light of v0.19.0 being a 1.0.0 Release Candidate, I suggest this PR get a closer look due to missing some validation issues. I also just caught a few copy-paste errors, will correct in a moment with a follow-on patch. |
The third test in test_integers.py now constructs Literal objects for a strict set-equivalence of expected failing path-value pairs. However, it's not clear whether these Literals should have been constructible with rdflib, so this patch might revert significantly. References: * RDFLib/rdflib#1757 Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
It looks like discussion of how to resolve this PR should be anchored upstream, on RDFLib Issue 1757. |
The upstream issue is now closed, but an API was introduced to expose the not-well-formed literals. The present PR should probably wait for the next release of RDFLib. |
@ashleysommer , I stumbled across a data XPASS today that reminded me about this open issue. It looks like there is still a pause on this while waiting for the next I'm trying to define a shape on a property that has What I have now is the following, which doesn't throw a validation error on passing in ex:my-shape
a sh:PropertyShape ;
sh:datatype xsd:positiveInteger ;
sh:nodeKind sh:Literal ;
sh:path ex:my-property ;
sh:targetSubjectsOf ex:my-property ;
. I figure I can get the important bit about needing to be >=1 across with ex:my-shape sh:minInclusive "1"^^xsd:positiveInteger . Or: ex:my-shape sh:minInclusive "1"^^xsd:integer . |
Sorry, I forgot about this PR, and I didn't see your typing question above. You're right, to emulate Consider, in Turtle, numerals are implicitly HOWEVER, RDFlib v6.2.0 has been out for a few weeks, and has the new ill-typed literals feature. I have just released a new version of PySHACL (v0.20.0) that takes advantage of this feature when evaluating Note also, RDFLib v6.2.0 has added a new check for In regard to the release candidate, that was a little premature. v0.19.x is no longer a release candidate, some big changes were implemented with the move to RDFLib v6.2.0, so the new PySHACL v0.20.0 is the new release candidate. |
With this, `test_integers.py` passes `mypy --strict`. Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
Hi @ashleysommer , Apologies for the delayed reply, I was on annual leave. Thanks for integrating the ill-typed literals feature. Unfortunately, I'm not quite sure how to use it. I would still like this PR to be eventually be merged because the unit test will serve as a demonstration of triggering and detecting the errors. I think the test still needs a little more development to take care of what I'm not clear on. I believe something between |
fix sh.path to sh.resultPath in integers test
I'm not sure I'm following. What kind of error are you expecting? As-of PySHACL v0.20.0 (and RDFLib v6.2.0) the units tests you contributed now pass. PySHACL now detects the ill-typed literals when executing the Note, you'll notice my commit in this thread above, I needed to make one tiny correction to the third test in the file, to enable it to search the validation graph for the correct
It is in the textual definition of the
Before RDFLIb v6.2.0 was released, PySHACL had no way to determine if a Literal was ill-typed (beyond some crude string, int and float checks). That is why it these tests were not able to pass before now. But since RDFLib v6.2.0 was released, PySHACL can now take advantage of the new ill-typed Literal test and incorporates that check into the Thank you for your contribution of this unit test. |
Huh. I'm not sure why that test was still failing on my laptop yesterday, but it does indeed pass on my laptop now. Apologies for the confusion. Thank you for working through this with me, and for the spec. citation! |
This patch series will add tests to confirm behaviors of XSD integer types aside from
xsd:integer
. It stems from trying to test a sample with a literal"0"^^xsd:positiveInteger
and not receiving an error.It is not entirely clear to me if corrections from this patch series should be in pySHACL or upstream in RDFLib.