Type hint TypeVars inside @overload decorators with *args #1448
Closed
JackAshwell11
started this conversation in
General
Replies: 1 comment 5 replies
-
Is This type checks: @overload
def foo(__a_one: type[T]) -> Iterable[tuple[int, tuple[T]]]:
...
@overload
def foo(__a_one: type[T], __a_two: type[T1]) -> Iterable[tuple[int, tuple[T, T1]]]:
...
@overload
def foo(
__a_one: type[T], __a_two: type[T1], __a_three: type[T2]
) -> Iterable[tuple[int, tuple[T, T1, T2]]]:
...
def foo(*args: type[Base]) -> Iterable[tuple[int, tuple[Base, ...]]]:
return [(1, tuple(arg() for arg in args))] |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, so this is a simplified version of my current problem. The code:
The
foo()
function is meant to take in an arbitrary number of parameters. The function then returns a collection of instances which match those parameter types so that each return value in the tuple is correctly typed to the specific class. However, this works for having one parameter, but doesn't work for having multiple parameters. Is there any way to fix this?Beta Was this translation helpful? Give feedback.
All reactions