Parameter suggestion uses only the last overload for overloaded functions #6928
Answered
by
rchiodo
adrien-lsh
asked this question in
General
-
Hi there, I recently started to type hint the functions of my project. And some of them return certain types depending of the value of a parameter. Pylance.issue.mp4Python 3.12.2 |
Beta Was this translation helpful? Give feedback.
Answered by
rchiodo
Feb 7, 2025
Replies: 1 comment 1 reply
-
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('') |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
adrien-lsh
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Seems like a bug to me.
Here's the code typed out: