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: add type hints for rdflib.store and rdflib.plugins.stores #2057

Merged
merged 1 commit into from
Jul 30, 2022

Conversation

aucampia
Copy link
Member

@aucampia aucampia commented Jul 28, 2022

Summary of changes

Add type hints and aliases for rdflib.store and
rdflib.plugins.stores and also add a couple of more type hints and
aliases to rdflib.graph.

This PR contains no runtime changes.

Other changes:

  • Changed some imports to be more specific (e.g. import from rdflib.graph instead of import from rdflib). This is to reduce
    the probability of circular imports.
  • Ignore E231 (missing whitespace after ',') in flake8 as black is
    managing the whitespaces and seems to be bumping heads with flake8
    with spaces after , sometimes.
  • Install berkeleydb-stubs when doing extensive testing with tox.
  • Added devtools/diffrtpy.py which is a script that can be used with
    git difftool to generate compact diffs for python code. This should
    make it a lot easier to review PRs that change type hints to verify
    that they don't have a runtime impact.

Compact diff: https://gist.github.com/aucampia/3f380070fbd8f0e8a99aea2df6cc1f06

Checklist

  • Checked that there aren't other open pull requests for
    the same change.
  • Added tests for any changes that have a runtime impact.
  • Checked that all tests and type checking passes.
  • For changes that have a potential impact on users of this project:
    • Considered updating our changelog (CHANGELOG.md).
  • Considered granting push permissions to the PR branch,
    so maintainers can fix minor issues and keep your PR up to date.

@coveralls
Copy link

coveralls commented Jul 28, 2022

Coverage Status

Coverage decreased (-0.05%) to 90.439% when pulling 16d9618 on aucampia:iwana-20220728T1941-store_typing into ff41218 on RDFLib:master.

@aucampia
Copy link
Member Author

I will publish this tomorrow, I'm writing a script to diff python source code with type hints and comments removed, so it is easier to review these PRs.

@aucampia aucampia force-pushed the iwana-20220728T1941-store_typing branch 2 times, most recently from 8303d8e to 97c686f Compare July 29, 2022 00:57
@aucampia
Copy link
Member Author

@aucampia aucampia marked this pull request as ready for review July 29, 2022 01:08
@aucampia aucampia requested a review from a team July 29, 2022 01:08
@aucampia
Copy link
Member Author

@ajnelson-nist @mielvds tagging you in case you have time to review.

@aucampia aucampia added the type hints Relating to type hints or type aliases label Jul 29, 2022
@ajnelson-nist
Copy link
Contributor

@aucampia : I don't really have experience with this area in the code, so I don't have cogent feedback aside from noticing a documentation typo.

@aucampia aucampia force-pushed the iwana-20220728T1941-store_typing branch from 97c686f to 5d05b96 Compare July 29, 2022 15:27
@aucampia aucampia added the review wanted This indicates that the PR is ready for review label Jul 29, 2022
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, will be v. useful for ADR

Add type hints and aliases for `rdflib.store` and
`rdflib.plugins.stores` and also add a couple of more type hints and
aliases to `rdflib.graph`.

This PR contains no runtime changes.

Other changes:
- Changed some imports to be more specific (e.g. `import from
  rdflib.graph` instead of `import from rdflib`). This is to reduce
  the probability of circular imports.
- Ignore `E231` (missing whitespace after ',') in flake8 as black is
  managing the whitespaces and seems to be bumping heads with flake8
  with spaces after `,` sometimes.
- Install `berkeleydb-stubs` when doing extensive testing with tox.
- Added `devtools/diffrtpy.py` which is a script that can be used with
  `git difftool` to generate compact diffs for python code. This should
  make it a lot easier to review PRs that change type hints to verify
  that they don't have a runtime impact.
@aucampia aucampia force-pushed the iwana-20220728T1941-store_typing branch from 5d05b96 to 16d9618 Compare July 29, 2022 20:38
@aucampia aucampia merged commit 283bef2 into RDFLib:master Jul 30, 2022
@aucampia aucampia deleted the iwana-20220728T1941-store_typing branch April 9, 2023 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review wanted This indicates that the PR is ready for review type hints Relating to type hints or type aliases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants