Skip to content
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

feat: more type hints for rdflib.plugins.sparql #2268

Merged
merged 1 commit into from
Mar 12, 2023

Conversation

aucampia
Copy link
Member

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.

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.
@aucampia aucampia force-pushed the iwana-20230312T1355-type_sparql branch from 911d3a3 to 176d4d3 Compare March 12, 2023 13:23
@coveralls
Copy link

Coverage Status

Coverage: 90.782% (+0.02%) from 90.759% when pulling 176d4d3 on aucampia:iwana-20230312T1355-type_sparql into a44bd99 on RDFLib:main.

@aucampia aucampia marked this pull request as ready for review March 12, 2023 13:32
@aucampia aucampia added review wanted This indicates that the PR is ready for review ready to merge The PR will be merged soon if no further feedback is provided. labels Mar 12, 2023
@aucampia aucampia merged commit 7a7cc1f into RDFLib:main Mar 12, 2023
@aucampia aucampia deleted the iwana-20230312T1355-type_sparql branch April 9, 2023 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready to merge The PR will be merged soon if no further feedback is provided. review wanted This indicates that the PR is ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants