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

Run Pyright & begin adding type annotations #1020

Merged
merged 25 commits into from
Aug 23, 2023
Merged

Conversation

richardm-stripe
Copy link
Contributor

@richardm-stripe richardm-stripe commented Aug 21, 2023

Summary

This PR begins to add type annotations to the library. The goal is a minimal amount of changes to to get pyright running and typechecking the library in CI with zero errors.

We add a py.typed to the repo but NOT to the package_data property of setup.py. This should ensure that the type annotations in the library don't get picked up by user typecheckers yet (we're not ready yet! we'll get there) but allows us to test our own library for consistency in CI.

We do, however, add typing_extensions as a dependency to the library. We don't take adding dependencies lightly, but
this dependency is inescapable as we still target python 3.6, and are planning on using fairly recent type system features (Unpack for typed **kwargs). This dependency is lightweight and seems very common.

For now, the library is still compatible with typing_extensions > 3.7.2 but this will narrow as we make use of newer type features.

Please let us know here on Github if you experience any problems as a result of this new dependency.

* Puts __getattr_ behind `if not TYPE_CHECKING`
* Add mypy.ini and py.typed
@richardm-stripe richardm-stripe force-pushed the richard-wip branch 3 times, most recently from dfdad3f to 56dab4c Compare August 21, 2023 19:02
stripe/oauth.py Outdated Show resolved Hide resolved
@richardm-stripe richardm-stripe marked this pull request as ready for review August 23, 2023 16:08
@richardm-stripe richardm-stripe requested review from pakrym-stripe and a team August 23, 2023 16:08
setup.py Outdated Show resolved Hide resolved
setup.py Outdated Show resolved Hide resolved
setup.py Outdated Show resolved Hide resolved
stripe/util.py Outdated Show resolved Hide resolved
Copy link
Contributor

@pakrym-stripe pakrym-stripe left a comment

Choose a reason for hiding this comment

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

Nice work! Some comments.

Copy link
Contributor

@pakrym-stripe pakrym-stripe left a comment

Choose a reason for hiding this comment

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

This is great! 🥳 🎆 🍾

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.

None yet

3 participants