Skip to content

Fixed regression that resulted in a false positive error when using `…#10791

Merged
erictraut merged 1 commit intomainfrom
Issue-10490
Aug 13, 2025
Merged

Fixed regression that resulted in a false positive error when using `…#10791
erictraut merged 1 commit intomainfrom
Issue-10490

Conversation

@erictraut
Copy link
Collaborator

…reportUninitializedInstanceVariablewith aNamedTuple` class. This addresses #10490.

…reportUninitializedInstanceVariable` with a `NamedTuple` class. This addresses #10490.
@github-actions
Copy link
Contributor

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

sympy (https://github.com/sympy/sympy)
-   .../projects/sympy/sympy/polys/numberfields/tests/test_minpoly.py:183:17 - error: Operator "*" not supported for types "Unknown | int" and "Unknown | int | None"
+   .../projects/sympy/sympy/polys/numberfields/tests/test_minpoly.py:183:17 - error: Operator "*" not supported for types "int | Unknown" and "int | None"
-   .../projects/sympy/sympy/polys/numberfields/tests/test_minpoly.py:184:17 - error: Operator "*" not supported for types "Unknown | int" and "Unknown | int | None"
+   .../projects/sympy/sympy/polys/numberfields/tests/test_minpoly.py:184:17 - error: Operator "*" not supported for types "int | Unknown" and "int | None"
+   .../projects/sympy/sympy/polys/numberfields/tests/test_subfield.py:303:7 - error: Cannot access attribute "_reset" for class "One"
+     Attribute "_reset" is unknown (reportAttributeAccessIssue)
+   .../projects/sympy/sympy/polys/numberfields/tests/test_subfield.py:303:7 - error: Cannot access attribute "_reset" for class "NegativeOne"
+     Attribute "_reset" is unknown (reportAttributeAccessIssue)
+   .../projects/sympy/sympy/polys/numberfields/tests/test_subfield.py:303:7 - error: Cannot access attribute "_reset" for class "Zero"
+     Attribute "_reset" is unknown (reportAttributeAccessIssue)
+     Attribute "_reset" is unknown (reportAttributeAccessIssue)
+   .../projects/sympy/sympy/polys/numberfields/tests/test_subfield.py:303:7 - error: Cannot access attribute "_reset" for class "NaN"
+     Attribute "_reset" is unknown (reportAttributeAccessIssue)
+   .../projects/sympy/sympy/polys/numberfields/tests/test_subfield.py:303:7 - error: Cannot access attribute "_reset" for class "ComplexInfinity"
+     Attribute "_reset" is unknown (reportAttributeAccessIssue)
+   .../projects/sympy/sympy/polys/numberfields/tests/test_subfield.py:303:7 - error: Cannot access attribute "_reset" for class "Rational"
+     Attribute "_reset" is unknown (reportAttributeAccessIssue)
+   .../projects/sympy/sympy/polys/numberfields/tests/test_subfield.py:303:7 - error: Cannot access attribute "_reset" for class "Infinity"
+     Attribute "_reset" is unknown (reportAttributeAccessIssue)
+   .../projects/sympy/sympy/polys/numberfields/tests/test_subfield.py:303:7 - error: Cannot access attribute "_reset" for class "NegativeInfinity"
+     Attribute "_reset" is unknown (reportAttributeAccessIssue)
+   .../projects/sympy/sympy/polys/numberfields/tests/test_subfield.py:303:7 - error: Cannot access attribute "_reset" for class "Float"
+     Attribute "_reset" is unknown (reportAttributeAccessIssue)
+   .../projects/sympy/sympy/polys/numberfields/tests/test_subfield.py:303:7 - error: Cannot access attribute "_reset" for class "Expr"
+   .../projects/sympy/sympy/polys/series/tests/test_hypothesis.py:102:57 - error: Cannot access attribute "to_dense" for class "tuple[Unknown, ...]"
-   .../projects/sympy/sympy/polys/series/tests/test_hypothesis.py:111:57 - error: Cannot access attribute "to_dense" for class "tuple[Unknown, ...]"
-     Attribute "to_dense" is unknown (reportAttributeAccessIssue)
-   .../projects/sympy/sympy/polys/series/tests/test_hypothesis.py:112:59 - error: Cannot access attribute "to_dense" for class "tuple[Unknown, ...]"
-     Attribute "to_dense" is unknown (reportAttributeAccessIssue)
-   .../projects/sympy/sympy/polys/series/tests/test_hypothesis.py:113:57 - error: Cannot access attribute "to_dense" for class "tuple[Unknown, ...]"
-     Attribute "to_dense" is unknown (reportAttributeAccessIssue)
-   .../projects/sympy/sympy/polys/series/tests/test_hypothesis.py:114:59 - error: Cannot access attribute "to_dense" for class "tuple[Unknown, ...]"
-     Attribute "to_dense" is unknown (reportAttributeAccessIssue)
-     Attribute "to_dense" is unknown (reportAttributeAccessIssue)
-   .../projects/sympy/sympy/polys/series/tests/test_ring.py:1117:55 - error: Cannot access attribute "to_dense" for class "tuple[Unknown, ...]"
-     Attribute "to_dense" is unknown (reportAttributeAccessIssue)
-   .../projects/sympy/sympy/polys/series/tests/test_ring.py:1118:63 - error: Cannot access attribute "to_dense" for class "tuple[Unknown, ...]"
-     Attribute "to_dense" is unknown (reportAttributeAccessIssue)
-   .../projects/sympy/sympy/polys/series/tests/test_ring.py:1119:55 - error: Cannot access attribute "to_dense" for class "tuple[Unknown, ...]"
-   .../projects/sympy/sympy/polys/series/tests/test_ring.py:1120:63 - error: Cannot access attribute "to_dense" for class "tuple[Unknown, ...]"
+   .../projects/sympy/sympy/solvers/diophantine/tests/test_diophantine.py:313:75 - error: "args" is not a known attribute of "None" (reportOptionalMemberAccess)
+   .../projects/sympy/sympy/solvers/diophantine/tests/test_diophantine.py:379:15 - error: Operator "*" not supported for "None" (reportOptionalOperand)
+   .../projects/sympy/sympy/solvers/diophantine/tests/test_diophantine.py:382:13 - error: No overloads for "__init__" match the provided arguments (reportCallIssue)
+   .../projects/sympy/sympy/solvers/diophantine/tests/test_diophantine.py:382:18 - error: Argument of type "list[Iterator[Unknown]]" cannot be assigned to parameter "iterable" of type "Iterable[list[bytes]]" in function "__init__" (reportArgumentType)
+   .../projects/sympy/sympy/solvers/diophantine/tests/test_diophantine.py:382:78 - error: "args" is not a known attribute of "None" (reportOptionalMemberAccess)
-   .../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:1030:70 - error: Argument of type "Unknown | Basic" cannot be assigned to parameter "obj" of type "Sized" in function "len"
+   .../projects/sympy/sympy/tensor/array/expressions/array_expressions.py:1030:70 - error: Argument of type "Unknown | Tuple | Basic" cannot be assigned to parameter "obj" of type "Sized" in function "len"
-     Type "Unknown | Basic" is not assignable to type "Sized"
+     Type "Unknown | Tuple | Basic" is not assignable to type "Sized"
+   .../projects/sympy/sympy/tensor/array/expressions/array_expressions.py:1030:80 - error: No overloads for "__getitem__" match the provided arguments (reportCallIssue)
+   .../projects/sympy/sympy/tensor/array/expressions/array_expressions.py:1030:80 - error: Argument of type "Unknown | Tuple" cannot be assigned to parameter "key" of type "slice[Any, Any, Any]" in function "__getitem__"
+     Type "Unknown | Tuple" is not assignable to type "slice[Any, Any, Any]"
+       "Tuple" is not assignable to "slice[Any, Any, Any]" (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:34:2 - error: Argument of type "(expr: ArrayTensorProduct, x: Expr) -> (Unknown | Zero)" cannot be assigned to parameter of type "(...) -> NoReturn"
+   .../projects/sympy/sympy/tensor/array/expressions/arrayexpr_derivatives.py:34:2 - error: Argument of type "(expr: ArrayTensorProduct, x: Expr) -> (Unknown | Zero | ZeroArray | ArrayAdd)" cannot be assigned to parameter of type "(...) -> NoReturn"
-     Type "(expr: ArrayTensorProduct, x: Expr) -> (Unknown | Zero)" is not assignable to type "(...) -> NoReturn"
+     Type "(expr: ArrayTensorProduct, x: Expr) -> (Unknown | Zero | ZeroArray | ArrayAdd)" is not assignable to type "(...) -> NoReturn"
-       Function return type "Unknown | Zero" is incompatible with type "NoReturn"
+       Function return type "Unknown | Zero | ZeroArray | ArrayAdd" is incompatible with type "NoReturn"
-         Type "Unknown | Zero" is not assignable to type "NoReturn"
+         Type "Unknown | Zero | ZeroArray | ArrayAdd" is not assignable to type "NoReturn"
-           Type "Zero" is not assignable to type "NoReturn" (reportArgumentType)
+           Type "ArrayAdd" is not assignable to type "NoReturn" (reportArgumentType)
-   .../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)

... (truncated 295 lines) ...

@erictraut erictraut merged commit b8688e7 into main Aug 13, 2025
16 checks passed
@erictraut erictraut deleted the Issue-10490 branch August 13, 2025 05:14
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