[issue44791] Substitution of ParamSpec in Concatenate

Mehdi2277 report at bugs.python.org
Sun Feb 20 04:11:54 EST 2022


Mehdi2277 <med2277 at gmail.com> added the comment:

Concatenate[int, ...] I would interpret as a function signature with first argument int, followed by arbitrary arguments afterwards. I haven't run into this case, but ... is allowed in other spots Paramspec is allowed currently.

P = Paramspec("P")

class Foo(Generic[P]):
  ...

Foo[...] # Allowed 
Callable[..., None] # Allowed

Are there any other places a paramspec is allowed? Generic type argument, first argument to callable, last to concatenate, anything else?

I'm unaware of any type checking use case for Concatenate[int, ...]. You can practically get same thing by using a paramspec variable without using it elsewhere so that it captures, but then effectively discards that information.

def use_func1(f: Callable[Concatenate[int, P], None]) -> None:
  ...

def use_func2(f: Callable[Concatenate[int, ...], None]) -> None:
  ...

feels like those two signatures should encode same information.

----------
nosy: +med2277

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44791>
_______________________________________


More information about the Python-bugs-list mailing list