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

Fixed bug that results in incorrect inferred type for an instance or … #9844

Merged
merged 1 commit into from
Feb 7, 2025

Conversation

erictraut
Copy link
Collaborator

…class variable assigned a value as part of a tuple expression target with an unpack operator (e.g. a, *self.b = (1, 2, 3)). This addresses #9841.

…class variable assigned a value as part of a tuple expression target with an unpack operator (e.g. `a, *self.b = (1, 2, 3)`). This addresses #9841.
Copy link
Contributor

github-actions bot commented Feb 7, 2025

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/vector/dyadic.py:233:7 - error: Base classes for class "DyadicMul" define method "as_content_primitive" in incompatible way
+     Return type mismatch: base method returns type "tuple[One, Self@Expr]", override returns type "tuple[One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Unknown, Self@Mul]"
+       "tuple[One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Unknown, Self@Mul]" is not assignable to "tuple[One, Self@Expr]"
+         Tuple entry 1 is incorrect type
+           Type "One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Unknown" is not assignable to type "One"
+             "ComplexInfinity" is not assignable to "One" (reportIncompatibleMethodOverride)
-     Return type mismatch: base method returns type "tuple[Expr, Expr]", override returns type "tuple[Self@Mul, Zero] | tuple[Zero, Expr] | tuple[Expr, Expr] | tuple[Expr | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Infinity | NegativeInfinity | Float | _NotImplementedType, Expr | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Infinity | NegativeInfinity | Float | _NotImplementedType] | tuple[Expr | Any | Unknown, Expr | Any | Unknown] | tuple[Expr | Any | Unknown | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Infinity | NegativeInfinity | Float | Number, Expr | Any | Unknown | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Infinity | NegativeInfinity | Float | Number] | None"
+     Return type mismatch: base method returns type "tuple[Expr, Expr]", override returns type "tuple[Self@Mul, Zero] | tuple[Zero, Expr] | tuple[Expr, Expr] | tuple[Expr | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Unknown, Expr | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Unknown] | tuple[Expr | Any | Unknown, Expr | Any | Unknown] | tuple[Expr | Any | Unknown | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Infinity | NegativeInfinity | Float | Number, Expr | Any | Unknown | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Infinity | NegativeInfinity | Float | Number] | None"
-       Type "tuple[Self@Mul, Zero] | tuple[Zero, Expr] | tuple[Expr, Expr] | tuple[Expr | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Infinity | NegativeInfinity | Float | _NotImplementedType, Expr | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Infinity | NegativeInfinity | Float | _NotImplementedType] | tuple[Expr | Any | Unknown, Expr | Any | Unknown] | tuple[Expr | Any | Unknown | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Infinity | NegativeInfinity | Float | Number, Expr | Any | Unknown | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Infinity | NegativeInfinity | Float | Number] | None" is not assignable to type "tuple[Expr, Expr]"
+       Type "tuple[Self@Mul, Zero] | tuple[Zero, Expr] | tuple[Expr, Expr] | tuple[Expr | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Unknown, Expr | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Unknown] | tuple[Expr | Any | Unknown, Expr | Any | Unknown] | tuple[Expr | Any | Unknown | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Infinity | NegativeInfinity | Float | Number, Expr | Any | Unknown | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Infinity | NegativeInfinity | Float | Number] | None" is not assignable to type "tuple[Expr, Expr]"
+   /tmp/mypy_primer/projects/sympy/sympy/vector/dyadic.py:253:7 - error: Base classes for class "DyadicAdd" define method "as_content_primitive" in incompatible way
+     Return type mismatch: base method returns type "tuple[One, Self@Expr]", override returns type "tuple[One | NegativeOne | Zero | Integer | Expr | ComplexInfinity | Rational | NaN | Half | Unknown, Expr | Unknown | Self@Add]"
+       "tuple[One | NegativeOne | Zero | Integer | Expr | ComplexInfinity | Rational | NaN | Half | Unknown, Expr | Unknown | Self@Add]" is not assignable to "tuple[One, Self@Expr]"
+         Tuple entry 1 is incorrect type
+           Type "One | NegativeOne | Zero | Integer | Expr | ComplexInfinity | Rational | NaN | Half | Unknown" is not assignable to type "One"
+             "Expr" is not assignable to "One" (reportIncompatibleMethodOverride)
-   /tmp/mypy_primer/projects/sympy/sympy/vector/implicitregion.py:114:20 - error: Operator "**" not supported for "None" (reportOptionalOperand)
-   /tmp/mypy_primer/projects/sympy/sympy/vector/implicitregion.py:114:28 - error: Operator "*" not supported for types "Literal[4]" and "One | Zero | Expr | Unknown | Any | None"
-     Operator "*" not supported for types "Literal[4]" and "None" (reportOperatorIssue)
-   /tmp/mypy_primer/projects/sympy/sympy/vector/implicitregion.py:503:30 - error: "coeff" is not a known attribute of "None" (reportOptionalMemberAccess)
-   /tmp/mypy_primer/projects/sympy/sympy/vector/implicitregion.py:504:30 - error: "coeff" is not a known attribute of "None" (reportOptionalMemberAccess)
-   /tmp/mypy_primer/projects/sympy/sympy/vector/implicitregion.py:505:30 - error: "coeff" is not a known attribute of "None" (reportOptionalMemberAccess)
+   /tmp/mypy_primer/projects/sympy/sympy/vector/vector.py:496:7 - error: Base classes for class "VectorAdd" define method "as_content_primitive" in incompatible way
+     Return type mismatch: base method returns type "tuple[One, Self@Expr]", override returns type "tuple[One | NegativeOne | Zero | Integer | Expr | ComplexInfinity | Rational | NaN | Half | Unknown, Expr | Unknown | Self@Add]"
+       "tuple[One | NegativeOne | Zero | Integer | Expr | ComplexInfinity | Rational | NaN | Half | Unknown, Expr | Unknown | Self@Add]" is not assignable to "tuple[One, Self@Expr]"
+         Tuple entry 1 is incorrect type
+           Type "One | NegativeOne | Zero | Integer | Expr | ComplexInfinity | Rational | NaN | Half | Unknown" is not assignable to type "One"
+             "Expr" is not assignable to "One" (reportIncompatibleMethodOverride)
+   /tmp/mypy_primer/projects/sympy/sympy/vector/vector.py:518:7 - error: Base classes for class "VectorMul" define method "as_content_primitive" in incompatible way
+     Return type mismatch: base method returns type "tuple[One, Self@Expr]", override returns type "tuple[One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Unknown, Self@Mul]"
+       "tuple[One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Unknown, Self@Mul]" is not assignable to "tuple[One, Self@Expr]"
+         Tuple entry 1 is incorrect type
+           Type "One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Unknown" is not assignable to type "One"
+             "ComplexInfinity" is not assignable to "One" (reportIncompatibleMethodOverride)
-     Return type mismatch: base method returns type "tuple[Expr, Expr]", override returns type "tuple[Self@Mul, Zero] | tuple[Zero, Expr] | tuple[Expr, Expr] | tuple[Expr | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Infinity | NegativeInfinity | Float | _NotImplementedType, Expr | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Infinity | NegativeInfinity | Float | _NotImplementedType] | tuple[Expr | Any | Unknown, Expr | Any | Unknown] | tuple[Expr | Any | Unknown | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Infinity | NegativeInfinity | Float | Number, Expr | Any | Unknown | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Infinity | NegativeInfinity | Float | Number] | None"
+     Return type mismatch: base method returns type "tuple[Expr, Expr]", override returns type "tuple[Self@Mul, Zero] | tuple[Zero, Expr] | tuple[Expr, Expr] | tuple[Expr | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Unknown, Expr | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Unknown] | tuple[Expr | Any | Unknown, Expr | Any | Unknown] | tuple[Expr | Any | Unknown | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Infinity | NegativeInfinity | Float | Number, Expr | Any | Unknown | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Infinity | NegativeInfinity | Float | Number] | None"
-       Type "tuple[Self@Mul, Zero] | tuple[Zero, Expr] | tuple[Expr, Expr] | tuple[Expr | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Infinity | NegativeInfinity | Float | _NotImplementedType, Expr | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Infinity | NegativeInfinity | Float | _NotImplementedType] | tuple[Expr | Any | Unknown, Expr | Any | Unknown] | tuple[Expr | Any | Unknown | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Infinity | NegativeInfinity | Float | Number, Expr | Any | Unknown | One | NegativeOne | Zero | Integer | Rational | NaN | ComplexInfinity | Half | Infinity | NegativeInfinity | Float | Number] | None" is not assignable to type "tuple[Expr, Expr]"

... (truncated 3 lines) ...

@erictraut erictraut merged commit fe79092 into main Feb 7, 2025
18 checks passed
@erictraut erictraut deleted the issue-9841 branch February 7, 2025 18:12
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