feat: more type hints for rdflib.plugins.sparql
by aucampia · Pull Request #2268 · RDFLib/rdflib (original) (raw)
Summary of changes
A bit of a roundabout reason why this matters now, but basically:
I want to add examples for securing RDFLib with sys.addaudithook
and urllib.request.install_opener
. I also want to be sure examples are actually valid, and runnable, so I was adding static analysis and simple execution of examples to our CI.
During this I noticed that examples use initBindings
with Dict[str,...]
, which was not valid according to mypy, but then after some investigation I realized the type hints in some places were too strict.
So the main impetus for this is actually to relax the type hints in rdflib.graph
, but to ensure this is valid I'm adding a bunch of type hints I had saved up to rdflib.plugins.sparql
.
Even though this PR looks big, it has no runtime changes, as can be seen from the compact diff here.
Checklist
- Checked that there aren't other open pull requests for
the same change. - Checked that all tests and type checking passes.
- Considered granting push permissions to the PR branch,
so maintainers can fix minor issues and keep your PR up to date.