prisma-client-py
prisma-client-py copied to clipboard
Optimise generated types
In order to circumvent mypy not supporting recursive types we duplicate every would-be recursive type. While this works it leads to a massive number of types being generated which slows down mypy considerably.
This appears to be unavoidable but we can improve performance by only generating types that will actually be used (we currently generate every possible relational type) and potentially re-using types.
We should also add a note to the docs somewhere that mypy performance can be improved by decreasing the depth of generated recursive types.
This is also relevant as generating many types also increases memory usage significantly when static type checking
Maybe mypy now has the recursive type support you need? https://github.com/python/mypy/issues/731#issuecomment-922760064
@tday Unfortunately not, on mypy version 0.931 recursive TypedDicts are not supported.
Trying to type check will raise errors like these:
src/prisma/types.py:2759: error: Cannot resolve name "TypesScalarWhereWithAggregatesInput" (possible cyclic definition) [misc]
NOT: List['TypesScalarWhereWithAggregatesInput']