You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Regression with narrowing with negative intersection #20597
from __future__ import annotations
from typing import Any
class array: ...
def get_result() -> Any: ...
def foo(x: str | array) -> str:
result = get_result()
if isinstance(result, array):
return "asdf"
if result is x:
reveal_type(result) # N: Revealed type is "Any"
return result
raise
As of #20492 we now get 14: error: Incompatible return value type (got "str | array", expected "str")
I don't have a fix for this in my stack (and expect a fix to be tricky)
Activity
Fix regression with narrowing and negative intersection (issue python…
James-4u commentedon Jan 20, 2026
https://github.com/python/mypy/compare/master...SmartDever02:fix-issue-20597-narrowing-negative-intersection?expand=1
@hauntsaninja how do you think of my proposal?