You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I enable the reportShadowedImports checks, Pyright runs increase from ~13.5 seconds to ~28 seconds.
Describe the solution you’d like
Given the repetitive nature of the imports, I am hoping that it's possible to speed up or avoid duplicate shadow checks.
Steps to reproduce
I have prepared a sample repo that illustrates the slowdown:
git clone --branch shadowed-imports-slowdown https://github.com/correctmost/pyright-corpus.git
cd pyright-corpus
# Run with reportShadowedImports already enabled
time npx pyright
--> Toggle reportShadowedImports off in pyrightconfig.json
# Re-run with reportShadowedImports disabled
time npx pyright
Thanks!
The text was updated successfully, but these errors were encountered:
This test can be quite expensive on large code bases with complex import dependency graphs. I've already spent quite a bit of time optimizing it, but I'll take a closer look at your sample to see if there's anything I can do to speed it up further. I just want to set expectations that there probably won't be much, if anything, that I can do.
You probably know this already, but this check is not on by default — even in strict mode. That's for good reason. If you find that the value it provides is not worth the time it takes, you can leave it disabled.
I'll also note that it's arguably not the job of a type checker to be reporting import cycles in your code. I added the check very early in pyright's evolution because the team I was managing at the time had a large and complex code base with a number of problematic import cycles, and I couldn't find other tools at the time that would detect them. There may be other tools available now.
I misspoke above. I mixed things up and thought you were talking about reportImportCycles, which is intrinsically an expensive test. You're talking about the reportShadowedImports, which is different. I wouldn't expect that to be expensive. This check is disabled by default in pyright but is enabled by default in pylance. It was implemented by the pylance team, so I'll leave it to them to investigate and see if there's a way to speed it up.
@rchiodo, could you or someone else on the pylance team take a look at this? Feel free to transfer to the pylance-release project if you'd prefer to track it there.
Is your feature request related to a problem? Please describe.
I have a private codebase with ~2300 Python files. Most of the files have repeated import blocks like this:
When I enable the reportShadowedImports checks, Pyright runs increase from ~13.5 seconds to ~28 seconds.
Describe the solution you’d like
Given the repetitive nature of the imports, I am hoping that it's possible to speed up or avoid duplicate shadow checks.
Steps to reproduce
I have prepared a sample repo that illustrates the slowdown:
Thanks!
The text was updated successfully, but these errors were encountered: