Skip to content

Fixed a bug that results in a false negative when the specialization … #10220

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

Merged
merged 1 commit into from
Mar 30, 2025

Conversation

erictraut
Copy link
Collaborator

…of a TypeVarTuple includes multiple unpacked tuples of unknown length. This addresses #10219.

…of a TypeVarTuple includes multiple unpacked tuples of unknown length. This addresses #10219.
Copy link
Contributor

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

sympy (https://github.com/sympy/sympy)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/array/expressions/tests/test_convert_array_to_matrix.py:170:41 - error: Argument of type "Unknown | Zero | ZeroArray | ArrayContraction | Basic | PermuteDims | ArrayAdd | ArrayDiagonal" cannot be assigned to parameter "expr" of type "ArrayDiagonal" in function "_array_diag2contr_diagmatrix"
+     Type "Unknown | Zero | ZeroArray | ArrayContraction | Basic | PermuteDims | ArrayAdd | ArrayDiagonal" is not assignable to type "ArrayDiagonal"
+       "Basic" is not assignable to "ArrayDiagonal" (reportArgumentType)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/array/expressions/tests/test_convert_array_to_matrix.py:174:41 - error: Argument of type "Unknown | Zero | ZeroArray | ArrayContraction | Basic | PermuteDims | ArrayAdd | ArrayDiagonal" cannot be assigned to parameter "expr" of type "ArrayDiagonal" in function "_array_diag2contr_diagmatrix"
+     Type "Unknown | Zero | ZeroArray | ArrayContraction | Basic | PermuteDims | ArrayAdd | ArrayDiagonal" is not assignable to type "ArrayDiagonal"
+       "Basic" is not assignable to "ArrayDiagonal" (reportArgumentType)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/array/expressions/tests/test_convert_array_to_matrix.py:180:41 - error: Argument of type "Unknown | Zero | ZeroArray | ArrayContraction | Basic | PermuteDims | ArrayAdd | ArrayDiagonal" cannot be assigned to parameter "expr" of type "ArrayDiagonal" in function "_array_diag2contr_diagmatrix"
+     Type "Unknown | Zero | ZeroArray | ArrayContraction | Basic | PermuteDims | ArrayAdd | ArrayDiagonal" is not assignable to type "ArrayDiagonal"
+       "Basic" is not assignable to "ArrayDiagonal" (reportArgumentType)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/array/expressions/tests/test_convert_array_to_matrix.py:184:41 - error: Argument of type "Unknown | Zero | ZeroArray | ArrayContraction | Basic | PermuteDims | ArrayAdd | ArrayDiagonal" cannot be assigned to parameter "expr" of type "ArrayDiagonal" in function "_array_diag2contr_diagmatrix"
+     Type "Unknown | Zero | ZeroArray | ArrayContraction | Basic | PermuteDims | ArrayAdd | ArrayDiagonal" is not assignable to type "ArrayDiagonal"
+       "Basic" is not assignable to "ArrayDiagonal" (reportArgumentType)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/array/expressions/tests/test_convert_array_to_matrix.py:188:41 - error: Argument of type "Unknown | Zero | ZeroArray | ArrayContraction | Basic | PermuteDims | ArrayAdd | ArrayDiagonal" cannot be assigned to parameter "expr" of type "ArrayDiagonal" in function "_array_diag2contr_diagmatrix"
+     Type "Unknown | Zero | ZeroArray | ArrayContraction | Basic | PermuteDims | ArrayAdd | ArrayDiagonal" is not assignable to type "ArrayDiagonal"
+       "Basic" is not assignable to "ArrayDiagonal" (reportArgumentType)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/array/expressions/tests/test_convert_array_to_matrix.py:196:41 - error: Argument of type "Unknown | Zero | ZeroArray | ArrayContraction | Basic | PermuteDims | ArrayAdd | ArrayDiagonal" cannot be assigned to parameter "expr" of type "ArrayDiagonal" in function "_array_diag2contr_diagmatrix"
+     Type "Unknown | Zero | ZeroArray | ArrayContraction | Basic | PermuteDims | ArrayAdd | ArrayDiagonal" is not assignable to type "ArrayDiagonal"
+       "Basic" is not assignable to "ArrayDiagonal" (reportArgumentType)
+   /tmp/mypy_primer/projects/sympy/sympy/tensor/array/expressions/tests/test_convert_array_to_matrix.py:205:41 - error: Argument of type "Unknown | Zero | ZeroArray | ArrayContraction | Basic | PermuteDims | ArrayAdd | ArrayDiagonal" cannot be assigned to parameter "expr" of type "ArrayDiagonal" in function "_array_diag2contr_diagmatrix"
+     Type "Unknown | Zero | ZeroArray | ArrayContraction | Basic | PermuteDims | ArrayAdd | ArrayDiagonal" is not assignable to type "ArrayDiagonal"
+       "Basic" is not assignable to "ArrayDiagonal" (reportArgumentType)
-     Attribute "split_multiple_contractions" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/tensor/array/expressions/tests/test_convert_array_to_matrix.py:213:15 - error: Cannot access attribute "split_multiple_contractions" for class "ArrayDiagonal"
-     Attribute "split_multiple_contractions" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/tensor/array/expressions/tests/test_convert_array_to_matrix.py:213:15 - error: Cannot access attribute "split_multiple_contractions" for class "ArrayAdd"
-   /tmp/mypy_primer/projects/sympy/sympy/tensor/array/expressions/tests/test_convert_array_to_matrix.py:217:15 - error: Cannot access attribute "split_multiple_contractions" for class "ArrayDiagonal"
-     Attribute "split_multiple_contractions" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/tensor/array/expressions/tests/test_convert_array_to_matrix.py:217:15 - error: Cannot access attribute "split_multiple_contractions" for class "ArrayAdd"
-     Attribute "split_multiple_contractions" is unknown (reportAttributeAccessIssue)
-     Attribute "split_multiple_contractions" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/tensor/array/expressions/tests/test_convert_array_to_matrix.py:223:15 - error: Cannot access attribute "split_multiple_contractions" for class "ArrayDiagonal"
-     Attribute "split_multiple_contractions" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/tensor/array/expressions/tests/test_convert_array_to_matrix.py:223:15 - error: Cannot access attribute "split_multiple_contractions" for class "ArrayAdd"
-   /tmp/mypy_primer/projects/sympy/sympy/tensor/array/expressions/tests/test_convert_array_to_matrix.py:227:15 - error: Cannot access attribute "split_multiple_contractions" for class "ArrayDiagonal"
-     Attribute "split_multiple_contractions" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/tensor/array/expressions/tests/test_convert_array_to_matrix.py:227:15 - error: Cannot access attribute "split_multiple_contractions" for class "ArrayAdd"
-     Attribute "split_multiple_contractions" is unknown (reportAttributeAccessIssue)
-     Attribute "split_multiple_contractions" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/tensor/array/expressions/tests/test_convert_array_to_matrix.py:231:15 - error: Cannot access attribute "split_multiple_contractions" for class "ArrayDiagonal"
-     Attribute "split_multiple_contractions" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/tensor/array/expressions/tests/test_convert_array_to_matrix.py:231:15 - error: Cannot access attribute "split_multiple_contractions" for class "ArrayAdd"
-   /tmp/mypy_primer/projects/sympy/sympy/tensor/array/expressions/tests/test_convert_array_to_matrix.py:235:15 - error: Cannot access attribute "split_multiple_contractions" for class "ArrayDiagonal"
-     Attribute "split_multiple_contractions" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/tensor/array/expressions/tests/test_convert_array_to_matrix.py:235:15 - error: Cannot access attribute "split_multiple_contractions" for class "ArrayAdd"
-     Attribute "split_multiple_contractions" is unknown (reportAttributeAccessIssue)
-     Attribute "split_multiple_contractions" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/tensor/array/expressions/tests/test_convert_array_to_matrix.py:241:15 - error: Cannot access attribute "split_multiple_contractions" for class "ArrayDiagonal"
-     Attribute "split_multiple_contractions" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/tensor/array/expressions/tests/test_convert_array_to_matrix.py:241:15 - error: Cannot access attribute "split_multiple_contractions" for class "ArrayAdd"
-   /tmp/mypy_primer/projects/sympy/sympy/tensor/array/expressions/tests/test_convert_array_to_matrix.py:245:39 - error: Cannot access attribute "split_multiple_contractions" for class "ArrayDiagonal"
-     Attribute "split_multiple_contractions" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/tensor/array/expressions/tests/test_convert_array_to_matrix.py:245:39 - error: Cannot access attribute "split_multiple_contractions" for class "ArrayAdd"
-     Attribute "split_multiple_contractions" is unknown (reportAttributeAccessIssue)
-     Attribute "split_multiple_contractions" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/tensor/array/expressions/tests/test_convert_array_to_matrix.py:249:15 - error: Cannot access attribute "split_multiple_contractions" for class "ArrayDiagonal"
-     Attribute "split_multiple_contractions" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/tensor/array/expressions/tests/test_convert_array_to_matrix.py:249:15 - error: Cannot access attribute "split_multiple_contractions" for class "ArrayAdd"
-   /tmp/mypy_primer/projects/sympy/sympy/tensor/array/expressions/tests/test_convert_array_to_matrix.py:255:15 - error: Cannot access attribute "split_multiple_contractions" for class "ArrayDiagonal"
-     Attribute "split_multiple_contractions" is unknown (reportAttributeAccessIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/tensor/array/expressions/tests/test_convert_array_to_matrix.py:255:15 - error: Cannot access attribute "split_multiple_contractions" for class "ArrayAdd"
-     Attribute "split_multiple_contractions" is unknown (reportAttributeAccessIssue)

... (truncated 268 lines) ...

@erictraut erictraut merged commit bdf1ddc into main Mar 30, 2025
18 checks passed
@erictraut erictraut deleted the issue-10219 branch March 30, 2025 22:05
erictraut added a commit that referenced this pull request Mar 31, 2025
* main:
  Fixed a bug that results in a false negative when a class that derives from `type[Any]` is assigned to any other type. This addresses #10185. (#10224)
  Removed support for `ru` and `ur` string prefixes. These were supported in Python 2.7 but are syntax errors in Python 3.x. This addresses #10222. (#10223)
  Fixed a bug that results in a false negative when the specialization of a TypeVarTuple includes multiple unpacked tuples of unknown length. This addresses #10219. (#10220)
  Extended `reportUnknownVariableType` check to include cases where a value whose type is a generic class parameterized by `Unknown` is assigned to a variable with a declared type. This addresses #10214. (#10217)
  Partly addressed inconsistency between override validation and protocol matching introduced in recent change. (#10215)
  Fix typo in docs (#10213)
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