Hacker News new | ask | show | jobs
by yoyohello13 877 days ago
You can annotate OR types in python so in this case you could do

def fooify(x: int | list[int])

1 comments

But if x is an int, the result is an int

If x is a list, the result is a list

I don’t think that the type system can describe this.