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

Move type annotations inline and complete them #419

Closed
wants to merge 1 commit into from
Closed

Move type annotations inline and complete them #419

wants to merge 1 commit into from

Conversation

jdufresne
Copy link
Contributor

Now that the project is Python 3.6+, it can safely use inline type
annotations. Doing so helps ensure that the types remain accurate and
useful both internally and both projects that consume freezegun. For
example, the pip project currently ignores missing freezegun types:

https://github.com/pypa/pip/blob/135faabfd62f8c3566fd4f99a5688316302cf1c8/tests/unit/test_self_check_outdated.py#L7

The CI system runs mypy on all support Python platforms as the stdlib
API can change between releases. The code has been altered to use
PEP-484 compliant version and platform checking as outlined at:
https://www.python.org/dev/peps/pep-0484/#version-and-platform-checking

The type checker already found a couple of mistakes with internal API
usage. This should help catch bugs in new pull requests earlier during
CI.

The py.typed file is now installed alongside the package to be compliant
with PEP-561:
https://www.python.org/dev/peps/pep-0561/#packaging-type-information

Using the spec "type: ignore" comment and cast calls were only done as a
last resort when the type checker couldn't be satisfied using more
conventional approaches.

By switching to using the setuptools explicit package_data approach, the
MANIFEST.in file was simplified.

Now that the project is Python 3.6+, it can safely use inline type
annotations. Doing so helps ensure that the types remain accurate and
useful both internally and both projects that consume freezegun. For
example, the pip project currently ignores missing freezegun types:

https://github.com/pypa/pip/blob/135faabfd62f8c3566fd4f99a5688316302cf1c8/tests/unit/test_self_check_outdated.py#L7

The CI system runs mypy on all support Python platforms as the stdlib
API can change between releases. The code has been altered to use
PEP-484 compliant version and platform checking as outlined at:
https://www.python.org/dev/peps/pep-0484/#version-and-platform-checking

The type checker already found a couple of mistakes with internal API
usage. This should help catch bugs in new pull requests earlier during
CI.

The py.typed file is now installed alongside the package to be compliant
with PEP-561:
https://www.python.org/dev/peps/pep-0561/#packaging-type-information

Using the spec "type: ignore" comment and cast calls were only done as a
last resort when the type checker couldn't be satisfied using more
conventional approaches.

By switching to using the setuptools explicit package_data approach, the
MANIFEST.in file was simplified.
@jdufresne
Copy link
Contributor Author

I think it would be beneficial to land #418 and #416 first to make testing and review a bit nicer.

@bblommers
Copy link
Collaborator

This has been superceded by #543

@bblommers bblommers closed this May 11, 2024
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.

2 participants