Skip to content

Is self-referencing type alias supported? #5779

Answered by dmontagu
2AtM7 asked this question in Question
Discussion options

You must be logged in to vote

The short answer is — not yet. But it's something we do want to add support for.

Once the type alias syntax introduced in this PEP https://peps.python.org/pep-0695/#generic-type-alias is introduced, I think that will be the obvious way to handle it, though that will require python 3.12+.

Also, it looks like there is active work toward backporting the TypeAliasType into typing_extensions, and once it is added, I think that will be the obvious way to support it in earlier python versions. See python/typing_extensions#159 and python/typing_extensions#160 for reference.

For what it's worth, I think the pydantic implementation will probably look a lot like this: ef5dd26 which was part of an at…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@dmontagu
Comment options

Answer selected by 2AtM7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants