Skip to content

How to properly type overload function to have correct inferred type from pyright? #8155

Answered by erictraut
Holt59 asked this question in Q&A
Discussion options

You must be logged in to vote

You've specified three overloads with default values for convert. Only two of them should have a default value specified. The overload with Literal[False] should not include a = ... because Literal[False] is not a valid default value based on your implementation.

@overload
def f1(model: str, convert: Literal[False]) -> int: ...

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Holt59
Comment options

Answer selected by Holt59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants