Skip to content

Added support for Sentinel type introduced in draft PEP 661. The `ena…#10574

Merged
erictraut merged 1 commit intomainfrom
issue-10565
Jun 9, 2025
Merged

Added support for Sentinel type introduced in draft PEP 661. The `ena…#10574
erictraut merged 1 commit intomainfrom
issue-10565

Conversation

@erictraut
Copy link
Collaborator

…bleExperimentalFeatures` setting must be set to true to enable this feature. This addresses #10565.

…bleExperimentalFeatures` setting must be set to true to enable this feature. This addresses #10565.
@github-actions
Copy link
Contributor

github-actions bot commented Jun 9, 2025

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

sympy (https://github.com/sympy/sympy)
-   .../projects/sympy/sympy/solvers/tests/test_solveset.py:297:16 - error: Argument of type "Unknown | FiniteSet | Set | Union | Intersection | ConditionSet" cannot be assigned to parameter "obj" of type "Sized" in function "len"
+   .../projects/sympy/sympy/solvers/tests/test_solveset.py:297:16 - error: Argument of type "Unknown | FiniteSet | Set | Union | Intersection | Complement | ConditionSet" cannot be assigned to parameter "obj" of type "Sized" in function "len"
-     Type "Unknown | FiniteSet | Set | Union | Intersection | ConditionSet" is not assignable to type "Sized"
+     Type "Unknown | FiniteSet | Set | Union | Intersection | Complement | ConditionSet" is not assignable to type "Sized"
-   .../projects/sympy/sympy/solvers/tests/test_solveset.py:297:34 - error: Argument of type "Unknown | FiniteSet | Set | Union | Intersection | ConditionSet" cannot be assigned to parameter "obj" of type "Sized" in function "len"
+   .../projects/sympy/sympy/solvers/tests/test_solveset.py:297:34 - error: Argument of type "Unknown | FiniteSet | Set | Union | Intersection | Complement | ConditionSet" cannot be assigned to parameter "obj" of type "Sized" in function "len"
-     Type "Unknown | FiniteSet | Set | Union | Intersection | ConditionSet" is not assignable to type "Sized"
+     Type "Unknown | FiniteSet | Set | Union | Intersection | Complement | ConditionSet" is not assignable to type "Sized"
+   .../projects/sympy/sympy/solvers/tests/test_solveset.py:444:30 - error: Cannot access attribute "limit_denominator" for class "NaN"
+     Attribute "limit_denominator" is unknown (reportAttributeAccessIssue)
+   .../projects/sympy/sympy/solvers/tests/test_solveset.py:444:30 - error: Cannot access attribute "limit_denominator" for class "ComplexInfinity"
+     Attribute "limit_denominator" is unknown (reportAttributeAccessIssue)
-   .../projects/sympy/sympy/solvers/tests/test_solveset.py:2203:16 - error: Argument of type "Unknown | FiniteSet | Set | Union | Intersection | ConditionSet" cannot be assigned to parameter "obj" of type "Sized" in function "len"
+   .../projects/sympy/sympy/solvers/tests/test_solveset.py:2203:16 - error: Argument of type "Unknown | FiniteSet | Set | Union | Intersection | Complement | ConditionSet" cannot be assigned to parameter "obj" of type "Sized" in function "len"
-     Type "Unknown | FiniteSet | Set | Union | Intersection | ConditionSet" is not assignable to type "Sized"
+     Type "Unknown | FiniteSet | Set | Union | Intersection | Complement | ConditionSet" is not assignable to type "Sized"
-   .../projects/sympy/sympy/solvers/tests/test_solveset.py:2284:16 - error: Argument of type "Unknown | FiniteSet | Set | Union | Intersection | ConditionSet" cannot be assigned to parameter "obj" of type "Sized" in function "len"
+   .../projects/sympy/sympy/solvers/tests/test_solveset.py:2284:16 - error: Argument of type "Unknown | FiniteSet | Set | Union | Intersection | Complement | ConditionSet" cannot be assigned to parameter "obj" of type "Sized" in function "len"
-     Type "Unknown | FiniteSet | Set | Union | Intersection | ConditionSet" is not assignable to type "Sized"
+     Type "Unknown | FiniteSet | Set | Union | Intersection | Complement | ConditionSet" is not assignable to type "Sized"
-   .../projects/sympy/sympy/solvers/tests/test_solveset.py:2297:16 - error: Argument of type "Unknown | FiniteSet | Set | Union | Intersection | ConditionSet" cannot be assigned to parameter "obj" of type "Sized" in function "len"
+   .../projects/sympy/sympy/solvers/tests/test_solveset.py:2297:16 - error: Argument of type "Unknown | FiniteSet | Set | Union | Intersection | Complement | ConditionSet" cannot be assigned to parameter "obj" of type "Sized" in function "len"
-     Type "Unknown | FiniteSet | Set | Union | Intersection | ConditionSet" is not assignable to type "Sized"
+     Type "Unknown | FiniteSet | Set | Union | Intersection | Complement | ConditionSet" is not assignable to type "Sized"
-   .../projects/sympy/sympy/solvers/tests/test_solveset.py:2303:16 - error: Argument of type "Unknown | FiniteSet | Set | Union | Intersection | ConditionSet" cannot be assigned to parameter "obj" of type "Sized" in function "len"
+   .../projects/sympy/sympy/solvers/tests/test_solveset.py:2303:16 - error: Argument of type "Unknown | FiniteSet | Set | Union | Intersection | Complement | ConditionSet" cannot be assigned to parameter "obj" of type "Sized" in function "len"
-     Type "Unknown | FiniteSet | Set | Union | Intersection | ConditionSet" is not assignable to type "Sized"
+     Type "Unknown | FiniteSet | Set | Union | Intersection | Complement | ConditionSet" is not assignable to type "Sized"
-   .../projects/sympy/sympy/solvers/tests/test_solveset.py:2408:16 - error: Argument of type "Unknown | Set | FiniteSet | Union | Intersection | ConditionSet" cannot be assigned to parameter "obj" of type "Sized" in function "len"
+   .../projects/sympy/sympy/solvers/tests/test_solveset.py:2408:16 - error: Argument of type "Unknown | Set | FiniteSet | Union | Intersection | Complement | ConditionSet" cannot be assigned to parameter "obj" of type "Sized" in function "len"
-     Type "Unknown | Set | FiniteSet | Union | Intersection | ConditionSet" is not assignable to type "Sized"
+     Type "Unknown | Set | FiniteSet | Union | Intersection | Complement | ConditionSet" is not assignable to type "Sized"
-   .../projects/sympy/sympy/solvers/tests/test_solveset.py:2470:16 - error: Argument of type "Unknown | FiniteSet | Set | Union | Intersection | ConditionSet" cannot be assigned to parameter "obj" of type "Sized" in function "len"
+   .../projects/sympy/sympy/solvers/tests/test_solveset.py:2470:16 - error: Argument of type "Unknown | FiniteSet | Set | Union | Intersection | Complement | ConditionSet" cannot be assigned to parameter "obj" of type "Sized" in function "len"
-     Type "Unknown | FiniteSet | Set | Union | Intersection | ConditionSet" is not assignable to type "Sized"
+     Type "Unknown | FiniteSet | Set | Union | Intersection | Complement | ConditionSet" is not assignable to type "Sized"
+   .../projects/sympy/sympy/stats/crv.py:132:56 - error: Cannot access attribute "left" for class "Complement"
+     Attribute "left" is unknown (reportAttributeAccessIssue)
+     Attribute "right" is unknown (reportAttributeAccessIssue)
+   .../projects/sympy/sympy/stats/crv.py:132:68 - error: Cannot access attribute "right" for class "Complement"
-   .../projects/sympy/sympy/stats/drv.py:268:22 - error: Argument of type "Generator[tuple[Unknown, ...] | Unknown | Sum | Expr | Any | Zero | NaN | Piecewise | Basic | int | None, None, None]" cannot be assigned to parameter "iterable" of type "Iterable[_SupportsSumNoDefaultT@sum]" in function "sum"
+   .../projects/sympy/sympy/stats/drv.py:268:22 - error: Argument of type "Generator[tuple[Unknown, ...] | Unknown | Sum | Zero | NaN | Piecewise | Basic | int | None, None, None]" cannot be assigned to parameter "iterable" of type "Iterable[_SupportsSumNoDefaultT@sum]" in function "sum"
-     "Generator[tuple[Unknown, ...] | Unknown | Sum | Expr | Any | Zero | NaN | Piecewise | Basic | int | None, None, None]" is not assignable to "Iterable[_SupportsSumNoDefaultT@sum]"
+     "Generator[tuple[Unknown, ...] | Unknown | Sum | Zero | NaN | Piecewise | Basic | int | None, None, None]" is not assignable to "Iterable[_SupportsSumNoDefaultT@sum]"
-       Type parameter "_T_co@Iterable" is covariant, but "tuple[Unknown, ...] | Unknown | Sum | Expr | Any | Zero | NaN | Piecewise | Basic | int | None" is not a subtype of "_SupportsSumNoDefaultT@sum"
+       Type parameter "_T_co@Iterable" is covariant, but "tuple[Unknown, ...] | Unknown | Sum | Zero | NaN | Piecewise | Basic | int | None" is not a subtype of "_SupportsSumNoDefaultT@sum"
-         Type "tuple[Unknown, ...] | Unknown | Sum | Expr | Any | Zero | NaN | Piecewise | Basic | int | None" is not assignable to type "_SupportsSumWithNoDefaultGiven"
+         Type "tuple[Unknown, ...] | Unknown | Sum | Zero | NaN | Piecewise | Basic | int | None" is not assignable to type "_SupportsSumWithNoDefaultGiven"
-           Type "tuple[Unknown, ...] | Unknown | Sum | Expr | Any | Zero | NaN | Piecewise | Basic | int | None" is not assignable to type "_SupportsSumWithNoDefaultGiven"
+           Type "tuple[Unknown, ...] | Unknown | Sum | Zero | NaN | Piecewise | Basic | int | None" is not assignable to type "_SupportsSumWithNoDefaultGiven"
-   .../projects/sympy/sympy/stats/joint_rv_types.py:575:27 - error: Argument of type "One | NegativeOne | Zero | Integer | NaN | ComplexInfinity | Rational | Unknown | Number | Expr" cannot be assigned to parameter "stop" of type "SupportsIndex" in function "__new__"
+   .../projects/sympy/sympy/stats/joint_rv_types.py:575:27 - error: Argument of type "One | NegativeOne | Zero | Integer | NaN | ComplexInfinity | Rational | Infinity | NegativeInfinity | Float | Number | Expr" cannot be assigned to parameter "stop" of type "SupportsIndex" in function "__new__"
-     Type "One | NegativeOne | Zero | Integer | NaN | ComplexInfinity | Rational | Unknown | Number | Expr" is not assignable to type "SupportsIndex"
+     Type "One | NegativeOne | Zero | Integer | NaN | ComplexInfinity | Rational | Infinity | NegativeInfinity | Float | Number | Expr" is not assignable to type "SupportsIndex"
-   .../projects/sympy/sympy/stats/rv.py:473:25 - error: Argument of type "Expr | Lambda | Zero | One | Integral | Unknown | Probability | tuple[Unknown, ...] | Sum | Any | NaN | Piecewise | Basic | NegativeOne | Integer | ComplexInfinity | Rational | Number | Infinity | NegativeInfinity | int" cannot be assigned to parameter "args" of type "Expr | complex" in function "__new__"

... (truncated 891 lines) ...

@erictraut erictraut merged commit 6ecb8f2 into main Jun 9, 2025
17 checks passed
@erictraut erictraut deleted the issue-10565 branch June 9, 2025 22:15
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