Skip to content

[1.20 regression] Inconsistent narroving for unions involving Any #21364

Description

@ilevkivskyi

Consider this example:

from typing import Any

class B:
    x: int

class C(B):
    y: int

x: B | int
y: C | Any

assert x == y
reveal_type(x)  # Revealed type is "test.B | int", OK
reveal_type(y)  # Revealed type is "Any | test.B | int", why???
y.y  # Error here, previously this worked.

cc @hauntsaninja I didn't bisect, but there is high chance this may be caused by one of the recent narrowing changes.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions