Skip to content

Conversation

@kurtmckee
Copy link
Contributor

Type checking across all supported Pythons revealed errors:

  • Python 3.9 doesn't have typing.TypeAlias.

    This is fixed by importing typing_extensions.TypeAlias.

  • Python 3.9 doesn't support type alias x | y union syntax.

    This is fixed by using Union[x, y] syntax.

  • Setting warn-return-any = true revealed that when cryptography isn't installed, RSAPrivateKey.sign() has an unknown signature. The return type cannot be cast() because it's redundant if cryptography is installed.

    This is fixed by adding signature: bytes = key.sign() and then returning signature.

  • All disabled error codes have been removed.

  • The pre-commit hook for mypy has been removed. It's less robust than running the test suite.

  • All functions and methods are now fully type-annotated.

Type checking across all supported Pythons revealed errors:

* Python 3.9 doesn't have `typing.TypeAlias`.

  This is fixed by importing `typing_extensions.TypeAlias`.

* Python 3.9 doesn't support type alias `x | y` union syntax.

  This is fixed by using `Union[x, y]` syntax.

* Setting `warn-return-any = true` revealed that
  when `cryptography` isn't installed,
  `RSAPrivateKey.sign()` has an unknown signature.
  The return type cannot be `cast()`
  because it's redundant if `cryptography` is installed.

  This is fixed by adding `signature: bytes = key.sign()`
  and then returning `signature`.

* All disabled error codes have been removed.
* The pre-commit hook for mypy has been removed.
  It's less robust than running the test suite.
* All functions and methods are now fully type-annotated.
@auvipy auvipy requested review from auvipy and Copilot and removed request for auvipy October 29, 2025 14:39
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves type checking infrastructure by removing the mypy pre-commit hook, adding tox-based mypy testing across all supported Python versions (3.9-3.14), and increasing mypy strictness. The changes enable type annotations to be tested in both crypto and nocrypto configurations across all Python versions.

  • Added tox environments for running mypy on Python 3.9-3.14 with optional crypto extras
  • Increased mypy strictness by enabling strict = true and warn_return_any = true
  • Replaced Python 3.10+ union syntax with Union[] for Python 3.9 compatibility

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tox.ini Added mypy test environments for all Python versions (3.9-3.14) and a labeled group for running them
pyproject.toml Enabled strict mypy checking and simplified configuration
jwt/jwks_client.py Updated type ignore comment to be more specific
jwt/api_jwt.py Added Python 3.9 support for TypeAlias, replaced union syntax, added cast for type safety
jwt/algorithms.py Added Python 3.9 support for TypeAlias, replaced union syntax, added type annotations and return type hints
CHANGELOG.rst Documented the development changes
.pre-commit-config.yaml Removed mypy pre-commit hook

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Collaborator

@auvipy auvipy left a comment

Choose a reason for hiding this comment

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

please cross check the suggestions

@kurtmckee
Copy link
Contributor Author

kurtmckee commented Oct 29, 2025

Just did. Copilot was wrong on all counts, and no changes are needed.

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