Skip to content

Fixed bug that results in crash when a class is parameterized by a Ty…#10564

Merged
erictraut merged 1 commit intomainfrom
issue-10563
Jun 8, 2025
Merged

Fixed bug that results in crash when a class is parameterized by a Ty…#10564
erictraut merged 1 commit intomainfrom
issue-10563

Conversation

@erictraut
Copy link
Collaborator

…peVarTuple that has a non-TypeVarTuple after it in the type parameter list. This addresses #10563.

…peVarTuple that has a non-TypeVarTuple after it in the type parameter list. This addresses #10563.
@github-actions
Copy link
Contributor

github-actions bot commented Jun 8, 2025

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

sympy (https://github.com/sympy/sympy)
+   .../projects/sympy/sympy/tensor/array/expressions/array_expressions.py: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)
+   .../projects/sympy/sympy/tensor/array/expressions/array_expressions.py:1322:49 - error: "Basic" is not iterable
+     "__iter__" method not defined (reportGeneralTypeIssues)
-   .../projects/sympy/sympy/tensor/array/expressions/array_expressions.py:1329:24 - error: Operator "in" not supported for types "Unknown | Basic" and "Basic"
-     Operator "in" not supported for types "Basic" and "Basic" (reportOperatorIssue)
-   .../projects/sympy/sympy/tensor/array/expressions/array_expressions.py: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)
-   .../projects/sympy/sympy/tensor/array/expressions/array_expressions.py:1331:21 - error: No overloads for "__setitem__" match the provided arguments (reportCallIssue)
-   .../projects/sympy/sympy/tensor/array/expressions/array_expressions.py: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)
-   .../projects/sympy/sympy/tensor/array/expressions/arrayexpr_derivatives.py: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"
+   .../projects/sympy/sympy/tensor/array/expressions/arrayexpr_derivatives.py: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"
-   .../projects/sympy/sympy/tensor/array/expressions/arrayexpr_derivatives.py: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"
+   .../projects/sympy/sympy/tensor/array/expressions/arrayexpr_derivatives.py: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"
+   .../projects/sympy/sympy/tensor/array/expressions/from_array_to_indexed.py:50:25 - error: No overloads for "__setitem__" match the provided arguments (reportCallIssue)
+   .../projects/sympy/sympy/tensor/array/expressions/from_array_to_indexed.py: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)
-   .../projects/sympy/sympy/tensor/array/expressions/from_array_to_matrix.py: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__"
+   .../projects/sympy/sympy/tensor/array/expressions/from_array_to_matrix.py: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"
-   .../projects/sympy/sympy/tensor/array/expressions/from_array_to_matrix.py:214:12 - error: Type "ArrayContraction | Basic | Unknown | Zero | ZeroArray | ArrayTensorProduct | ArrayDiagonal | ArrayAdd" is not assignable to declared type "ArrayContraction"
+   .../projects/sympy/sympy/tensor/array/expressions/from_array_to_matrix.py: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"
-   .../projects/sympy/sympy/tensor/array/expressions/from_array_to_matrix.py:215:12 - error: Type "Zero | ZeroArray | ArrayTensorProduct | Unknown | ArrayContraction | Basic | ArrayDiagonal | ArrayAdd | PermuteDims" is not assignable to declared type "ArrayContraction"
+   .../projects/sympy/sympy/tensor/array/expressions/from_array_to_matrix.py: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"
-   .../projects/sympy/sympy/tensor/array/expressions/from_array_to_matrix.py:216:12 - error: Type "Zero | ZeroArray | ArrayTensorProduct | Unknown | ArrayContraction | Basic | ArrayDiagonal | ArrayAdd | PermuteDims" is not assignable to declared type "ArrayContraction"
+   .../projects/sympy/sympy/tensor/array/expressions/from_array_to_matrix.py: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"
-   .../projects/sympy/sympy/tensor/array/expressions/from_array_to_matrix.py:217:12 - error: Type "Zero | ZeroArray | ArrayTensorProduct | Unknown | ArrayContraction | Basic | ArrayDiagonal | ArrayAdd | PermuteDims" is not assignable to declared type "ArrayContraction"
+   .../projects/sympy/sympy/tensor/array/expressions/from_array_to_matrix.py: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"
-   .../projects/sympy/sympy/tensor/array/expressions/from_array_to_matrix.py:233:39 - error: Cannot access attribute "contraction_indices" for class "ArrayDiagonal"
-     Attribute "contraction_indices" is unknown (reportAttributeAccessIssue)

... (truncated 381 lines) ...

@erictraut erictraut merged commit 64b389c into main Jun 8, 2025
17 checks passed
@erictraut erictraut deleted the issue-10563 branch June 8, 2025 21:46
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.

1 participant