Skip to content

Issue with Type Checking Pydantic Generics in Pyright #9298

Answered by erictraut
ChenMoFeiJin asked this question in Q&A
Discussion options

You must be logged in to vote

Pyright adheres to the typing standard. In areas where pydantic deviates from standard behaviors, there will be mismatches. If you or the maintainers of pydantic would like to propose extensions or modifications to the typing system, the Python typing forum is a good place to discuss such proposals.

I can imagine different levels of standardized support for pydantic's behavior.

Level 1: Assume standard behaviors. This is what pyright and other conformant type checkers do today.

Level 2: A static type checker could detect that a class has a custom __class_getitem__ with a return type other than GenericAlias. In such a case, it could assume that the class should no longer be treated like a …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ChenMoFeiJin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants