-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…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.
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) ...
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
…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.