-
Notifications
You must be signed in to change notification settings - Fork 226
Closed
astral-sh/ruff
#22782Labels
bugSomething isn't workingSomething isn't workinggenericsBugs or features relating to ty's generics implementationBugs or features relating to ty's generics implementation
Milestone
Description
Summary
I'm probably doing something wrong, but I can't figure it out. Here's a simple example of what I'm trying to do
from typing import *
Scalar = TypeVar("Scalar", int,float)
def test(a:Scalar) -> Scalar:
return a * 2
reveal_type(test(10.0)) # should be float
reveal_type(test(10)) # should be int Pyright works fine.
Mypy works, though I can't find a way to share a link to a playground.
pyrefly has no trouble with the operator, but thinks it's a bad return type. However, it's able to correctly infer the return types.
ty gives an unsupported operator error, and says the type of test(10.0) is float | int. Is there a more correct way to do what I'm trying to do?
Version
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinggenericsBugs or features relating to ty's generics implementationBugs or features relating to ty's generics implementation