-
Notifications
You must be signed in to change notification settings - Fork 560
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
there is no use-case of comparing a Literal with None (I think) #1155
base: main
Are you sure you want to change the base?
there is no use-case of comparing a Literal with None (I think) #1155
Conversation
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.
In my eyes this is ok. The instance check will return False for None and thus we will end at NotImplemented or False in the case of equals, which is good. As we are heading towards a major release breaking changes are ok.
@ashleysommer and I talked about this sort of thing at our last meeting a couple of weeks back. Ashley, what did we decide here? |
We discussed the merits of storing However, that is not related to this Issue/PR. The only thing I can see this is a maybe problem here is the possibility of breaking Literal Total Ordering. Given that feature is only concerned with comparing As @white-gecko said, this is a breaking change. Users with code which expects |
I would expect a https://github.com/RDFLib/rdflib/blob/master/rdflib/plugins/sparql/operators.py#L857 Interestingly raising a |
On a somewhat related note, I have yet to understand when SPAQRL is supposed to throw an error and when silently just return an empty literal. For example Pointers on the expected behaviour are welcome as I would like to do some refactoring on the sparql evaluation :) [with this MR being the first step] |
In case of
In the "XPath and XQuery Functions and Operators 3.1" Recommendation there is a statement about errors: https://www.w3.org/TR/xpath-functions/#errors-and-diagnostics also some functions have Also for the operators I think to be sure it is necessary to dive into the XPath specs: https://www.w3.org/TR/sparql11-query/#OperatorMapping |
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.
Can we change this to throw TypeError()
when trying to compare Literal to None? Seems like that is the correct solution.
@@ -1041,7 +1037,8 @@ def __eq__(self, other): | |||
""" | |||
if self is other: | |||
return True | |||
if other is None: | |||
|
|||
if other is None: |
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.
Whats going on with the indentation here? This line is offset by two spaces?
This is somewhat of a question: What is the use-case of comparing a
Literate
instance toNone
? I didn't find any, so I removed the checks from the comparing functions and all tests still passed.