-
-
Notifications
You must be signed in to change notification settings - Fork 85
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. |
yeah I've realised this was a problem so I started moving some of the type generation logic out of the templates directly, e.g.
it seems like we'd have to extend this to support imports as well and then move basically all of the PRs more than welcome! I don't think I'll personally have time to figure this out unfortunately |
@RobertCraigie I'm happy to put in the work, but might need a bit of help getting started. Could you point me to e.g. the top 5 files that would need to be reworked and a general idea of what needs to happen? |
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: