Repository navigation
Preserve union-expanded constructor types - #11621
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
🔒 Automated review in progress — Stella Huang (@StellaHuang95) is auto-reviewing this PR. |
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
|
GitHub cannot anchor PR review comments to unchanged lines in the diff. Falling back to a general PR comment for packages/pyright-internal/src/tests/samples/overloadCall12.py:L227.
Add coverage for a union of two definitive branches that both rely only on the |
Stella Huang (StellaHuang95)
left a comment
There was a problem hiding this comment.
Approved via Review Center.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Diff from mypy_primer, showing the effect of this PR on open source code: sympy (https://github.com/sympy/sympy)
+ .../projects/sympy/sympy/simplify/sqrtdenest.py:157:19 - error: Operator "**" not supported for types "Basic" and "Literal[2]" (reportOperatorIssue)
+ .../projects/sympy/sympy/simplify/sqrtdenest.py:200:48 - error: Argument of type "Basic" cannot be assigned to parameter "args" of type "Expr | complex" in function "__new__"
+ Type "Basic" is not assignable to type "Expr | complex"
+ "Basic" is not assignable to "Expr"
+ "Basic" is not assignable to "complex" (reportArgumentType)
+ .../projects/sympy/sympy/simplify/sqrtdenest.py:207:26 - error: Operator "**" not supported for types "Unknown | Mul | Basic" and "Literal[2]"
- .../projects/sympy/sympy/simplify/sqrtdenest.py:309:10 - error: Operator "+" not supported for types "Expr" and "Unknown | Expr | Mul | None"
- Operator "+" not supported for types "Expr" and "None" (reportOperatorIssue)
- .../projects/sympy/sympy/simplify/sqrtdenest.py:340:19 - error: Operator "-" not supported for types "Expr | Unknown | GaussianRational | One | NegativeOne | Zero | Integer | MPQ | GaussianInteger | MPZ | Poly | NotImplementedType | ANP[MPQ]" and "Expr | Unknown | NotImplementedType | GaussianRational | One | NegativeOne | Zero | Integer | NaN | ComplexInfinity | Rational | Infinity | NegativeInfinity | Float | MPQ | GaussianInteger | MPZ | Poly"
- Operator "-" not supported for types "Expr" and "GaussianRational"
- Operator "-" not supported for types "Expr" and "MPQ"
- Operator "-" not supported for types "Expr" and "GaussianInteger"
- Operator "-" not supported for types "Expr" and "MPZ"
- Operator "-" not supported for types "GaussianRational" and "Expr"
- Operator "-" not supported for types "GaussianRational" and "NaN"
- Operator "-" not supported for types "GaussianRational" and "ComplexInfinity"
- Operator "-" not supported for types "GaussianRational" and "Rational"
- ... (reportOperatorIssue)
- .../projects/sympy/sympy/simplify/sqrtdenest.py:340:26 - error: Operator "*" not supported for types "Expr | Unknown | GaussianRational | One | NegativeOne | Zero | Integer | MPQ | GaussianInteger | MPZ | Poly | NotImplementedType | ANP[MPQ]" and "Expr | Unknown | NotImplementedType | GaussianRational | One | NegativeOne | Zero | Integer | NaN | ComplexInfinity | Rational | MPQ | GaussianInteger | MPZ | Infinity | NegativeInfinity | Float | Poly | Alg | Number"
- Operator "*" not supported for types "Expr" and "GaussianRational"
- Operator "*" not supported for types "Expr" and "MPQ"
- Operator "*" not supported for types "Expr" and "GaussianInteger"
- Operator "*" not supported for types "Expr" and "MPZ"
- Operator "*" not supported for types "GaussianRational" and "Expr"
- Operator "*" not supported for types "GaussianRational" and "NaN"
- Operator "*" not supported for types "GaussianRational" and "ComplexInfinity"
- Operator "*" not supported for types "GaussianRational" and "Rational"
- ... (reportOperatorIssue)
- .../projects/sympy/sympy/simplify/sqrtdenest.py:341:11 - error: Cannot access attribute "is_Rational" for class "GaussianRational"
- Attribute "is_Rational" is unknown (reportAttributeAccessIssue)
- .../projects/sympy/sympy/simplify/sqrtdenest.py:341:11 - error: Cannot access attribute "is_Rational" for class "MPQ"
- Attribute "is_Rational" is unknown (reportAttributeAccessIssue)
- .../projects/sympy/sympy/simplify/sqrtdenest.py:341:11 - error: Cannot access attribute "is_Rational" for class "GaussianInteger"
- Attribute "is_Rational" is unknown (reportAttributeAccessIssue)
- .../projects/sympy/sympy/simplify/sqrtdenest.py:341:11 - error: Cannot access attribute "is_Rational" for class "MPZ"
- Attribute "is_Rational" is unknown (reportAttributeAccessIssue)
- .../projects/sympy/sympy/simplify/sqrtdenest.py:341:11 - error: Cannot access attribute "is_Rational" for class "ANP[MPQ]"
- Attribute "is_Rational" is unknown (reportAttributeAccessIssue)
- .../projects/sympy/sympy/simplify/sqrtdenest.py:342:15 - error: Cannot access attribute "is_positive" for class "GaussianRational"
- Attribute "is_positive" is unknown (reportAttributeAccessIssue)
- .../projects/sympy/sympy/simplify/sqrtdenest.py:342:15 - error: Cannot access attribute "is_positive" for class "MPQ"
- Attribute "is_positive" is unknown (reportAttributeAccessIssue)
- .../projects/sympy/sympy/simplify/sqrtdenest.py:342:15 - error: Cannot access attribute "is_positive" for class "GaussianInteger"
- Attribute "is_positive" is unknown (reportAttributeAccessIssue)
- .../projects/sympy/sympy/simplify/sqrtdenest.py:342:15 - error: Cannot access attribute "is_positive" for class "MPZ"
- Attribute "is_positive" is unknown (reportAttributeAccessIssue)
- .../projects/sympy/sympy/simplify/sqrtdenest.py:342:15 - error: Cannot access attribute "is_positive" for class "ANP[MPQ]"
- Attribute "is_positive" is unknown (reportAttributeAccessIssue)
- .../projects/sympy/sympy/simplify/sqrtdenest.py:350:28 - error: Operator "*" not supported for types "Unknown | Expr | GaussianRational | NegativeOne | One | Zero | Integer | NaN | ComplexInfinity | Rational | NegativeInfinity | Infinity | Float | Number | MPQ | GaussianInteger | MPZ | Poly | ANP[MPQ]" and "Expr | Unknown | NotImplementedType | GaussianRational | One | NegativeOne | Zero | Integer | NaN | ComplexInfinity | Rational | MPQ | GaussianInteger | MPZ | Infinity | NegativeInfinity | Float | Poly | Alg | Number"
- Operator "*" not supported for types "Expr" and "GaussianRational"
- Operator "*" not supported for types "Expr" and "MPQ"
- Operator "*" not supported for types "Expr" and "GaussianInteger"
- Operator "*" not supported for types "Expr" and "MPZ"
- Operator "*" not supported for types "GaussianRational" and "Expr"
- Operator "*" not supported for types "GaussianRational" and "NaN"
- Operator "*" not supported for types "GaussianRational" and "ComplexInfinity"
- Operator "*" not supported for types "GaussianRational" and "Rational"
- ... (reportOperatorIssue)
- .../projects/sympy/sympy/simplify/sqrtdenest.py:353:51 - error: Operator "*" not supported for types "Expr | Unknown | NotImplementedType | GaussianRational | One | NegativeOne | Zero | Integer | NaN | ComplexInfinity | Rational | MPQ | GaussianInteger | MPZ | Infinity | NegativeInfinity | Float | Poly | Alg | Number" and "Expr | Unknown | NotImplementedType | GaussianRational | One | NegativeOne | Zero | Integer | NaN | ComplexInfinity | Rational | MPQ | GaussianInteger | MPZ | Infinity | NegativeInfinity | Float | Poly | Alg | Number"
- Operator "*" not supported for types "Expr" and "GaussianRational"
- Operator "*" not supported for types "Expr" and "MPQ"
- Operator "*" not supported for types "Expr" and "GaussianInteger"
- Operator "*" not supported for types "Expr" and "MPZ"
- Operator "*" not supported for types "GaussianRational" and "Expr"
- Operator "*" not supported for types "GaussianRational" and "NaN"
- Operator "*" not supported for types "GaussianRational" and "ComplexInfinity"
- Operator "*" not supported for types "GaussianRational" and "Rational"
- ... (reportOperatorIssue)
- .../projects/sympy/sympy/simplify/sqrtdenest.py:431:42 - error: Operator "-" not supported for types "Expr" and "Expr | Unknown | NotImplementedType | GaussianRational | One | NegativeOne | Zero | Integer | NaN | ComplexInfinity | Rational | MPQ | GaussianInteger | MPZ | Infinity | NegativeInfinity | Float | Poly | Alg | Number"
- Operator "-" not supported for types "Expr" and "GaussianRational"
- Operator "-" not supported for types "Expr" and "MPQ"
- Operator "-" not supported for types "Expr" and "GaussianInteger"
- Operator "-" not supported for types "Expr" and "MPZ" (reportOperatorIssue)
- .../projects/sympy/sympy/simplify/sqrtdenest.py:597:24 - error: Operator "-" not supported for types "Unknown | One | NegativeOne | Zero | Integer | Expr | None" and "Unknown | One | NegativeOne | Zero | Integer | NaN | ComplexInfinity | Rational | Infinity | NegativeInfinity | Float | None"
+ .../projects/sympy/sympy/simplify/sqrtdenest.py:597:24 - error: Operator "-" not supported for types "Expr | Unknown | None" and "Expr | Unknown | None"
- Operator "-" not supported for types "None" and "NaN"
+ Operator "-" not supported for types "None" and "Expr"
- Operator "-" not supported for types "None" and "ComplexInfinity"
- Operator "-" not supported for types "None" and "Rational"
- Operator "-" not supported for types "None" and "Infinity"
- Operator "-" not supported for types "None" and "NegativeInfinity"
- Operator "-" not supported for types "None" and "Float"
- .../projects/sympy/sympy/simplify/sqrtdenest.py:626:49 - error: Operator "*" not supported for types "Expr | Unknown | GaussianRational | NegativeOne | One | Zero | Integer | NaN | ComplexInfinity | Rational | MPQ | GaussianInteger | MPZ | NegativeInfinity | Infinity | Float | Poly | ANP[MPQ] | Number | NotImplementedType" and "Expr"
- Operator "*" not supported for types "GaussianRational" and "Expr"
- Operator "*" not supported for types "MPQ" and "Expr"
- Operator "*" not supported for types "GaussianInteger" and "Expr"
- Operator "*" not supported for types "MPZ" and "Expr" (reportOperatorIssue)
- .../projects/sympy/sympy/simplify/sqrtdenest.py:635:50 - error: Operator "*" not supported for types "Expr | Unknown | GaussianRational | NegativeOne | One | Zero | Integer | NaN | ComplexInfinity | Rational | MPQ | GaussianInteger | MPZ | NegativeInfinity | Infinity | Float | Poly | ANP[MPQ] | Number | NotImplementedType" and "Mul | Expr"
- Operator "*" not supported for types "GaussianRational" and "Mul"
- Operator "*" not supported for types "GaussianRational" and "Expr"
... (truncated 626 lines) ...
bidict (https://github.com/jab/bidict)
- .../projects/bidict/bidict/_base.py
- .../projects/bidict/bidict/_base.py:550:34 - error: No overloads for "__init__" match the provided arguments (reportCallIssue)
- .../projects/bidict/bidict/_base.py:550:39 - error: Argument of type "BidictBase[VT@BidictBase, KT@BidictBase]*" cannot be assigned to parameter "map" of type "SupportsKeysAndGetItem[_KT@dict, _VT@dict]" in function "__init__"
- "BidictBase[VT@BidictBase, KT@BidictBase]*" is incompatible with protocol "SupportsKeysAndGetItem[_KT@dict, _VT@dict]"
- Type parameter "_KT@SupportsKeysAndGetItem" is invariant, but "VT@BidictBase" is not the same as "_KT@dict" (reportArgumentType)
- .../projects/bidict/bidict/_base.py:550:39 - error: Argument of type "BidictBase[VT@BidictBase, KT@BidictBase]* | Self@BidictBase[KT@BidictBase, VT@BidictBase]" cannot be assigned to parameter "iterable" of type "Iterable[list[bytes]]" in function "__init__"
- Type "BidictBase[VT@BidictBase, KT@BidictBase]* | BidictBase[KT@BidictBase, VT@BidictBase]*" is not assignable to type "Iterable[list[bytes]]"
- "BidictBase[KT@BidictBase, VT@BidictBase]*" is not assignable to "Iterable[list[bytes]]"
- Type parameter "_T_co@Iterable" is covariant, but "KT@BidictBase" is not a subtype of "list[bytes]"
- "object*" is not assignable to "list[bytes]" (reportArgumentType)
- 8 errors, 1 warning, 0 informations
+ 5 errors, 1 warning, 0 informations
|
Stella Huang (StellaHuang95)
left a comment
There was a problem hiding this comment.
Approved via Review Center.
…11739) * Revert nested overload materialization and dependent checker fixes Selectively roll back #11601, #11621, and checker-only #11732 while preserving primer-analysis tooling and independent subsequent fixes. Retain regression fixtures and document the restored conformance, constructor, and protocol-operation limitations in current-behavior expectations. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Restore matching gh-aw compiler and runtime for primer analysis Regenerate with v0.86.2, preserve current artifact action versions, and prevent standalone runtime bumps with a narrow Dependabot ignore and workflow consistency coverage. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Preserve constructor constraints and results across union branches Replay each expanded argument using its own overload constraints and retain definitive constructed union branches. Fix the reproduced Werkzeug Mapping-to-dict regression without restoring nested overload materialization, and retain precise positive and negative regression coverage. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Summary
__init__branch's effective specialized self type, including definitive and single-possible branchesNone__init__placeholderFollow-up to #11601. This addresses the unresolved review finding in #11601 (comment), where a later definitive branch such as
Table[bytes]was omitted once an earlier materialization-ambiguous branch populated the separate constructor handoff.Tests
npx jest typeEvaluator6.test -t "OverloadCall12" --runInBand --forceExitnpx jest typeEvaluator6.test -t "OverloadCall(6|11|12)|Constructor" --runInBand --forceExitnpm run build(packages/pyright-internal)npm run typecheck