Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign uptype refinement in function call #5206
Comments
This comment has been minimized.
This comment has been minimized.
This could perhaps be done with literal types in the future, something like this:
|
This comment has been minimized.
This comment has been minimized.
That's pretty verbose though..
…On Tue, Jun 12, 2018, 08:08 Jelle Zijlstra ***@***.***> wrote:
This could perhaps be done with literal types in the future, something
like this:
@overload
def check(x: int) -> Literal[True]: ...
@overload
def check(x: str) -> Literal[False]: ...
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#5206 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ACwrMvKHVxoXmkkO8mpf8aeuMzX0ZZmTks5t79lfgaJpZM4UkjNs>
.
|
This comment has been minimized.
This comment has been minimized.
I've had this issue recently too. I definitely think Mypy would benefit from some way to refine types by following conditional paths. Unfortunately implementing that kind of logic is well beyond my expertise. AFAIK you would still have the problem if you wrote |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Here I copy the relevant link from one of the above issues I just closed microsoft/TypeScript#1007 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is ok for mypy:
but how can I make it work if the
isinstance
test is in a function call?I get: