Skip to content

TypeVar with constraints incorrectly solved when Unknown argument is passed in #1100

@AlexWaygood

Description

@AlexWaygood

Summary

def f[T: (str, bytes)](x: T) -> T:
    return x

def g(x):
    reveal_type(f(x))  # revealed: str

https://play.ty.dev/dfbe3306-e4f1-46c1-a888-d8b178dc86b0

str feels much too confident here -- I think this should either be Unknown or str | bytes?

Version

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggenericsBugs or features relating to ty's generics implementation

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions