Add support for PEP 695 type aliases#14898
Conversation
|
@facutuesca do you have a) opinions on if this is the right place for this? b) thoughts on how to test? |
|
I have to setup a complete development environment for cryptography to test so that i can also run the linters and stuff, however i will not manage to do this today. But I will try to do it next week. Otherwise also feel free to use my draft and update it as you like. |
| if sys.version_info >= (3,12): | ||
| while isinstance(field_type, typing.TypeAliasType): |
There was a problem hiding this comment.
This could also be present in previous versions by using typing_extensions.TypeAliasType. See the top of the file for how we handle conditionally importing from typing vs typing_extensions for different Python versions.
There was a problem hiding this comment.
While I'd assume cryptography can't easily add a new dependency, we provide and use https://typing-inspection.pydantic.dev/latest/ in Pydantic. It takes care of all the possible variants that are easy to miss when dealing with typing objects (in particular TypeAliasType, see our implementation). The usage guide provides useful information too.
If the only concern about testing is the newer Python versions needed for the feature (mentioned here), see my review comment about supporting |
531e6c1 to
a1c7274
Compare
|
So no i have a local test setup an fixed the linter errors. On my machine also the existing tests run without a problem. However adding a test for that case an maybe also the edge cases in combination with annotated would make sense. |
Fixes #14892
However, currently the implementation is missing tests for that specific feature.