Skip to content

Parameter suggestion uses only the last overload for overloaded functions #6928

Answered by rchiodo
adrien-lsh asked this question in General
Discussion options

You must be logged in to vote

Seems like a bug to me.

Here's the code typed out:

@overload
def foo(return_type: Literal['dict']) -> dict: ...  
@overload
def foo(return_type: Literal['list']) -> list: ...

def foo(return_type: Literal['dict', 'list']) -> dict | list:
    if return_type == 'dict':
        return {}
    return []

foo('')

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@adrien-lsh
Comment options

Answer selected by adrien-lsh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants