Skip to content

Fix NewType identity comparisons with base literals - #11491

Merged
Rich Chiodo (rchiodo) merged 4 commits into
microsoft:mainfrom
KirtiRamchandani:fix/newtype-is-literal-11463
Jun 23, 2026
Merged

Rich Chiodo (rchiodo) merged 4 commits into
microsoft:mainfrom
KirtiRamchandani:fix/newtype-is-literal-11463

Conversation

@KirtiRamchandani

Copy link
Copy Markdown
Contributor

Summary

Fixes pyright treating valid is comparisons between NewType instances and their underlying base literals as unreachable.

Problem

Banana = NewType("Banana", bool)

def f(b: Banana) -> None:
    if b is True:  # incorrectly marked unreachable
        reveal_type(b)

Fix

Compare NewType instances against their underlying base types when evaluating is narrowing for literals and None.

Testing

  • Added newTypeIsLiteral1.py + NewType8 test (0 errors expected)

Fixes #11463

Treat NewType instances as comparable to their underlying base literals in
is/narrowing checks so valid runtime comparisons are not marked unreachable.

Fixes microsoft#11463
@KirtiRamchandani
Kirtikumar Anandrao Ramchandani (KirtiRamchandani) marked this pull request as ready for review June 15, 2026 07:13
if (isIsOperator || isNoneInstance(subtype)) {
const isSubtype = evaluator.assignType(subtype, literalType);
return isSubtype ? literalType : undefined;
let compareType: Type = subtype;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot generated:
The Skeptic execution-verified that the fix only unwraps one level of NewType. For X = NewType("X", bool) then Y = NewType("Y", X), y is True is still marked unreachable: compareType becomes the inner NewType X, so assignType(X, Literal[True]) is false → returns undefined → dead branch. This is the exact bug class this PR fixes, one level deeper. Either walk the NewType base chain to the ultimate non-NewType base (a loop / shared helper) and add a nested-NewType row to newTypeIsLiteral1.py, or document the single-level limitation explicitly.

[verified]


const adjustedSubtype = useExpandedSubtype ? subtype : unexpandedSubtype;

// NewType instances can be identity-compared with their underlying base type.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot generated:
The Architect notes this new block re-implements None-detection (isNoneInstance + assignType(..., getNoneType())) that already exists in the original checks ~10 lines below. Preferred direction: unwrap the NewType to its base instance once and let the existing exact-None / potentially-None checks run against it, returning the original NewType subtype on the positive branch — mirroring the cleaner structure the literal-comparison hunk already uses. This collapses two parallel None paths into one.

[verified]

const baseInstance = ClassType.cloneAsInstance(baseClass);
if (isNoneInstance(baseInstance)) {
resultIncludesNoneSubtype = true;
return isPositiveTest ? adjustedSubtype : undefined;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot generated:
[unverified] The Skeptic flagged an identity inconsistency: when the base is NoneType (Apple case), this returns the NewType (adjustedSubtype), but when the base merely contains None (e.g. NewType("Obj", object)), the positive branch returns bare None via addConditionToType(getNoneType(), …) instead of the NewType. This diverges from the literal-comparison path, which always returns the NewType subtype on a positive match. Make this a deliberate decision and add a test either way.

[verified]

const isSubtype = evaluator.assignType(subtype, literalType);
return isSubtype ? literalType : undefined;
let compareType: Type = subtype;
if (isClassInstance(subtype) && ClassType.isNewTypeClass(subtype) && subtype.shared.baseClasses.length > 0) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot generated:
The Architect, Skeptic, and Advocate all note the NewType-unwrap pattern (isClassInstance(x) && isNewTypeClass(x) && baseClasses.length > 0 → cloneAsInstance(baseClasses[0])) is open-coded in both hunks, with isNewTypeClass checked a third time in this return ternary. Extracting a single getNewTypeBaseInstance(t): ClassType | undefined helper localizes the new dependency on the baseClasses[0] synthesis invariant (createNewType, typeEvaluator.ts:13788) to one place and makes the two hunks obviously symmetric.

[verified]


const adjustedSubtype = useExpandedSubtype ? subtype : unexpandedSubtype;

// NewType instances can be identity-compared with their underlying base type.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot generated:
Nit (Advocate, structurally confirmed): the new guard line is ~145 columns including indentation, past the repo's printWidth: 120. Prettier will reflow it, so npm run check may bounce until fix:prettier is run. Mechanical — resolve before CI.

[verified]

Cherry = NewType("Cherry", int)


def f(a: Apple, b: Banana, c: Cherry) -> None:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot generated:
The Advocate flags positive-only coverage. The sample exercises only positive is branches; there is no coverage for the negative branch (b is not True), for a NewType inside a union, for a nested NewType (NewType("Y", X) — see the verified gap above), or the NewType("Obj", object) is None identity case. Adding these would lock in the intended behavior and guard against the residual gaps the reviewers identified.

[verified]

: adjustedSubtype;
}
}
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📍 packages/pyright-internal/src/analyzer/typeGuards.ts:1131
The is None fix does not fix its own primary scenario and produces the opposite of correct narrowing. For Apple = NewType("Apple", NoneType), if a is None: should be the reachable branch (Apple), but the positive branch collapses to Never. The first sub-branch returns adjustedSubtype (the NewType instance, a non-None type) while setting resultIncludesNoneSubtype = true; the unchanged post-filter at lines 1152-1156 (isNoneInstance(st) ? st : undefined) then strips that subtype — isNoneInstance is false for a NewType because it lacks the BuiltIn flag — yielding Never. Fix: for the isNoneInstance(baseInstance) case the positive result must be a value the post-filter keeps (a None instance carrying the NewType identity), or skip setting resultIncludesNoneSubtype and return the NewType directly.

[verified]


def f(a: Apple, b: Banana, c: Cherry) -> None:
if a is None:
reveal_type(a, expected_text="Apple")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📍 packages/pyright-internal/src/tests/samples/newTypeIsLiteral1.py:12
This assertion is vacuous and hides the functional bug. Because if a is None: is unreachable (see typeGuards.ts:1131), pyright never evaluates reveal_type(a, expected_text="Apple"), so the expected_text check never fires — flipping the literal to expected_text="WRONG_XYZ" still passes with 0 errors. A reveal_type in dead code is not an assertion. Add negative coverage that fails when the branch is unreachable (e.g. a statement after the block that depends on the narrowed binding, or assert the else branch type) so a Never regression can't pass silently.

[verified]


if (evaluator.assignType(baseInstance, evaluator.getNoneType())) {
resultIncludesNoneSubtype = true;
return isPositiveTest

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📍 packages/pyright-internal/src/analyzer/typeGuards.ts:1137
For a NewType over a None-compatible non-None base (e.g. ObjNT = NewType("ObjNT", object)), if o is None: narrows to bare None, dropping the ObjNT brand. This is inconsistent with the literal path (line 2773), which deliberately preserves the NewType identity. The behavior mirrors existing base-None narrowing so it may be defensible, but the two newly added paths answer "preserve NewType identity?" differently. Decide the intended behavior, add a test for this path (currently untested), and add a one-line comment explaining the divergence so a future reader doesn't mistake it for a bug.

[verified]

: adjustedSubtype;
}
}
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📍 packages/pyright-internal/src/analyzer/typeGuards.ts:1131
The NewType-base unwrap is copy-pasted into two functions (here and lines 2762-2769): identical isClassInstance && isNewTypeClass && baseClasses.length > 0 → baseClasses[0] → isClass() guard → cloneAsInstance. AGENTS.md explicitly calls out this copy/paste-variant pattern. Extract a single getNewTypeBaseInstance(subtype): ClassType | undefined helper so both call sites collapse to one line and there's a single place to evolve depth/Any-base handling.

[verified]

if (isClass(baseClass)) {
compareType = ClassType.cloneAsInstance(baseClass);
}
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📍 packages/pyright-internal/src/analyzer/typeGuards.ts:2760
The unwrap is single-level only. NewType's base may itself be a NewType (Y = NewType("Y", X) where X = NewType("X", bool) is legal and instantiable). The patch unwraps one level, so compareType stays a NewType and assignType(X_instance, True) still fails, leaving nested NewType comparisons marked unreachable. Either loop/recurse until the first non-NewType base (natural fit for the suggested shared helper) or explicitly scope nested NewType out with a comment.

[verified]

@rchiodo

Copy link
Copy Markdown
Collaborator

GitHub cannot anchor PR review comments to unchanged lines in the diff. Falling back to a general PR comment for packages/pyright-internal/src/analyzer/typeGuards.ts:L1162.

📍 packages/pyright-internal/src/analyzer/typeGuards.ts:1162
narrowTypeForIsEllipsis is the structural twin of narrowTypeForIsNone (same isXInstance/assignType shape) but received no NewType handling. X = NewType("X", EllipsisType); x is ... would still be flagged unreachable — the same class of bug this PR fixes, left inconsistent in the adjacent context. Rare, but at minimum note why ellipsis was intentionally excluded, or handle it via the shared helper.

[verified]

@rchiodo

Copy link
Copy Markdown
Collaborator

The literal-comparison path (bool/int cases) is fixed correctly, but the is None path does not actually fix its own scenario. For NewType("Apple", NoneType), the positive if a is None: branch narrows to Never (the post-filter at lines 1152-1156 strips the NewType instance via isNoneInstance), so the added reveal_type assertion is dead code and NewType8 passes vacuously. Please make the is None positive result survive the post-filter (return a None-typed value carrying the NewType identity, or skip the post-filter for this case) and add non-vacuous coverage that fails on a Never regression.

if (isNewTypeWithSingletonBase(evaluator, adjustedSubtype, evaluator.getNoneType(), isNoneInstance)) {
resultIncludesNoneSubtype = true;
return isPositiveTest ? adjustedSubtype : undefined;
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Negative-branch regression (verified empirically). isNewTypeWithSingletonBase returns true when isExactMatch(base) || assignType(base, target) — i.e. "could the value be the singleton?". That's correct for the positive branch's adjustedSubtype return, but wrong for the negative branch's undefined (eliminate) return. For ObjNT = NewType("ObjNT", object), the base unwraps to object and assignType(object, None) is true, so this block fires and o is not None returns undefined → Never, marking the true branch unreachable (reproduced: reportUnreachable='error' flags the if o is not None: body). In the pre-PR code this case falls through to the assignType(subtype, None) check and correctly keeps the type. Fix: gate the negative-branch elimination on isExactMatch(base) only, so non-singleton bases fall through to the existing exact-/potentially-None checks.

: subtype;

if (isNewTypeWithSingletonBase(evaluator, adjustedSubtype, ellipsisType, isEllipsisInstance)) {
resultIncludesEllipsisSubtype = true;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same negative-branch defect in the ellipsis twin. For an object-based NewType, assignType(object, ellipsisType) is true, so e is not ... returns undefined → Never here too, whereas the existing fall-through at the assignType(subtype, ellipsisType) check would correctly keep the type. Apply the same fix as the is None path (single root cause).


// Handle type narrowing for expressions of the form "x is None" and "x is not None".
function narrowTypeForIsNone(evaluator: TypeEvaluator, type: Type, isPositiveTest: boolean) {
const expandedType = mapSubtypes(type, (subtype) => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The predicate name isNewTypeWithSingletonBase overstates what it checks: for an object base the unwrapped base is not a singleton, yet assignType(object, None) makes it return true. This name is what makes the negative-branch elimination look correct. Consider renaming (e.g. newTypeBaseCouldMatch) and documenting that a true result only justifies keeping a subtype on the positive branch, not eliminating it on the negative branch.


if d is ...:
reveal_type(d, expected_text="Dragonfruit")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage gap that let the negative-branch regression pass. The sample exercises only positive is branches; there's no is not None / is not ... coverage and no object-based NewType. Add a NewType over a None-compatible non-singleton base (e.g. ObjNT = NewType("ObjNT", object)) and assert that the else of if o is None: (and the body of if o is not None:) stays reachable as ObjNT under reportUnreachable='error', so this class of bug is caught.

@rchiodo

Copy link
Copy Markdown
Collaborator

Core fix for the positive is/is None cases works and nested NewTypes are handled correctly (verified: a is None narrows to the NewType, not Never). The blocking problem is on the negative branch: isNewTypeWithSingletonBase answers "could the base be the singleton?" via assignType(base, target), which is right for keeping a subtype on the positive branch but wrong for eliminating it on the negative branch. For a NewType over a non-singleton base that's merely compatible with None/ellipsis (e.g. object), this turns is not None / is not ... into Never. Please gate the negative-branch elimination on the exact-match case only, and add negative-branch + object-base test coverage.

@rchiodo

Copy link
Copy Markdown
Collaborator

The core fix works and nested NewTypes are handled correctly. However, there is one real regression: isNewTypeWithSingletonBase uses assignType(base, target), which is correct for keeping a subtype on the positive branch but wrong for eliminating it on the negative branch. For a NewType whose base is merely compatible with (not equal to) None/ellipsis (e.g. an object-based NewType), is not None / is not ... collapse to Never and mark reachable code unreachable. I reproduced this under reportUnreachable='error'. Restricting the negative-branch elimination to an exact singleton-base match, plus adding negative-branch/object-based test coverage, should resolve it. (The other first-pass notes about the primary branch collapsing to Never, a vacuous test, single-level unwrap, copy-paste duplication, and missing ellipsis handling did not reproduce and were dropped.)

Only treat a NewType as the None/ellipsis singleton when its innermost
base is exactly that singleton. A NewType over a merely-compatible base
(e.g. NewType("Obj", object)) now falls through to the generic checks, so
`is not None` / `is not ...` no longer collapse the negative branch to
Never and mark reachable code unreachable.

Replaces the misleadingly-named isNewTypeWithSingletonBase predicate with
the getInnermostNewTypeBaseInstance helper (which now returns undefined for
non-NewTypes), and adds object-based NewType coverage that fails under
reportUnreachable if the negative branch regresses.

@rchiodo Rich Chiodo (rchiodo) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved via Review Center.

@github-actions

Copy link
Copy Markdown
Contributor

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

sympy (https://github.com/sympy/sympy)
-   .../projects/sympy/sympy/stats/random_matrix_models.py:111:36 - error: Operator "*" not supported for types "Expr" and "tuple[Unknown, ...] | Unknown | Product | Basic | BooleanFalse | BooleanTrue | Equality | Expr | NaN | One | Zero"
+   .../projects/sympy/sympy/stats/random_matrix_models.py:111:36 - error: Operator "*" not supported for types "Expr" and "tuple[Unknown, ...] | Unknown | Product | Basic | BooleanFalse | BooleanTrue | ComplexInfinity | Equality | Expr | Float | Infinity | Integer | NaN | NegativeInfinity | NegativeOne | Number | One | Rational | Zero"
+   .../projects/sympy/sympy/stats/rv.py:473:25 - error: Argument of type "Expr | Lambda | Zero | One | Integral | Unknown | Probability | tuple[Unknown, ...] | Sum | ZeroMatrix | NaN | Piecewise | Basic | NegativeOne | Integer | ComplexInfinity | Rational | Infinity | NegativeInfinity | Float | Number | int" cannot be assigned to parameter "args" of type "Expr | complex" in function "__new__"
+     Type "Expr | Lambda | Zero | One | Integral | Unknown | Probability | tuple[Unknown, ...] | Sum | ZeroMatrix | NaN | Piecewise | Basic | NegativeOne | Integer | ComplexInfinity | Rational | Infinity | NegativeInfinity | Float | Number | int" is not assignable to type "Expr | complex"
-   .../projects/sympy/sympy/stats/rv.py:473:25 - error: Argument of type "Expr | Lambda | Zero | One | Integral | Unknown | NegativeOne | Integer | NaN | ComplexInfinity | Rational | Infinity | Number | NegativeInfinity | Probability | tuple[Unknown, ...] | Sum | ZeroMatrix | Piecewise | Basic | int" cannot be assigned to parameter "args" of type "Expr | complex" in function "__new__"
-     Type "Expr | Lambda | Zero | One | Integral | Unknown | NegativeOne | Integer | NaN | ComplexInfinity | Rational | Infinity | Number | NegativeInfinity | Probability | tuple[Unknown, ...] | Sum | ZeroMatrix | Piecewise | Basic | int" is not assignable to type "Expr | complex"
-       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/stats/rv.py:473:25 - error: Argument of type "Mul | Expr | Lambda | Zero | One | Integral | Unknown | NegativeOne | Integer | NaN | ComplexInfinity | Rational | Infinity | Number | NegativeInfinity | Probability | tuple[Unknown, ...] | Sum | ZeroMatrix | Piecewise | Basic | int" cannot be assigned to parameter "args" of type "Expr | complex" in function "__new__"
-     Type "Mul | Expr | Lambda | Zero | One | Integral | Unknown | NegativeOne | Integer | NaN | ComplexInfinity | Rational | Infinity | Number | NegativeInfinity | Probability | tuple[Unknown, ...] | Sum | ZeroMatrix | Piecewise | Basic | int" is not assignable to type "Expr | complex"
-   .../projects/sympy/sympy/stats/tests/test_discrete_rv.py:138:33 - error: Operator "+" not supported for types "Expr | Unknown | Any | One | NegativeOne | Zero | Integer | NaN | ComplexInfinity | Rational | tuple[Unknown, ...] | MatAdd | int" and "Literal[3]"
+   .../projects/sympy/sympy/stats/tests/test_discrete_rv.py:138:33 - error: Operator "+" not supported for types "Expr | Unknown | Any | One | NegativeOne | Zero | Integer | NaN | ComplexInfinity | Rational | tuple[Unknown, ...] | MatAdd | Infinity | NegativeInfinity | Float | Number | int" and "Literal[3]"
-   .../projects/sympy/sympy/stats/tests/test_finite_rv.py:34:23 - error: Operator "/" not supported for types "Unknown | Any | BernoulliDistribution | Probability | Zero | One | Expr | Float | ComplexInfinity | NaN | Rational | Infinity | NegativeInfinity | NotImplementedType | tuple[Unknown, ...] | Sum | ZeroMatrix | Piecewise | Basic | Integer | Lambda | Mul | NegativeOne | Number | Integral | Literal[0]" and "Unknown | Any | BernoulliDistribution | Probability | Zero | One | Expr | Float | ComplexInfinity | NaN | Rational | Infinity | NegativeInfinity | NotImplementedType | tuple[Unknown, ...] | Sum | ZeroMatrix | Piecewise | Basic | Integer | Lambda | Mul | NegativeOne | Number | Integral | Literal[0]"
+   .../projects/sympy/sympy/stats/tests/test_finite_rv.py:34:23 - error: Operator "/" not supported for types "Unknown | Any | One | NegativeOne | Zero | Integer | NaN | ComplexInfinity | Rational | BernoulliDistribution | Probability | Expr | Float | Infinity | NegativeInfinity | NotImplementedType | Lambda | Piecewise | Integral | Literal[0]" and "Unknown | Any | BernoulliDistribution | Probability | Zero | One | Expr | Float | ComplexInfinity | NaN | Rational | Infinity | NegativeInfinity | NotImplementedType | Integer | Lambda | NegativeOne | Piecewise | Integral | Literal[0]"
-     Operator "/" not supported for types "BernoulliDistribution" and "tuple[Unknown, ...]"
-     Operator "/" not supported for types "BernoulliDistribution" and "Basic"
+     Operator "/" not supported for types "Literal[0]" and "BernoulliDistribution" (reportOperatorIssue)
+   .../projects/sympy/sympy/stats/tests/test_finite_rv.py:35:23 - error: Operator "*" not supported for types "Unknown | Any | One | NegativeOne | Zero | Integer | NaN | ComplexInfinity | Rational | BernoulliDistribution | Probability | Expr | Float | Infinity | NegativeInfinity | NotImplementedType | Lambda | Piecewise | Integral | Literal[0]" and "Unknown | Any | BernoulliDistribution | Probability | Zero | One | Expr | Float | ComplexInfinity | NaN | Rational | Infinity | NegativeInfinity | NotImplementedType | Integer | Lambda | NegativeOne | Piecewise | Integral | Literal[0]"
-     Operator "/" not supported for types "tuple[Unknown, ...]" and "BernoulliDistribution"
+     Operator "*" not supported for types "ComplexInfinity" and "BernoulliDistribution"
-     Operator "/" not supported for types "tuple[Unknown, ...]" and "tuple[Unknown, ...]"
-     Operator "/" not supported for types "tuple[Unknown, ...]" and "Basic"
-     Operator "/" not supported for types "tuple[Unknown, ...]" and "Literal[0]"
-     ... (reportOperatorIssue)
-   .../projects/sympy/sympy/stats/tests/test_finite_rv.py:35:23 - error: Operator "*" not supported for types "Unknown | Any | BernoulliDistribution | Probability | Zero | One | Expr | Float | ComplexInfinity | NaN | Rational | Infinity | NegativeInfinity | NotImplementedType | tuple[Unknown, ...] | Sum | ZeroMatrix | Piecewise | Basic | Integer | Lambda | Mul | NegativeOne | Number | Integral | Literal[0]" and "Unknown | Any | BernoulliDistribution | Probability | Zero | One | Expr | Float | ComplexInfinity | NaN | Rational | Infinity | NegativeInfinity | NotImplementedType | tuple[Unknown, ...] | Sum | ZeroMatrix | Piecewise | Basic | Integer | Lambda | Mul | NegativeOne | Number | Integral | Literal[0]"
-     Operator "*" not supported for types "BernoulliDistribution" and "Infinity"
+   .../projects/sympy/sympy/stats/tests/test_finite_rv.py:35:23 - error: Operator "/" not supported for types "Unknown | Any | One | NegativeOne | Zero | Integer | NaN | ComplexInfinity | Rational | Infinity | NegativeInfinity | Float | NotImplementedType | Expr | int" and "Unknown | Any | BernoulliDistribution | Probability | Zero | One | Expr | Float | ComplexInfinity | NaN | Rational | Infinity | NegativeInfinity | NotImplementedType | Integer | Lambda | NegativeOne | Piecewise | Integral | Literal[0]"
-   .../projects/sympy/sympy/stats/tests/test_finite_rv.py:35:23 - error: Operator "/" not supported for types "Unknown | Any | One | NegativeOne | Zero | Integer | NaN | ComplexInfinity | Rational | Expr | Infinity | NegativeInfinity | Float | NotImplementedType | tuple[Unknown, ...] | MatMul | int" and "Unknown | Any | BernoulliDistribution | Probability | Zero | One | Expr | Float | ComplexInfinity | NaN | Rational | Infinity | NegativeInfinity | NotImplementedType | tuple[Unknown, ...] | Sum | ZeroMatrix | Piecewise | Basic | Integer | Lambda | Mul | NegativeOne | Number | Integral | Literal[0]"
-     Operator "/" not supported for types "tuple[Unknown, ...]" and "BernoulliDistribution"
-     Operator "/" not supported for types "tuple[Unknown, ...]" and "tuple[Unknown, ...]"
-     Operator "/" not supported for types "tuple[Unknown, ...]" and "Basic"
-     Operator "/" not supported for types "tuple[Unknown, ...]" and "Literal[0]"
-     Operator "/" not supported for types "int" and "BernoulliDistribution"
-     Operator "/" not supported for types "int" and "tuple[Unknown, ...]"
-     Operator "/" not supported for types "int" and "Basic" (reportOperatorIssue)
+     Operator "/" not supported for types "int" and "BernoulliDistribution" (reportOperatorIssue)
-   .../projects/sympy/sympy/stats/tests/test_finite_rv.py:470:12 - error: Operator "+" not supported for types "Unknown | Any | BernoulliDistribution | Probability | Zero | One | Expr | Float | ComplexInfinity | NaN | Rational | Infinity | NegativeInfinity | NotImplementedType | tuple[Unknown, ...] | Sum | ZeroMatrix | Piecewise | Basic | Integer | Lambda | Mul | NegativeOne | Number | Integral | Literal[0]" and "Unknown | Any | BernoulliDistribution | Probability | Zero | One | Expr | Float | ComplexInfinity | NaN | Rational | Infinity | NegativeInfinity | NotImplementedType | tuple[Unknown, ...] | Sum | ZeroMatrix | Piecewise | Basic | Integer | Lambda | Mul | NegativeOne | Number | Integral | Literal[0]"
+   .../projects/sympy/sympy/stats/tests/test_finite_rv.py:470:12 - error: Operator "+" not supported for types "Unknown | Any | One | NegativeOne | Zero | Integer | NaN | ComplexInfinity | Rational | BernoulliDistribution | Probability | Expr | Float | Infinity | NegativeInfinity | NotImplementedType | Lambda | Piecewise | Integral | Literal[0]" and "Unknown | Any | One | NegativeOne | Zero | Integer | NaN | ComplexInfinity | Rational | BernoulliDistribution | Probability | Expr | Float | Infinity | NegativeInfinity | NotImplementedType | Lambda | Piecewise | Integral | Literal[0]"

... (truncated 1414 lines) ...

@rchiodo
Rich Chiodo (rchiodo) merged commit 9e036b2 into microsoft:main Jun 23, 2026
16 checks passed
@rchiodo

Copy link
Copy Markdown
Collaborator

Thanks for the PR :)

@KirtiRamchandani

Copy link
Copy Markdown
Contributor Author

Yipee! :)

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.

Incorrect is behaviour with NewType

2 participants