Skip to content

chore: remove superfluous constants#1136

Merged
jpadilla merged 2 commits intojpadilla:masterfrom
tamird:no-constants-just-aliases
Feb 18, 2026
Merged

chore: remove superfluous constants#1136
jpadilla merged 2 commits intojpadilla:masterfrom
tamird:no-constants-just-aliases

Conversation

@tamird
Copy link
Copy Markdown
Contributor

@tamird tamird commented Feb 12, 2026

This Py >= 3.10 TODO is doable even on 3.9, so do it.

@tamird tamird force-pushed the no-constants-just-aliases branch 3 times, most recently from d40a1a1 to 8ad28cf Compare February 13, 2026 21:01
@tamird
Copy link
Copy Markdown
Contributor Author

tamird commented Feb 13, 2026

@jpadilla the coverage change here doesn't seem meaningful - please have a look. Thanks!

This Py >= 3.10 TODO is doable even on 3.9, so do it.
Copy link
Copy Markdown
Contributor

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 refactors the JWT algorithms module to remove superfluous constant tuples that were previously used for runtime type checking. The changes leverage Python's typing.get_args() to dynamically extract type information from Union type aliases at runtime, replacing the need for separate constant tuples.

Changes:

  • Removed constant tuples (ALLOWED_RSA_KEY_TYPES, ALLOWED_EC_KEY_TYPES, ALLOWED_OKP_KEY_TYPES, etc.) and replaced them with get_args() calls on Union types
  • Moved TypeAlias definitions outside of TYPE_CHECKING block to make them available at runtime
  • Added type casts where necessary to satisfy type checkers after isinstance checks

Reviewed changes

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

File Description
jwt/algorithms.py Refactored to use get_args() for extracting types from Union type aliases, replacing constant tuples; moved TypeAlias definitions outside TYPE_CHECKING block
.github/workflows/main.yml Added comments and explicit file specification for codecov uploads

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

@tamird tamird force-pushed the no-constants-just-aliases branch from a6784e8 to 7cbe990 Compare February 14, 2026 15:59
Scope mypy missing-import suppression to cryptography only, and make
no-crypto key aliases explicit with Never.
@tamird tamird force-pushed the no-constants-just-aliases branch from 8ed9560 to 6f3b616 Compare February 14, 2026 21:12
@jpadilla jpadilla merged commit 99a8728 into jpadilla:master Feb 18, 2026
27 of 29 checks passed
@tamird tamird deleted the no-constants-just-aliases branch February 18, 2026 17:30
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