-
-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reduce type resolution complexity #1060
Comments
The maintainer of Pyright (the underlying type checker that powers Pylance) just posted a detailed explanation of why Pylance and Pyright can't handle these files: microsoft/pyright#9709 (comment) Highlights
Example of the mentioned "alternative functional syntax"The "alternative functional syntax" definition of _AgentGraphCompoundPrimaryKeyInner = TypedDict(
'_AgentGraphCompoundPrimaryKeyInner',
{
'id': '_str',
'version': '_int',
},
total=True
)
_AgentGraphCompoundPrimaryKey = TypedDict(
'_AgentGraphCompoundPrimaryKey',
{
'graphVersionId': '_AgentGraphCompoundPrimaryKeyInner',
},
total=True
)
AgentGraphWhereUniqueInput = _AgentGraphCompoundPrimaryKey
Offered solutions
|
Excellent point @Pwuts. I think the |
I did a local test, updated the
|
The other possible solution is to split the
By modifying slightly the template generator I managed to generate one Once each model lives in a different file, we need to resolve the dependencies among them (e.g. model A relies on types from model B if it has a foreign relation). Models that rely on each other would cause a circular import. To avoid this, we'd need to split files considering a second dimension that avoids circular imports (e.g. at least separate the |
Or do the imports at a different level, e.g. inside the class that uses it? In any case, it seems like we're hitting the limits of generating Python modules with jinja templates. |
Problem
We are working on a medium-size project (our
schema.prisma
is < 400 lines) that generates atypes.py
file over 40.000 lines. This file is so big that Pylance refuses to process it, and hence we don't have type resolution while coding:Suggested solution
I suggest splitting the types file into multiple files, e.g. one per
Model
.Alternatives
Suggest Pylance settings that would allow processing such large file (I could not find any setting to fix it).
Additional context
The text was updated successfully, but these errors were encountered: