Skip to content

Add Type Annotations for git_version.py#365

Merged
Callek merged 11 commits intopython-versioneer:masterfrom
Callek:typing
Apr 17, 2023
Merged

Add Type Annotations for git_version.py#365
Callek merged 11 commits intopython-versioneer:masterfrom
Callek:typing

Conversation

@Callek
Copy link
Copy Markdown
Collaborator

@Callek Callek commented Apr 16, 2023

Over in #298 it was suggested we wanted type annotations and that a PR would be welcome.

This PR does roughly the minimum to enable type annotations on git_version.py

If I have further time I'll create new PRs for the rest of the src repo, add typing in tests, as well as do some better Typing in a few places (TypedDict, better typing on the decorators and vcs hooks, etc.)

But in the meantime wanted to submit this.

Additional changes that are not strictly typing:

  • Use exception OSError as e instead of relying on the sys.exc_info to get the exception class. This is ok now that py2.7 is no longer supported [and necessary for better typing since the former method typed it as BaseException which didn't have errno as a property.
  • Supported my local testing on mac (using the linux tox target) by replacing . with _ in the binary wheel name expectation.
  • Converted the class/function definitions in the various files (where # --STRIP DURING BUILD was used) to actual imports that didn't fail the tests. This so that python editors (such as VSCode) gave better type hinting in the various files, without the need to type-hint all the redefinitions themselves

Copy link
Copy Markdown
Contributor

@effigies effigies left a comment

Choose a reason for hiding this comment

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

Thanks for this, and thanks for the offer to maintain. You should have received an invite for write access to the repository, so you should be able to trigger CI on your own once you accept.

Overall LGTM. I would consider adding type checking commands to the tox script, or possibly adding a type-checking environment.

@CallekTest
Copy link
Copy Markdown

Overall LGTM. I would consider adding type checking commands to the tox script, or possibly adding a type-checking environment.

We do have it at least for the git_version.py output. I'll need to add a check for the versioneer.py output in a followup PR.

!pypy3: mypy git_version.py

@Callek
Copy link
Copy Markdown
Collaborator Author

Callek commented Apr 17, 2023

(oops commented with a test account I was using for something else for work)

@Callek Callek merged commit e2d1fc8 into python-versioneer:master Apr 17, 2023
@Callek Callek deleted the typing branch April 17, 2023 20:06
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.

3 participants