Skip to content
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

Issues when running on various open source codebases #8272

Closed
hauntsaninja opened this issue Jun 30, 2024 · 9 comments
Closed

Issues when running on various open source codebases #8272

hauntsaninja opened this issue Jun 30, 2024 · 9 comments
Labels
bug Something isn't working

Comments

@hauntsaninja
Copy link

hauntsaninja commented Jun 30, 2024

Yesterday I greatly expanded the set of packages in mypy_primer that pyright will run on. I encountered a few issues (using 1.1.369).

On scipy, running pyright crashes with the following stacktrace:

An internal error occurred while type checking file "/private/tmp/mypy_primer/projects/scipy/scipy/sparse/tests/test_base.py": Error: Debug Failure. False expression.
    at computeMroLinearization (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeUtils.ts:3162:21)
    at createClassFromMetaclass (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:13110:14)
    at validateCallForInstantiableClass (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:9783:37)
    at validateCallArgumentsForSubtype (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:9401:28)
    at callback (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:9285:44)
    at useSpeculativeMode (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:20725:20)
    at callback (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:9282:24)
    at callback (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:3956:43)
    at doForEachSubtype (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeUtils.ts:751:9)
    at expandSubtype (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:3940:13)
    at mapSubtypesExpandTypeVars (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:3998:13)
    at validateCallArguments (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:9278:26)
    at getTypeOfCall (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:8075:36)
    at getTypeOfExpressionCore (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:1159:30)
    at getTypeOfExpression (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:1062:26)
    at forEach (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:18606:66)
    at Array.forEach (<anonymous>)
    at inferFunctionReturnType (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:18603:59)
    at disableSpeculativeMode (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:22098:48)
    at callback (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:22097:25)
    at a.getFunctionInferredReturnType [as timeOperation] (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/common/timing.ts:40:20)
    at getFunctionEffectiveReturnType (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:22045:20)
    at validateFunctionArgumentTypes (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:11591:26)
    at validateFunctionArgumentTypesWithContext (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:11228:20)
    at validateFunctionArguments (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:11833:16)
    at validateCallForFunction (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:9506:32)
    at validateCallArgumentsForSubtype (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:9368:24)
    at callback (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:9285:44)
    at useSpeculativeMode (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:20725:20)
    at callback (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:9282:24)
    at callback (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:3956:43)
    at doForEachSubtype (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeUtils.ts:751:9)
    at expandSubtype (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:3940:13)
    at mapSubtypesExpandTypeVars (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:3998:13)
    at validateCallArguments (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:9278:26)
    at getTypeOfCall (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:8075:36)
    at getTypeOfExpressionCore (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:1159:30)
    at getTypeOfExpression (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:1062:26)
    at forEach (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:16559:35)
    at Array.forEach (<anonymous>)
    at cb (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:16543:28)
    at invalidateTypeCacheIfCanceled (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/common/cancellationUtils.ts:32:16)
    at getTypeOfClass (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:16510:16)
    at getTypeForDeclaration (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:21083:39)
    at getDeclaredTypeOfSymbol (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:21991:50)
    at getEffectiveTypeOfSymbolForUsage (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:21634:32)
    at getTypeOfName (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:4459:39)
    at getTypeOfExpressionCore (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:1144:30)
    at getTypeOfExpression (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:1062:26)
    at getTypeOfMemberAccess (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:5105:32)
    at getTypeOfExpressionCore (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:1149:30)
    at callback (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:1062:26)
    at a.getTypeOfExpression [as timeOperation] (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/common/timing.ts:40:20)
    at isCallNoReturn (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/codeFlowEngine.ts:1625:46)
    at getTypeFromFlowNode (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/codeFlowEngine.ts:451:29)
    at Object.getTypeFromCodeFlow (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/codeFlowEngine.ts:1165:20)
    at getFlowTypeOfReference (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:19966:25)
    at getTypeOfName (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:4517:44)
    at getTypeOfExpressionCore (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:1144:30)
    at getTypeOfExpression (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:1062:26)
    at getTypeOfCall (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:8021:30)
    at getTypeOfExpressionCore (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:1159:30)
    at getTypeOfExpression (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:1062:26)
    at /Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:16559:35
Error performing analysis: Error: Debug Failure. False expression.
    at computeMroLinearization (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeUtils.ts:3162:21)
    at createClassFromMetaclass (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:13110:14)
    at validateCallForInstantiableClass (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:9783:37)
    at validateCallArgumentsForSubtype (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:9401:28)
    at callback (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:9285:44)
    at useSpeculativeMode (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:20725:20)
    at callback (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:9282:24)
    at callback (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:3956:43)
    at doForEachSubtype (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeUtils.ts:751:9)
    at expandSubtype (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:3940:13)
    at mapSubtypesExpandTypeVars (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:3998:13)
    at validateCallArguments (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:9278:26)
    at getTypeOfCall (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:8075:36)
    at getTypeOfExpressionCore (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:1159:30)
    at getTypeOfExpression (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:1062:26)
    at forEach (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:18606:66)
    at Array.forEach (<anonymous>)
    at inferFunctionReturnType (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:18603:59)
    at disableSpeculativeMode (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:22098:48)
    at callback (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:22097:25)
    at a.getFunctionInferredReturnType [as timeOperation] (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/common/timing.ts:40:20)
    at getFunctionEffectiveReturnType (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:22045:20)
    at validateFunctionArgumentTypes (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:11591:26)
    at validateFunctionArgumentTypesWithContext (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:11228:20)
    at validateFunctionArguments (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:11833:16)
    at validateCallForFunction (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:9506:32)
    at validateCallArgumentsForSubtype (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:9368:24)
    at callback (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:9285:44)
    at useSpeculativeMode (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:20725:20)
    at callback (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:9282:24)
    at callback (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:3956:43)
    at doForEachSubtype (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeUtils.ts:751:9)
    at expandSubtype (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:3940:13)
    at mapSubtypesExpandTypeVars (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:3998:13)
    at validateCallArguments (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:9278:26)
    at getTypeOfCall (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:8075:36)
    at getTypeOfExpressionCore (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:1159:30)
    at getTypeOfExpression (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:1062:26)
    at forEach (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:16559:35)
    at Array.forEach (<anonymous>)
    at cb (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:16543:28)
    at invalidateTypeCacheIfCanceled (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/common/cancellationUtils.ts:32:16)
    at getTypeOfClass (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:16510:16)
    at getTypeForDeclaration (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:21083:39)
    at getDeclaredTypeOfSymbol (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:21991:50)
    at getEffectiveTypeOfSymbolForUsage (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:21634:32)
    at getTypeOfName (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:4459:39)
    at getTypeOfExpressionCore (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:1144:30)
    at getTypeOfExpression (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:1062:26)
    at getTypeOfMemberAccess (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:5105:32)
    at getTypeOfExpressionCore (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:1149:30)
    at callback (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:1062:26)
    at a.getTypeOfExpression [as timeOperation] (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/common/timing.ts:40:20)
    at isCallNoReturn (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/codeFlowEngine.ts:1625:46)
    at getTypeFromFlowNode (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/codeFlowEngine.ts:451:29)
    at Object.getTypeFromCodeFlow (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/codeFlowEngine.ts:1165:20)
    at getFlowTypeOfReference (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:19966:25)
    at getTypeOfName (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:4517:44)
    at getTypeOfExpressionCore (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:1144:30)
    at getTypeOfExpression (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:1062:26)
    at getTypeOfCall (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:8021:30)
    at getTypeOfExpressionCore (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:1159:30)
    at getTypeOfExpression (/Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:1062:26)
    at /Users/shantanu/.cache/pyright-python/1.1.369/node_modules/pyright/dist/pyright-internal/src/analyzer/typeEvaluator.ts:16559:35

I also encountered several hangs (I left pyright running for about an hour with no termination):

You can find the dependencies required for each repro listed in mypy_primer/projects.py

Out of the projects that I have currently enabled pyright on, these were the five slowest projects:

321.85  https://github.com/aio-libs/aiohttp
240.55  https://github.com/home-assistant/core
238.38  https://github.com/scikit-learn/scikit-learn
237.42  https://github.com/sympy/sympy
181.36  https://github.com/pydata/xarray

You can get a basic n=1 timing using mypy_primer --measure-project-runtimes --type-checker pyright.
You might be interested in looking at what's going on with aiohttp in particular, since mypy is many times faster on that codebase.

Let me know if the new set of mypy_primer packages works well in CI for you. If not, let's figure out how to make things better. I can add the same cost-based sharding we do for mypy or disable some of the slowest projects.

@hauntsaninja hauntsaninja added the bug Something isn't working label Jun 30, 2024
@hauntsaninja
Copy link
Author

The changes increased the number of projects in mypy_primer that pyright runs on from 28 to 123. You might be interested in re-running some of your recent analyses, e.g. #8259

@erictraut
Copy link
Collaborator

Thanks! I'll take a look at the repos you mentioned above.

We may need to (at least temporarily) pass --skipunannotated to the pyright command line for some of these projects. That will skip analysis of unannotated functions, which is what mypy does by default.

@erictraut
Copy link
Collaborator

The crash you are seeing for scipy is already fixed in pyright's "main" branch. This was a regression that would have been avoided with your expanded mypy_primer list!

@hauntsaninja
Copy link
Author

hauntsaninja commented Jun 30, 2024

I think earlier I was seeing that if you installed numpy, pyright from "main" would hang on scipy as well:

python -m venv env
source env/bin/activate
pip install numpy
/Users/shantanu/dev/pyright/packages/pyright/index.js scipy

I'll double check that. I'll also see what can get unblocked with --skipunannotated

@erictraut
Copy link
Collaborator

I did an initial pass over the three code bases that result in a hang. In all three cases, the problem is related to a specific method or function (all of which have high cyclomatic complexity and symbol interdependencies). I've filed separate bugs for these three issues.

It looks like you've left these disabled in mypy_primer for now. We can enable them one by one as I address the underlying cause of the hangs.

I also looked at the five slowest projects listed above. Of these, aiohttp looks like it's due to a potential bug, similar to the three hangs. The other four projects are simply really large projects with very dense, complex code, so I would expect them to take longer to analyze.

I'm going to leave this issue open until I've had a chance to test the CI scripts and add more parallel runners as appropriate. Once that's done, I'll close this issue and fall back on the other specific issues I filed.

Thanks again for doing this!

@hauntsaninja
Copy link
Author

Thank you for looking into it!

I also confirmed that scipy hangs with "main" pyright if you install numpy, so we should track that.

Yup, mypy is slow on the other four projects too, it's just aiohttp that's the outlier.

That sounds good, on my side I'll add cost based sharding for pyright. Do let me know if there are other things I can help with.

@erictraut
Copy link
Collaborator

I introduced a performance fix for the aiohttp issue. That makes the CI scripts usable with the updated mypy_primer.

I filed an additional bug to track the scipy hang.

With that, I'm going to close this issue.

@erictraut
Copy link
Collaborator

@hauntsaninja, I've fixed the issue that causes pyright to hang when type checking isort, graphql-core, and mypy. We can enable those in mypy_primer now.

I'm still investigating the issue with scipy with numpy installed. That's a different issue.

BTW, I switched the CI script to use 8 shards rather than 2. This keeps the total time down to just under 7 minutes. The script seems to be doing a good job balancing the workload between shards.

image

@hauntsaninja
Copy link
Author

Hooray, thank you! I've enabled those projects. Good to know the cost based sharding is working reasonably.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants