Skip to content

Evaluate truthiness of literals in static boolean expressions - #11520

Merged
Rich Chiodo (rchiodo) merged 5 commits into
microsoft:mainfrom
velikodniy:static-literal-truthiness
Jun 24, 2026
Merged

Rich Chiodo (rchiodo) merged 5 commits into
microsoft:mainfrom
velikodniy:static-literal-truthiness

Conversation

@velikodniy

Copy link
Copy Markdown
Contributor

Summary

Currently, bool-like expressions evaluator supports only None as a falsy literal.
So that, this code does not report print(x) as unreachable:

while 1:
    x = 1
print(x)

This PR adds support of other literal types listed below

Expression form Examples Static result
Bool keywords True, False true / false
None None false
Ellipsis ... true
Numbers 0, 0.0, 0j / 1, 3.14, 1j false / true
Strings & bytes "", b"" / "x", b"x" false / true
List / set / tuple / dict [], (), {} / [1], (1,), {1}, {1: 2} false / true
not of a foldable operand not 1, not [], not not 1 negated
and / or of foldable operands 1 and 0, 0 or "x" combined truthiness
Container with a concrete element [1, *x], {**d, "k": 1} true (definitely non-empty)
f-strings f"{x}" undefined (runtime-dependent)
Spread/comprehension-only containers [*x], [i for i in y], {**d} undefined (length unknown)
Negative or non-literal operands -1, x, f(), Decimal(0), set() undefined (a negative number isn't a single node)

Tests

Added staticExpressionLiteral1.py with positive and negative cases.
One of the tests is updated because if 1 is determined now.

Fixes #11505

@velikodniy

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

@rchiodo

Copy link
Copy Markdown
Collaborator

Looks good — approving. Two minor maintainability notes inline (one behavioral consistency question on the not branch, one stale doc-comment).

@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

This comment has been minimized.

@rchiodo

Copy link
Copy Markdown
Collaborator

I'm wondering about the mypy primer differences.

Like this one:

pytest (https://github.com/pytest-dev/pytest)

  • .../projects/pytest/src/_pytest/pytester.py:1270:10 - error: Function with declared return type "Item" must return value on all code paths
  • "None" is not assignable to "Item" (reportReturnType)
    
  • 290 errors, 11 warnings, 0 informations
  • 289 errors, 11 warnings, 0 informations

That seems good to me, but we should double check. Is that expected now because we realized the function never returns?

@velikodniy

Copy link
Copy Markdown
Contributor Author

I'm looking into this to make sure it's not a regression

@github-actions

This comment has been minimized.

@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/staticExpressions.ts:L97.

The not branch now threads the strict leaf evaluator (_evaluateBoolConstant) for strict callers. Pre-PR, the not branch always delegated to the lenient bool-like evaluator, so strict evaluateStaticBoolExpression("not None") folded to true (None → false ⟹ not None → true). Post-PR it now returns undefined, contradicting the PR's own semantics table. Impact is low (precision loss only; both branches still analyzed, no false reachability), but it's a silent behavior change for strict callers. Since Python's not always forces a truthiness context on its operand, consider evaluating the not operand with the bool-like leaf (_evaluateBoolLikeLiteral) unconditionally to restore not None → true and make strict not 0/""/[] precise. If the conservative behavior is intentional, add a one-line comment so the next reader doesn't "re-fix" it.

@rchiodo

Copy link
Copy Markdown
Collaborator

Looks solid overall — the shared-walker refactor and literal truthiness handling are clean and well-tested. One subtle strict-mode behavior change in the not branch is worth a note/comment before merge, but it's non-blocking (precision-only, no incorrect reachability).

@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.

@velikodniy

Copy link
Copy Markdown
Contributor Author

That seems good to me, but we should double check. Is that expected now because we realized the function never returns?

Regarding the pytest case specifically.

The code is:

    def getitem(
        self, source: str | os.PathLike[str], funcname: str = "test_func"
    ) -> Item:
        items = self.getitems(source)
        for item in items:
            if item.name == funcname:
                return item
        assert 0, f"{funcname!r} item not found in module:\n{source}\nitems: {items}"

Before there were two errors:

  • Function with declared return type "str" must return value on all code paths
  • "None" is not assignable to "str" (reportReturnType)

It's because the type checker couldn't evaluate 0 as falsy. It assumed that assert might not trigger, so the function could return None implicitly. This led to the errors above. Now it's clear that assert always raises an exception, so the errors has gone.

I'll check other cases and post a brief follow-up.

@velikodniy

Copy link
Copy Markdown
Contributor Author

The not branch now threads the strict leaf evaluator (_evaluateBoolConstant) for strict callers.

Ah, I see what you mean! I've updated the code to process the not operand as bool-like.

@velikodniy

Copy link
Copy Markdown
Contributor Author

Regarding mypy_primer. Almost all of the changes are expected behaviour:

  • apprise: the result of _fetch is never None, it happens only when target is truthy but it's None
  • pytest: explained above
  • core: while 1 in find_moov()
  • pip: while 1 in ask()
  • werkzeug: if 0 caused Never
  • sympy: while 1

Though, there's a regression in zope.interface. I'm still investigating what caused it

@github-actions

This comment has been minimized.

test('StaticExpressionLiteral1', () => {
const analysisResults = TestUtils.typeAnalyzeSampleFiles(['staticExpressionLiteral1.py']);

TestUtils.validateResults(analysisResults, 4);

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/typeEvaluator8.test.ts:969
This asserts 4 errors but the sample produces 7. I verified by running the type checker on strict_not_folding() in isolation: it emits exactly 3 assert_type mismatches (not 0, not 1, not [] → bool); combined with negative()'s 4, the total is 7, so this test fails CI. Update the expected count to 7 (after fixing the sample assertions below), or — preferably — replace the indirect assert_type cases with a direct unit test of evaluateStaticBoolExpression/evaluateStaticBoolLikeExpression, which are the functions this PR actually changes.

[verified]


c = not 1
assert_type(c, Literal[False])

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/staticExpressionLiteral1.py:138
These three assert_type calls are wrong and produce errors: not 0, not 1, and not [] infer bool, not Literal[True]/Literal[False]. I confirmed this against the real type evaluator. pyright only folds not to a bool literal when the operand's truthiness is known from its type (which is why not None and not not None below DO pass — None is a singleton). Either change these three to assert_type(..., bool), or drop them. Note this function tests the type evaluator's not-narrowing, not the staticExpressions.ts code this PR changes — consider a direct unit test of the changed functions instead.

[verified]

sysImportAliases
sysImportAliases,
evaluateLeafAsBool
);

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/staticExpressions.ts:101
The not branch documents why it ignores the caller's evaluateLeafAsBool (always real bool), but the and/or branch silently does the opposite — it threads the caller's callback so strict 1 and 1 stays undefined. This divergence is correct but load-bearing and non-obvious; a one-line comment on the and/or branch (or a sentence contrasting the two in the function header) would prevent a future refactor from "harmonizing" them and regressing strict reachability.

[verified]

@rchiodo

Copy link
Copy Markdown
Collaborator

Core change to staticExpressions.ts looks solid. The blocker is the new test: strict_not_folding() adds 3 unexpected assert_type errors (not 0/1/[] infer bool, not literal), so the file emits 7 errors while the test expects 4. Fix the sample assertions and the expected count together — ideally with a direct unit test of the changed functions.

@velikodniy

Copy link
Copy Markdown
Contributor Author

A quick update.

This asserts 4 errors but the sample produces 7

I believe it's false-positive. It's 4 errors when I run locally and in the CI test jobs.

These three assert_type calls are wrong and produce errors: not 0, not 1, and not [] infer bool

All of them produce True/False deterministically, so bool wouldn't work.

replace the indirect assert_type cases with a direct unit test of evaluateStaticBoolExpression/evaluateStaticBoolLikeExpression, which are the functions this PR actually changes

My intention was to add high-level property-based tests. Though, I can add more tests if needed.

Regarding the mypy_primer cases. All of them show improvement in type inference, so it's a win. The only exception is the zope case. I spent some time yesterday trying to reproduce it. It looks like type inference is fragile.

The PR makes pyright statically treat the empty-dict literal in attrs = attrs or {} as falsy. This perturbs the control-flow graph of InterfaceClass.__new__ somehow and tips its recursive type inference from the permissive Any | Unknown fallback onto a concrete instance type for Interface. So that every class IFoo(Interface) now wrongly errors with "Argument to class must be a base class".

Rich Chiodo (@rchiodo), seemingly the comments about the tests are false-positive and the zope case is an issue not related to this PR (even though it was triggered by it). Shall we merge? What do you think?

@rchiodo

Copy link
Copy Markdown
Collaborator

Core change to staticExpressions.ts looks sound, but the test won't pass: strict_not_folding() relies on pyright folding not <literal> to a bool literal, which it does not do (only actual bool-literal operands fold). That function needs to be removed or rewritten before merge.

@rchiodo

Copy link
Copy Markdown
Collaborator

Core feature change to staticExpressions.ts looks reasonable, but the new test is broken: strict_not_folding() asserts literal not-folding that pyright's type evaluator does not perform (it folds not to a bool literal only when the operand's truthiness is known from its type, which holds for None but not for 0, [], {}, etc.). The expected error count 4 matches negative() alone; the extra assert_type failures make the total 11. Easiest fix: drop strict_not_folding() (or replace it with a direct unit test of evaluateStaticBoolExpression/evaluateStaticBoolLikeExpression, the functions this PR actually changes), keeping the expected count at 4.

@velikodniy

Copy link
Copy Markdown
Contributor Author

but the test won't pass

The expected error count 4 matches negative() alone; the extra assert_type failures make the total 11.

The tests are green in the CI workflows

@rchiodo

Copy link
Copy Markdown
Collaborator

Vadim Velicodnii (@velikodniy), sorry but most of the code review comments on this are generated by AI. It can sometimes get stuck in a logical loop.

I'm running the tests now. If they're green, I'll submit.

@github-actions

Copy link
Copy Markdown
Contributor

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

apprise (https://github.com/caronc/apprise)
-   .../projects/apprise/apprise/plugins/nextcloud.py:467:26 - error: "get" is not a known attribute of "None" (reportOptionalMemberAccess)
-   .../projects/apprise/apprise/plugins/nextcloud.py:501:26 - error: "get" is not a known attribute of "None" (reportOptionalMemberAccess)
- 4862 errors, 11 warnings, 0 informations
+ 4860 errors, 11 warnings, 0 informations

sympy (https://github.com/sympy/sympy)
-   .../projects/sympy/sympy/core/evalf.py:627:15 - error: "re" is possibly unbound (reportPossiblyUnboundVariable)
-   .../projects/sympy/sympy/core/evalf.py:629:15 - error: "im" is possibly unbound (reportPossiblyUnboundVariable)
-   .../projects/sympy/sympy/core/evalf.py:631:12 - error: "re" is possibly unbound (reportPossiblyUnboundVariable)
-   .../projects/sympy/sympy/core/evalf.py:631:16 - error: "im" is possibly unbound (reportPossiblyUnboundVariable)
-   .../projects/sympy/sympy/core/evalf.py:631:20 - error: "re_acc" is possibly unbound (reportPossiblyUnboundVariable)
-   .../projects/sympy/sympy/core/evalf.py:631:28 - error: "im_acc" is possibly unbound (reportPossiblyUnboundVariable)
-   .../projects/sympy/sympy/core/evalf.py:1196:12 - error: "result" is possibly unbound (reportPossiblyUnboundVariable)
-   .../projects/sympy/sympy/core/function.py:2257:40 - error: "reps" is possibly unbound (reportPossiblyUnboundVariable)
-   .../projects/sympy/sympy/core/tests/test_arit.py:240:31 - error: "b" is possibly unbound (reportPossiblyUnboundVariable)
-   .../projects/sympy/sympy/core/tests/test_arit.py:240:42 - error: Operator "-" not supported for type "Expr | Unbound" (reportOperatorIssue)
-   .../projects/sympy/sympy/core/tests/test_arit.py:240:43 - error: "b" is possibly unbound (reportPossiblyUnboundVariable)
-   .../projects/sympy/sympy/core/tests/test_arit.py:240:53 - error: "i" is possibly unbound (reportPossiblyUnboundVariable)
-   .../projects/sympy/sympy/external/ntheory.py:98:16 - error: Argument of type "Unknown | int | None" cannot be assigned to parameter "x" of type "ConvertibleToInt" in function "__new__"
-     Type "Unknown | int | None" is not assignable to type "ConvertibleToInt"
-       Type "None" is not assignable to type "ConvertibleToInt"
-         "None" is not assignable to "str"
-         "None" is incompatible with protocol "Buffer"
-           "__buffer__" is not present
-         "None" is incompatible with protocol "SupportsInt"
-           "__int__" is not present
-         "None" is incompatible with protocol "SupportsIndex"
-     ... (reportArgumentType)
-   .../projects/sympy/sympy/external/ntheory.py:98:16 - error: Argument of type "Unknown | int | None" cannot be assigned to parameter "x" of type "ConvertibleToInt" in function "__new__"
-     Type "Unknown | int | None" is not assignable to type "ConvertibleToInt"
-       Type "None" is not assignable to type "ConvertibleToInt"
-         "None" is not assignable to "str"
-         "None" is incompatible with protocol "Buffer"
-           "__buffer__" is not present
-         "None" is incompatible with protocol "SupportsInt"
-           "__int__" is not present
-         "None" is incompatible with protocol "SupportsIndex" (reportArgumentType)
-   .../projects/sympy/sympy/external/ntheory.py:104:17 - error: Argument of type "Unknown | int | None" cannot be assigned to parameter "x" of type "ConvertibleToInt" in function "__new__"
-     Type "Unknown | int | None" is not assignable to type "ConvertibleToInt"
-       Type "None" is not assignable to type "ConvertibleToInt"
-         "None" is not assignable to "str"
-         "None" is incompatible with protocol "Buffer"
-           "__buffer__" is not present
-         "None" is incompatible with protocol "SupportsInt"
-           "__int__" is not present
-         "None" is incompatible with protocol "SupportsIndex"
-     ... (reportArgumentType)
-   .../projects/sympy/sympy/external/ntheory.py:104:17 - error: Argument of type "Unknown | int | None" cannot be assigned to parameter "x" of type "ConvertibleToInt" in function "__new__"
-     Type "Unknown | int | None" is not assignable to type "ConvertibleToInt"
-       Type "None" is not assignable to type "ConvertibleToInt"
-         "None" is not assignable to "str"
-         "None" is incompatible with protocol "Buffer"
-           "__buffer__" is not present
-         "None" is incompatible with protocol "SupportsInt"
-           "__int__" is not present
-         "None" is incompatible with protocol "SupportsIndex" (reportArgumentType)
-   .../projects/sympy/sympy/external/ntheory.py:254:20 - error: Argument of type "Unknown | int | None" cannot be assigned to parameter "x" of type "ConvertibleToInt" in function "__new__"
-     Type "Unknown | int | None" is not assignable to type "ConvertibleToInt"
-       Type "None" is not assignable to type "ConvertibleToInt"
-         "None" is not assignable to "str"
-         "None" is incompatible with protocol "Buffer"
-           "__buffer__" is not present
-         "None" is incompatible with protocol "SupportsInt"
-           "__int__" is not present
-         "None" is incompatible with protocol "SupportsIndex"
-     ... (reportArgumentType)
-   .../projects/sympy/sympy/external/ntheory.py:254:20 - error: Argument of type "Unknown | int | None" cannot be assigned to parameter "x" of type "ConvertibleToInt" in function "__new__"
-     Type "Unknown | int | None" is not assignable to type "ConvertibleToInt"
-       Type "None" is not assignable to type "ConvertibleToInt"
-         "None" is not assignable to "str"
-         "None" is incompatible with protocol "Buffer"
-           "__buffer__" is not present
-         "None" is incompatible with protocol "SupportsInt"
-           "__int__" is not present
-         "None" is incompatible with protocol "SupportsIndex" (reportArgumentType)
-   .../projects/sympy/sympy/polys/numberfields/minpoly.py:609:31 - error: Cannot access attribute "base" for class "Expr"
-     Attribute "base" is unknown (reportAttributeAccessIssue)
-   .../projects/sympy/sympy/polys/numberfields/minpoly.py:609:40 - error: Cannot access attribute "exp" for class "Expr"
-     Attribute "exp" is unknown (reportAttributeAccessIssue)
-   .../projects/sympy/sympy/stats/drv.py:269:22 - error: Argument of type "Generator[tuple[Unknown, ...] | Unknown | Sum | Expr | ZeroMatrix | Add | 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:269:22 - error: Argument of type "Generator[tuple[Unknown, ...] | Unknown | Sum | Expr | ZeroMatrix | 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 | ZeroMatrix | Add | Zero | NaN | Piecewise | Basic | int | None, None, None]" is not assignable to "Iterable[_SupportsSumNoDefaultT@sum]"
+     "Generator[tuple[Unknown, ...] | Unknown | Sum | Expr | ZeroMatrix | 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 | ZeroMatrix | Add | 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 | Expr | ZeroMatrix | Zero | NaN | Piecewise | Basic | int | None" is not a subtype of "_SupportsSumNoDefaultT@sum"
-         Type "tuple[Unknown, ...] | Unknown | Sum | Expr | ZeroMatrix | Add | Zero | NaN | Piecewise | Basic | int | None" is not assignable to type "_SupportsSumWithNoDefaultGiven"
+         Type "tuple[Unknown, ...] | Unknown | Sum | Expr | ZeroMatrix | Zero | NaN | Piecewise | Basic | int | None" is not assignable to type "_SupportsSumWithNoDefaultGiven"
-           Type "tuple[Unknown, ...] | Unknown | Sum | Expr | ZeroMatrix | Add | Zero | NaN | Piecewise | Basic | int | None" is not assignable to type "_SupportsSumWithNoDefaultGiven"
+           Type "tuple[Unknown, ...] | Unknown | Sum | Expr | ZeroMatrix | Zero | NaN | Piecewise | Basic | int | None" is not assignable to type "_SupportsSumWithNoDefaultGiven"
-   .../projects/sympy/sympy/stats/drv_types.py:293:16 - error: Operator "*" not supported for types "Expr" and "tuple[Unknown, ...] | Unknown | Sum | Expr | ZeroMatrix | Add | Zero | NaN | Piecewise | Basic"
+   .../projects/sympy/sympy/stats/drv_types.py:293:16 - error: Operator "*" not supported for types "Expr" and "tuple[Unknown, ...] | Unknown | Sum | Expr | ZeroMatrix | Zero | NaN | Piecewise | Basic"
-   .../projects/sympy/sympy/stats/rv.py:473:25 - error: Argument of type "Expr | Lambda | Zero | One | Integral | Unknown | Probability | tuple[Unknown, ...] | Sum | ZeroMatrix | Add | 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__"
+   .../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 | Add | NaN | Piecewise | Basic | NegativeOne | Integer | ComplexInfinity | Rational | Infinity | NegativeInfinity | Float | Number | int" is not assignable to type "Expr | complex"
+     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"

... (truncated 166 lines) ...

zope.interface (https://github.com/zopefoundation/zope.interface)
+   .../projects/zope.interface/src/zope/interface/common/idatetime.py:28:23 - error: Argument to class must be a base class (reportGeneralTypeIssues)
+   .../projects/zope.interface/src/zope/interface/common/idatetime.py:69:18 - error: Argument to class must be a base class (reportGeneralTypeIssues)
+   .../projects/zope.interface/src/zope/interface/common/idatetime.py:220:22 - error: Argument to class must be a base class (reportGeneralTypeIssues)
+   .../projects/zope.interface/src/zope/interface/common/idatetime.py:487:18 - error: Argument to class must be a base class (reportGeneralTypeIssues)
+   .../projects/zope.interface/src/zope/interface/common/idatetime.py:582:15 - error: Argument to class must be a base class (reportGeneralTypeIssues)
+ .../projects/zope.interface/src/zope/interface/common/interfaces.py
+   .../projects/zope.interface/src/zope/interface/common/interfaces.py:20:18 - error: Argument to class must be a base class (reportGeneralTypeIssues)
+   .../projects/zope.interface/src/zope/interface/common/mapping.py:35:20 - error: Argument to class must be a base class (reportGeneralTypeIssues)
+   .../projects/zope.interface/src/zope/interface/common/mapping.py:65:21 - error: Argument to class must be a base class (reportGeneralTypeIssues)
+   .../projects/zope.interface/src/zope/interface/common/mapping.py:111:24 - error: Argument to class must be a base class (reportGeneralTypeIssues)
+   .../projects/zope.interface/src/zope/interface/common/sequence.py:126:34 - error: Argument to class must be a base class (reportGeneralTypeIssues)
-   .../projects/zope.interface/src/zope/interface/common/tests/__init__.py:31:22 - error: Cannot access attribute "dependents" for class "<subclass of ABCInterfaceClass and _InterfaceClassWithCustomMethods>"
+   .../projects/zope.interface/src/zope/interface/common/tests/__init__.py:31:22 - error: Cannot access attribute "dependents" for class "_InterfaceClassWithCustomMethods*"
+   .../projects/zope.interface/src/zope/interface/common/tests/__init__.py:31:22 - error: Cannot access attribute "dependents" for class "InterfaceClass*"
-   .../projects/zope.interface/src/zope/interface/common/tests/__init__.py:31:22 - error: Cannot access attribute "dependents" for class "InterfaceClass"
-   .../projects/zope.interface/src/zope/interface/interface.py:739:44 - error: Argument of type "Any | _InterfaceClassWithCustomMethods | InterfaceClass | Unknown | type[Self@InterfaceClass]" cannot be assigned to parameter "cls" of type "type[Self@object]" in function "__new__"
-     Type "Any | _InterfaceClassWithCustomMethods | InterfaceClass | Unknown | type[Self@InterfaceClass]" is not assignable to type "type[Self@object]" (reportArgumentType)
+   .../projects/zope.interface/src/zope/interface/interface.py:989:11 - error: Cannot assign to attribute "_calculate_sro" for class "_InterfaceClassWithCustomMethods*"
+     Attribute "_calculate_sro" is unknown (reportAttributeAccessIssue)
+   .../projects/zope.interface/src/zope/interface/interface.py:989:11 - error: Cannot assign to attribute "_calculate_sro" for class "InterfaceClass*"
+     Attribute "_calculate_sro" is unknown (reportAttributeAccessIssue)
+   .../projects/zope.interface/src/zope/interface/interface.py:989:11 - error: Cannot assign to attribute "_calculate_sro" for class "InterfaceClass"
+     Attribute "_calculate_sro" is unknown (reportAttributeAccessIssue)
+   .../projects/zope.interface/src/zope/interface/interface.py:990:11 - error: Cannot access attribute "changed" for class "_InterfaceClassWithCustomMethods*"
+     Attribute "changed" is unknown (reportAttributeAccessIssue)
+   .../projects/zope.interface/src/zope/interface/interface.py:990:11 - error: Cannot access attribute "changed" for class "InterfaceClass*"
+     Attribute "changed" is unknown (reportAttributeAccessIssue)
+   .../projects/zope.interface/src/zope/interface/interface.py:990:11 - error: Cannot access attribute "changed" for class "InterfaceClass"
+     Attribute "changed" is unknown (reportAttributeAccessIssue)
+   .../projects/zope.interface/src/zope/interface/interface.py:991:18 - error: Cannot access attribute "__sro__" for class "_InterfaceClassWithCustomMethods*"
+     Attribute "__sro__" is unknown (reportAttributeAccessIssue)
+   .../projects/zope.interface/src/zope/interface/interface.py:991:18 - error: Cannot access attribute "__sro__" for class "InterfaceClass*"
+     Attribute "__sro__" is unknown (reportAttributeAccessIssue)
+   .../projects/zope.interface/src/zope/interface/interface.py:991:18 - error: Cannot access attribute "__sro__" for class "InterfaceClass"
+     Attribute "__sro__" is unknown (reportAttributeAccessIssue)
+   .../projects/zope.interface/src/zope/interface/interface.py:992:15 - error: Cannot assign to attribute "_ROOT" for class "type[Specification]"
+     Expression of type "_InterfaceClassWithCustomMethods* | InterfaceClass* | InterfaceClass" cannot be assigned to attribute "_ROOT" of class "Specification"
+       Type "_InterfaceClassWithCustomMethods* | InterfaceClass* | InterfaceClass" is not assignable to type "None"
+         "InterfaceClass*" is not assignable to "None" (reportAttributeAccessIssue)
+   .../projects/zope.interface/src/zope/interface/interfaces.py:56:16 - error: Argument to class must be a base class (reportGeneralTypeIssues)
+   .../projects/zope.interface/src/zope/interface/interfaces.py:190:22 - error: Argument to class must be a base class (reportGeneralTypeIssues)
+   .../projects/zope.interface/src/zope/interface/interfaces.py:469:29 - error: Argument to class must be a base class (reportGeneralTypeIssues)
+   .../projects/zope.interface/src/zope/interface/interfaces.py:816:24 - error: Argument to class must be a base class (reportGeneralTypeIssues)
+   .../projects/zope.interface/src/zope/interface/interfaces.py:982:20 - error: Argument to class must be a base class (reportGeneralTypeIssues)
+   .../projects/zope.interface/src/zope/interface/interfaces.py:999:24 - error: Argument to class must be a base class (reportGeneralTypeIssues)
+   .../projects/zope.interface/src/zope/interface/interfaces.py:1085:21 - error: Argument to class must be a base class (reportGeneralTypeIssues)
+   .../projects/zope.interface/src/zope/interface/interfaces.py:1185:26 - error: Argument to class must be a base class (reportGeneralTypeIssues)
-   .../projects/zope.interface/src/zope/interface/ro.py:469:32 - error: Argument of type "list[Unknown] | None" cannot be assigned to parameter "iterable" of type "Iterable[_T_co@tuple]" in function "__new__"
-     Type "list[Unknown] | None" is not assignable to type "Iterable[Unknown]"
-       "None" is incompatible with protocol "Iterable[Unknown]"
-         "__iter__" is not present (reportArgumentType)
-   .../projects/zope.interface/src/zope/interface/ro.py:469:32 - error: Argument of type "list[Unknown] | None" cannot be assigned to parameter "iterable" of type "Iterable[_T_co@tuple]" in function "__new__"
-     Type "list[Unknown] | None" is not assignable to type "Iterable[_T_co@tuple]"
-       "None" is incompatible with protocol "Iterable[_T_co@tuple]"
-         "__iter__" is not present (reportArgumentType)
+   .../projects/zope.interface/src/zope/interface/tests/idummy.py:19:20 - error: Argument to class must be a base class (reportGeneralTypeIssues)
+ .../projects/zope.interface/src/zope/interface/tests/m1.py
+   .../projects/zope.interface/src/zope/interface/tests/m1.py:20:10 - error: Argument to class must be a base class (reportGeneralTypeIssues)
+   .../projects/zope.interface/src/zope/interface/tests/m1.py:24:10 - error: Argument to class must be a base class (reportGeneralTypeIssues)
+   .../projects/zope.interface/src/zope/interface/tests/test_adapter.py:27:15 - error: Argument to class must be a base class (reportGeneralTypeIssues)
+   .../projects/zope.interface/src/zope/interface/tests/test_adapter.py:42:15 - error: Argument to class must be a base class (reportGeneralTypeIssues)
+   .../projects/zope.interface/src/zope/interface/tests/test_adapter.py:48:15 - error: Argument to class must be a base class (reportGeneralTypeIssues)
+   .../projects/zope.interface/src/zope/interface/tests/test_adapter.py:1575:33 - error: Argument of type "list[_InterfaceClassWithCustomMethods* | InterfaceClass* | InterfaceClass]" cannot be assigned to parameter "iterable" of type "Iterable[SupportsRichComparisonT(1)@sorted]" in function "sorted"
+     Type "_InterfaceClassWithCustomMethods* | InterfaceClass* | InterfaceClass" is not assignable to type "SupportsRichComparison"
+       Type "_InterfaceClassWithCustomMethods* | InterfaceClass* | InterfaceClass" is not assignable to type "SupportsRichComparison"
+         Type "InterfaceClass*" is not assignable to type "SupportsRichComparison"
+           "InterfaceClass*" is incompatible with protocol "SupportsDunderLT[Any]"
+             "__lt__" is not present
+           "InterfaceClass*" is incompatible with protocol "SupportsDunderGT[Any]"
+             "__gt__" is not present
+     Type "_InterfaceClassWithCustomMethods* | InterfaceClass* | InterfaceClass" is not assignable to type "SupportsRichComparison" (reportArgumentType)
+   .../projects/zope.interface/src/zope/interface/tests/test_adapter.py:1579:33 - error: Argument of type "list[_InterfaceClassWithCustomMethods* | InterfaceClass* | InterfaceClass]" cannot be assigned to parameter "iterable" of type "Iterable[SupportsRichComparisonT(1)@sorted]" in function "sorted"
+     Type "_InterfaceClassWithCustomMethods* | InterfaceClass* | InterfaceClass" is not assignable to type "SupportsRichComparison"
+       Type "_InterfaceClassWithCustomMethods* | InterfaceClass* | InterfaceClass" is not assignable to type "SupportsRichComparison"
+         Type "InterfaceClass*" is not assignable to type "SupportsRichComparison"

... (truncated 562 lines) ...

pytest (https://github.com/pytest-dev/pytest)
-   .../projects/pytest/src/_pytest/pytester.py:1270:10 - error: Function with declared return type "Item" must return value on all code paths
-     "None" is not assignable to "Item" (reportReturnType)
- 290 errors, 11 warnings, 0 informations
+ 289 errors, 11 warnings, 0 informations

core (https://github.com/home-assistant/core)
- .../projects/core/homeassistant/components/stream/fmp4utils.py
-   .../projects/core/homeassistant/components/stream/fmp4utils.py:147:42 - error: Function with declared return type "int" must return value on all code paths
-     "None" is not assignable to "int" (reportReturnType)
- 37049 errors, 79 warnings, 0 informations
+ 37048 errors, 79 warnings, 0 informations

pip (https://github.com/pypa/pip)
-   .../projects/pip/src/pip/_internal/utils/misc.py:235:50 - error: Function with declared return type "str" must return value on all code paths
-     "None" is not assignable to "str" (reportReturnType)
- 556 errors, 38 warnings, 0 informations
+ 555 errors, 38 warnings, 0 informations

werkzeug (https://github.com/pallets/werkzeug)
-   .../projects/werkzeug/tests/test_wrappers.py:875:27 - error: Argument of type "Generator[None, Any, None]" cannot be assigned to parameter "response" of type "Iterable[bytes] | bytes | Iterable[str] | str | None" in function "__init__"
-     Type "Generator[None, Any, None]" is not assignable to type "Iterable[bytes] | bytes | Iterable[str] | str | None"
-       "Generator[None, Any, None]" is not assignable to "Iterable[bytes]"
-         Type parameter "_T_co@Iterable" is covariant, but "None" is not a subtype of "bytes"
-           "None" is not assignable to "bytes"
-       "Generator[None, Any, None]" is not assignable to "bytes"
-       "Generator[None, Any, None]" is not assignable to "Iterable[str]"
-         Type parameter "_T_co@Iterable" is covariant, but "None" is not a subtype of "str"
-           "None" is not assignable to "str"
-     ... (reportArgumentType)
- 354 errors, 18 warnings, 0 informations
+ 353 errors, 18 warnings, 0 informations

@rchiodo
Rich Chiodo (rchiodo) merged commit e1d4856 into microsoft:main Jun 24, 2026
16 checks passed
@rchiodo

Copy link
Copy Markdown
Collaborator

Thanks for the PR :)

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.

Code is structurally unreachable different for while 1 and while True.

2 participants