Skip to content

Broken type relations between intersections and protocols #3612

@AlexWaygood

Description

@AlexWaygood

Summary

from ty_extensions import static_assert, is_subtype_of, Intersection
from typing import Protocol

class Foo:
    x: int

class Bar:
    y: int

class FooBar(Foo, Bar): ...

class HasXAndY(Protocol):
    x: int
    y: int

static_assert(is_subtype_of(FooBar, HasXAndY))  # passes
static_assert(is_subtype_of(Intersection[Foo, Bar], HasXAndY))  # incorrectly fails

The first assertion here correctly passes; the second incorrectly fails.

Version

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    ProtocolsbugSomething isn't workingset-theoretic typesunions, intersections and moretype propertiessubtyping, assignability, equivalence, and more

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions