-
Notifications
You must be signed in to change notification settings - Fork 561
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
Widen Graph.__contains__
type hint
#2323
Conversation
These aren't used or referenced anywhere.
Paths are valid as the second argument of the triple here, as ultimately the triples method is called, which accepts either a predicate or a Path.
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.
Thanks for the pull request, it looks good to me. I will merge this before Monday.
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.
lgtm 👍
It looks like there was a problem with Read the Docs when building docs, which has it stuck in 'pending' in Github. It doesn't look related to the change, and says 'please try again later': I don't believe I have permission to kick off the docs build again. Is this the key blocker for merging? If so, could someone trigger the docs build again? No major rush from my side, just wanted to make sure the docs build showing as stuck in 'pending' wasn't going to halt progress towards merging. Thanks for your help! |
It is unrelated, I just had a bit of a busy weekend. Merging this now. |
ah no problem - sorry for bothering you then, didn't mean to rush you. Thanks for merging! |
Summary of changes
The typing on
Graph.__contains__
doesn't currently allowrdflib.paths.Path
s in the predicate position of the triple argument, even though the implementation supports this (it calls thetriple
method, which is type hinted to acceptPath
s and handles them fine). This can cause mypy errors for rdflib users on valid code. Minimal repro:gives a mypy error:
which goes away after the change in this PR.
Occurence in my codebase here that triggers the above error (although some context is required to see why, I just wanted to point out that this was a real problem I faced and had to add a # type: ignore for, not just a hypothetical).
I also removed some commented out type hints that aren't used or referenced anywhere while I was staring at them - this looked like useful cleanup but let me know if it isn't and I'll happily remove the commit from the PR.
Thanks for rdflib, and for adding (and distributing) the type hints!
Checklist
the same change.
./examples
for new features.CHANGELOG.md
).so maintainers can fix minor issues and keep your PR up to date.