eternacht @programming.dev
Posts 0
Comments 2
*Permanently Deleted* 3 0
YES! I rewatched recently. I thought it would age poorly but it’s still extremely watchable.
Reply
[Answered] Typehints for functions that have variable signatures 1 0
This is the real answer, overloads are meant for exactly this purpose.
It’ll be something like this:
from typing import Literal, overload
@overload
def foo() -> Data: …
@overload
def foo(return_more: Literal[True]) -> tuple[Data, Data]: …
def foo(return_more: bool = False) -> Data | tuple[Data, Data]
...
if return_more:
return data, more_data
return data
Reply
Next