Closed goodoldneon closed 6 months ago
@goodoldneon Can user code can still use the newer features like the |
operator even though the types are created using typing.Union
?
Also we should update the badge on the README to show 3.9
and maybe supported version ranges of the frameworks too?
Can user code can still use the newer features like the | operator even though the types are created using typing.Union?
Yes, type checkers treat typing.Union
the same way as |
, so users are free to continue using |
in their code.
Also we should update the badge on the README to show 3.9 and maybe supported version ranges of the frameworks too?
The badge will automatically update when we publish next. I added framework versions to the readme
Description
Add Python 3.9 support. This required 2 changes:
typing.Optional
andtyping.Union
instead of the|
operator (PEP 604)typing_extensions.TypeGuard
instead oftyping.TypeGuard
(PEP 647)Additionally:
3.9
in CI. Stopped using3.10
and3.11
in CI since it's overkill: it seems OK to use only the lowest and highest Python versions we supporttyping_extensions
to4.8.0
, since this is whatfastapi==0.104.0
requiresIssue
61
Review
This PR has a lot of changes but they're very low risk since they're almost entirely type annotations. We have a thorough test suite, so these changes should be OK as long as everything passes