Skip to content

Add type hints for Repository.branches, Repository.references and Repository.remotes #1384

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

BenediktSeidl
Copy link

After python/typeshed#14141 mypy no longer recognizes Repository.branches, Repository.references and Repository.remotes.

This pull request adds the type hints directly to pygit2.

Maybe it would have been possible to copy the type hints from the typeshed repo, but I'm not sure how this would work out with the licensees. My changes are a independent implementation.

pygit2 was removed from the python typeshed, but the built in types of
pygit2 are not complete.

This change tries to improve this situation, by fixing type errors that
occur when activating typing for the tests.
So first the test functions (for the public API) in test/test_refs.py
were adapted, in order to activate mypy type checking.
Then _pygit2.pyi was adapted to fix those mypy type checking errors.

The skeleton was provided by:
    stubgen -m pygit2.references -o /tmp/pygit2

The following command
    mypy test
returned the following summary before this change:
    Found 289 errors in 10 files (checked 50 source files)
and after this change:
    Found 289 errors in 10 files (checked 50 source files)
The following command
    mypy test
reports
    Found 284 errors in 9 files (checked 50 source files)
after this change.
The following command
    mypy test
reports
    Found 280 errors in 8 files (checked 50 source files)
after this change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant