Skip to content

Alternative fix for recent regression related to _type_checker_internals.pyi#10496

Merged
debonte merged 2 commits intomicrosoft:mainfrom
debonte:typeCheckerInternalsFix
May 23, 2025
Merged

Alternative fix for recent regression related to _type_checker_internals.pyi#10496
debonte merged 2 commits intomicrosoft:mainfrom
debonte:typeCheckerInternalsFix

Conversation

@debonte
Copy link
Contributor

@debonte debonte commented May 23, 2025

Alternative to #10494, since that change wasn't sufficient to address the analysis-related telemetry issue we were seeing in Pylance.

#10494 ensured that _type_checker_internals.pyi was not flagged as a user file, but since the file was added to the Program via addTrackedFile, it was included in the getFilesToAnalyzeCount count. This prevented the following check in Pylance's telemetry code from detecting that analysis was complete:

        const isComplete =
            (results.requiringAnalysisCount.files + results.requiringAnalysisCount.cells === 0 &&
                results.elapsedTime !== 0) ||
            results.fatalErrorOccurred;

This addresses #10484 and #10487.

@debonte debonte requested a review from erictraut May 23, 2025 15:37
@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

AutoSplit (https://github.com/Toufool/AutoSplit)
- ...
-   ...:40:9 - error: Method "items" is not marked as override but is overriding a method in class "Mapping[str, object]" (reportImplicitOverride)
-   ...:41:9 - error: Method "keys" is not marked as override but is overriding a method in class "Mapping[str, object]" (reportImplicitOverride)
-   ...:42:9 - error: Method "values" is not marked as override but is overriding a method in class "Mapping[str, object]" (reportImplicitOverride)
- 980 errors, 5 warnings, 7 informations 
+ 977 errors, 5 warnings, 7 informations 

sympy (https://github.com/sympy/sympy)
+   ...:793:52 - error: Argument of type "tuple[Unknown, ...] | Tuple | Unknown | Basic" cannot be assigned to parameter "key" of type "Basic" in function "__getitem__"
+     Type "tuple[Unknown, ...] | Tuple | Unknown | Basic" is not assignable to type "Basic"
+       "tuple[Unknown, ...]" is not assignable to "Basic" (reportArgumentType)
+   ...:1322:49 - error: "Basic" is not iterable
+     "__iter__" method not defined (reportGeneralTypeIssues)
-   ...:1329:24 - error: Operator "in" not supported for types "Unknown | Basic" and "Basic"
-     Operator "in" not supported for types "Basic" and "Basic" (reportOperatorIssue)
-   ...:1330:32 - error: Argument of type "Basic" cannot be assigned to parameter "iterable" of type "Iterable[Unknown | Basic]" in function "extend"
-     "Basic" is incompatible with protocol "Iterable[Unknown | Basic]"
-       "__iter__" is not present (reportArgumentType)
-   ...:1331:21 - error: No overloads for "__setitem__" match the provided arguments (reportCallIssue)
-   ...:1331:21 - error: Argument of type "None" cannot be assigned to parameter "value" of type "Basic" in function "__setitem__"
-     "None" is not assignable to "Basic" (reportArgumentType)
-   ...:64:2 - error: Argument of type "(expr: ArraySymbol, x: _ArrayExpr) -> (Zero | ZeroArray | ArrayTensorProduct | Unknown | ArrayContraction | Basic | ArrayDiagonal | ArrayAdd | PermuteDims)" cannot be assigned to parameter of type "(...) -> NoReturn"
+   ...:64:2 - error: Argument of type "(expr: ArraySymbol, x: _ArrayExpr) -> (Zero | ZeroArray | Unknown | ArrayContraction | Basic | PermuteDims)" cannot be assigned to parameter of type "(...) -> NoReturn"
-     Type "(expr: ArraySymbol, x: _ArrayExpr) -> (Zero | ZeroArray | ArrayTensorProduct | Unknown | ArrayContraction | Basic | ArrayDiagonal | ArrayAdd | PermuteDims)" is not assignable to type "(...) -> NoReturn"
+     Type "(expr: ArraySymbol, x: _ArrayExpr) -> (Zero | ZeroArray | Unknown | ArrayContraction | Basic | PermuteDims)" is not assignable to type "(...) -> NoReturn"
-       Function return type "Zero | ZeroArray | ArrayTensorProduct | Unknown | ArrayContraction | Basic | ArrayDiagonal | ArrayAdd | PermuteDims" is incompatible with type "NoReturn"
+       Function return type "Zero | ZeroArray | Unknown | ArrayContraction | Basic | PermuteDims" is incompatible with type "NoReturn"
-         Type "Zero | ZeroArray | ArrayTensorProduct | Unknown | ArrayContraction | Basic | ArrayDiagonal | ArrayAdd | PermuteDims" is not assignable to type "NoReturn"
+         Type "Zero | ZeroArray | Unknown | ArrayContraction | Basic | PermuteDims" is not assignable to type "NoReturn"
-   ...:74:2 - error: Argument of type "(expr: MatrixSymbol, x: _ArrayExpr) -> (Zero | ZeroArray | ArrayTensorProduct | Unknown | ArrayContraction | Basic | ArrayDiagonal | ArrayAdd | PermuteDims)" cannot be assigned to parameter of type "(...) -> NoReturn"
+   ...:74:2 - error: Argument of type "(expr: MatrixSymbol, x: _ArrayExpr) -> (Zero | ZeroArray | Unknown | ArrayContraction | Basic | PermuteDims)" cannot be assigned to parameter of type "(...) -> NoReturn"
-     Type "(expr: MatrixSymbol, x: _ArrayExpr) -> (Zero | ZeroArray | ArrayTensorProduct | Unknown | ArrayContraction | Basic | ArrayDiagonal | ArrayAdd | PermuteDims)" is not assignable to type "(...) -> NoReturn"
+     Type "(expr: MatrixSymbol, x: _ArrayExpr) -> (Zero | ZeroArray | Unknown | ArrayContraction | Basic | PermuteDims)" is not assignable to type "(...) -> NoReturn"
-       Function return type "Zero | ZeroArray | ArrayTensorProduct | Unknown | ArrayContraction | Basic | ArrayDiagonal | ArrayAdd | PermuteDims" is incompatible with type "NoReturn"
+       Function return type "Zero | ZeroArray | Unknown | ArrayContraction | Basic | PermuteDims" is incompatible with type "NoReturn"
-         Type "Zero | ZeroArray | ArrayTensorProduct | Unknown | ArrayContraction | Basic | ArrayDiagonal | ArrayAdd | PermuteDims" is not assignable to type "NoReturn"
+         Type "Zero | ZeroArray | Unknown | ArrayContraction | Basic | PermuteDims" is not assignable to type "NoReturn"
+   ...:50:25 - error: No overloads for "__setitem__" match the provided arguments (reportCallIssue)
+   ...:50:25 - error: Argument of type "Unknown | Basic" cannot be assigned to parameter "key" of type "slice[Any, Any, Any]" in function "__setitem__"
+     Type "Unknown | Basic" is not assignable to type "slice[Any, Any, Any]"
+       "Basic" is not assignable to "slice[Any, Any, Any]" (reportArgumentType)
-   ...:81:36 - error: Argument of type "Basic | Unknown | Zero | ZeroArray | ArrayTensorProduct | ArrayDiagonal | ArrayAdd | ArrayContraction" cannot be assigned to parameter "base_array" of type "ArrayContraction | ArrayDiagonal | ArrayTensorProduct" in function "__init__"
+   ...:81:36 - error: Argument of type "Basic | Unknown | Zero | ZeroArray | ArrayTensorProduct | ArrayContraction" cannot be assigned to parameter "base_array" of type "ArrayContraction | ArrayDiagonal | ArrayTensorProduct" in function "__init__"
-     Type "Basic | Unknown | Zero | ZeroArray | ArrayTensorProduct | ArrayDiagonal | ArrayAdd | ArrayContraction" is not assignable to type "ArrayContraction | ArrayDiagonal | ArrayTensorProduct"
+     Type "Basic | Unknown | Zero | ZeroArray | ArrayTensorProduct | ArrayContraction" is not assignable to type "ArrayContraction | ArrayDiagonal | ArrayTensorProduct"
-   ...:214:12 - error: Type "ArrayContraction | Basic | Unknown | Zero | ZeroArray | ArrayTensorProduct | ArrayDiagonal | ArrayAdd" is not assignable to declared type "ArrayContraction"
+   ...:214:12 - error: Type "ArrayContraction | Basic | Unknown | Zero | ZeroArray | ArrayTensorProduct" is not assignable to declared type "ArrayContraction"
-     Type "ArrayContraction | Basic | Unknown | Zero | ZeroArray | ArrayTensorProduct | ArrayDiagonal | ArrayAdd" is not assignable to type "ArrayContraction"
+     Type "ArrayContraction | Basic | Unknown | Zero | ZeroArray | ArrayTensorProduct" is not assignable to type "ArrayContraction"
-   ...:215:12 - error: Type "Zero | ZeroArray | ArrayTensorProduct | Unknown | ArrayContraction | Basic | ArrayDiagonal | ArrayAdd | PermuteDims" is not assignable to declared type "ArrayContraction"
+   ...:215:12 - error: Type "Zero | ZeroArray | Unknown | ArrayContraction | Basic | PermuteDims" is not assignable to declared type "ArrayContraction"
-     Type "Zero | ZeroArray | ArrayTensorProduct | Unknown | ArrayContraction | Basic | ArrayDiagonal | ArrayAdd | PermuteDims" is not assignable to type "ArrayContraction"
+     Type "Zero | ZeroArray | Unknown | ArrayContraction | Basic | PermuteDims" is not assignable to type "ArrayContraction"
-   ...:216:12 - error: Type "Zero | ZeroArray | ArrayTensorProduct | Unknown | ArrayContraction | Basic | ArrayDiagonal | ArrayAdd | PermuteDims" is not assignable to declared type "ArrayContraction"
+   ...:216:12 - error: Type "Zero | ZeroArray | Unknown | ArrayContraction | Basic | PermuteDims" is not assignable to declared type "ArrayContraction"
-     Type "Zero | ZeroArray | ArrayTensorProduct | Unknown | ArrayContraction | Basic | ArrayDiagonal | ArrayAdd | PermuteDims" is not assignable to type "ArrayContraction"
+     Type "Zero | ZeroArray | Unknown | ArrayContraction | Basic | PermuteDims" is not assignable to type "ArrayContraction"
-   ...:217:12 - error: Type "Zero | ZeroArray | ArrayTensorProduct | Unknown | ArrayContraction | Basic | ArrayDiagonal | ArrayAdd | PermuteDims" is not assignable to declared type "ArrayContraction"
+   ...:217:12 - error: Type "Zero | ZeroArray | Unknown | ArrayContraction | Basic | PermuteDims" is not assignable to declared type "ArrayContraction"
-     Type "Zero | ZeroArray | ArrayTensorProduct | Unknown | ArrayContraction | Basic | ArrayDiagonal | ArrayAdd | PermuteDims" is not assignable to type "ArrayContraction"
+     Type "Zero | ZeroArray | Unknown | ArrayContraction | Basic | PermuteDims" is not assignable to type "ArrayContraction"
-   ...:233:39 - error: Cannot access attribute "contraction_indices" for class "ArrayDiagonal"
-     Attribute "contraction_indices" is unknown (reportAttributeAccessIssue)
-   ...:233:39 - error: Cannot access attribute "contraction_indices" for class "ArrayAdd"
-     Attribute "contraction_indices" is unknown (reportAttributeAccessIssue)
+   ...:256:40 - error: Argument of type "Unknown | Zero | ZeroArray | ArrayContraction | Basic | PermuteDims | ArrayAdd | ArrayDiagonal" cannot be assigned to parameter "expr" of type "ArrayContraction | ArrayDiagonal" in function "identify_hadamard_products"
+     Type "Unknown | Zero | ZeroArray | ArrayContraction | Basic | PermuteDims | ArrayAdd | ArrayDiagonal" is not assignable to type "ArrayContraction | ArrayDiagonal"
+       Type "Basic" is not assignable to type "ArrayContraction | ArrayDiagonal"
+         "Basic" is not assignable to "ArrayContraction"
+         "Basic" is not assignable to "ArrayDiagonal" (reportArgumentType)
-   ...:307:17 - error: Argument of type "Zero | ZeroArray | ArrayTensorProduct | Unknown | ArrayContraction | Basic | ArrayDiagonal | ArrayAdd | PermuteDims | Any | Transpose" cannot be assigned to parameter "value" of type "None" in function "__setitem__"
+   ...:307:17 - error: Argument of type "Zero | ZeroArray | Unknown | ArrayContraction | Basic | PermuteDims | Any | Transpose" cannot be assigned to parameter "value" of type "None" in function "__setitem__"
-     Type "Zero | ZeroArray | ArrayTensorProduct | Unknown | ArrayContraction | Basic | ArrayDiagonal | ArrayAdd | PermuteDims | Any | Transpose" is not assignable to type "None"
+     Type "Zero | ZeroArray | Unknown | ArrayContraction | Basic | PermuteDims | Any | Transpose" is not assignable to type "None"

... (truncated 370 lines) ...

steam.py (https://github.com/Gobot1234/steam.py)
- ...
-   ...:52:91 - warning: Unnecessary "# type: ignore" comment (reportUnnecessaryTypeIgnoreComment)
- 8263 errors, 91 warnings, 0 informations 
+ 8263 errors, 90 warnings, 0 informations 

scipy-stubs (https://github.com/scipy/scipy-stubs)
- ...
-   ...:40:9 - error: Method "items" is not marked as override but is overriding a method in class "Mapping[str, object]" (reportImplicitOverride)
-   ...:41:9 - error: Method "keys" is not marked as override but is overriding a method in class "Mapping[str, object]" (reportImplicitOverride)
-   ...:42:9 - error: Method "values" is not marked as override but is overriding a method in class "Mapping[str, object]" (reportImplicitOverride)
- 275 errors, 0 warnings, 0 informations 
+ 272 errors, 0 warnings, 0 informations 

discord.py (https://github.com/Rapptz/discord.py)
- ...
-   ...:52:91 - warning: Unnecessary "# type: ignore" comment (reportUnnecessaryTypeIgnoreComment)
- 0 errors, 9 warnings, 0 informations 
+ 0 errors, 8 warnings, 0 informations 

antidote (https://github.com/Finistere/antidote)
- ...
-   ...:52:91 - warning: Unnecessary "# type: ignore" comment (reportUnnecessaryTypeIgnoreComment)
- 269 errors, 37 warnings, 0 informations 
+ 269 errors, 36 warnings, 0 informations 

operator (https://github.com/canonical/operator)
- ...
-   ...:52:91 - error: Unnecessary "# type: ignore" comment (reportUnnecessaryTypeIgnoreComment)
- 192 errors, 0 warnings, 0 informations 
+ 191 errors, 0 warnings, 0 informations 

hydra-zen (https://github.com/mit-ll-responsible-ai/hydra-zen)
- ...
-   ...:52:91 - error: Unnecessary "# type: ignore" comment (reportUnnecessaryTypeIgnoreComment)
- 10 errors, 0 warnings, 183 informations 
+ 9 errors, 0 warnings, 183 informations 

async-utils (https://github.com/mikeshardmind/async-utils)
- ...
-   ...:52:91 - warning: Unnecessary "# type: ignore" comment (reportUnnecessaryTypeIgnoreComment)
- 0 errors, 1 warning, 0 informations 
+ 0 errors, 0 warnings, 0 informations 

Tanjun (https://github.com/FasterSpeeding/Tanjun)
- ...
-   ...:52:91 - error: Unnecessary "# type: ignore" comment (reportUnnecessaryTypeIgnoreComment)
- 37 errors, 108 warnings, 0 informations 
+ 36 errors, 108 warnings, 0 informations 

trio (https://github.com/python-trio/trio)
- ...
-   ...:52:91 - error: Unnecessary "# type: ignore" comment (reportUnnecessaryTypeIgnoreComment)
- 1515 errors, 13 warnings, 0 informations 
+ 1514 errors, 13 warnings, 0 informations 

@debonte debonte merged commit 50dda51 into microsoft:main May 23, 2025
18 checks passed
@debonte debonte deleted the typeCheckerInternalsFix branch May 23, 2025 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants