Skip to content

Conversation

@kdeldycke
Copy link
Contributor

This is a small proposal that I am starting to apply everywhere in my own projects.

It fallows the lead of Python stdlib: python/cpython#118761

The idea consist in hiding all typing imports behind a hard-coded TYPE_CHECKING variable. Which Mypy is able to pick them up correctly, because TYPE_CHECKING is always evaluated to False at runtime, and to True during static analysis.

See an example at: python/cpython#128907

@csala csala merged commit b83f371 into csala:master Oct 27, 2025
2 of 13 checks passed
@kdeldycke kdeldycke deleted the defer-typing-imports branch October 27, 2025 15:59
@kdeldycke
Copy link
Contributor Author

Thanks again for the merge!

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