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 parser type hints #2232

Merged

Conversation

aucampia
Copy link
Member

@aucampia aucampia commented Feb 20, 2023

Summary of changes

Add type hints to:

  • rdflib/parser.py
  • rdflib/plugins/parser/*.py
  • some JSON-LD utils
  • rdflib/exceptions.py.

This is mainly because the work I'm doing to fix
#1844 is touching some of this parser stuff and the type hints are useful to avoid mistakes.

No runtime changes are included in this PR.

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.

@aucampia
Copy link
Member Author

aucampia commented Feb 20, 2023

A compact diff with all non-runtime content (e.g. comments, type-hints) stripped out can be found here: https://gist.github.com/aucampia/91e1bfb27351ebd63c3285d052a34d7e#file-compact-diff

Generated with:

20230220T204956 iwana@teekai.zoic.eu.org:~/sw/d/github.com/iafork/rdflib.reviews
$ git log -1
commit db682801f0b2a3a05cbe8e9c33a93911e6103a04 (HEAD -> iwana-20230220T2005-add_parser_typing)
Author: Iwan Aucamp <aucampia@gmail.com>
Date:   Mon Feb 20 19:36:30 2023 +0000

    feat: add parser type hints
    
    Add type hints to `rdflib/plugins/parser/*.py` and JSON-LD utils.
    
    This is mainly because the work I'm doing to fix
    <https://github.com/RDFLib/rdflib/issues/1844> is touching some of this
    parser stuff and the type hints are useful to avoid mistakes.
20230220T204958 iwana@teekai.zoic.eu.org:~/sw/d/github.com/iafork/rdflib.reviews
$ git status
On branch iwana-20230220T2005-add_parser_typing
Your branch and 'origin/iwana-20230220T2005-add_parser_typing' have diverged,
and have 1 and 1 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)

nothing to commit, working tree clean
20230220T205000 iwana@teekai.zoic.eu.org:~/sw/d/github.com/iafork/rdflib.reviews
$ PYLOGGING_LEVEL=INFO task run -- git difftool -y -x $(readlink -f devtools/diffrtpy.py) upstream/main > /var/tmp/compact.diff
task: [venv:run] poetry run git difftool -y -x /home/iwana/sw/d/github.com/iafork/rdflib.reviews/devtools/diffrtpy.py upstream/main

@aucampia aucampia force-pushed the iwana-20230220T2005-add_parser_typing branch from 90baf7a to db68280 Compare February 20, 2023 19:50
@aucampia aucampia marked this pull request as ready for review February 20, 2023 19:54
@aucampia aucampia requested a review from a team February 20, 2023 19:54
@coveralls
Copy link

coveralls commented Feb 20, 2023

Coverage Status

Coverage: 90.696% (+0.01%) from 90.682% when pulling a3bf7bd on aucampia:iwana-20230220T2005-add_parser_typing into d2c9edc on RDFLib:main.

@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 Feb 20, 2023
@aucampia aucampia force-pushed the iwana-20230220T2005-add_parser_typing branch 2 times, most recently from 8dc5b98 to bdde0e8 Compare February 20, 2023 21:16
Add type hints to:
- `rdflib/parser.py`
- `rdflib/plugins/parser/*.py`
- some JSON-LD utils
- `rdflib/exceptions.py`.

This is mainly because the work I'm doing to fix
<RDFLib#1844> is touching some of
this parser stuff and the type hints are useful to avoid mistakes.

No runtime changes are included in this PR.
@aucampia aucampia force-pushed the iwana-20230220T2005-add_parser_typing branch from bdde0e8 to a3bf7bd Compare February 20, 2023 21:23
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.

heroic! double-plus good

@aucampia aucampia merged commit 123edf5 into RDFLib:main Mar 5, 2023
@aucampia aucampia deleted the iwana-20230220T2005-add_parser_typing 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.

None yet

2 participants