Allow keyword-only parameters with ParamSpec

For some reason, PEP 612 forbids keyword-only parameters from being used with parameter specifications.

from typing import Generic
from typing_extensions import ParamSpec

P = ParamSpec('P')
class C(Generic[P]):
    def f(self, x: int, *args: P.args, y: int | None = None, **kwargs: P.kwargs) -> int:
        return x + (0 if y is None else y)

Is there any motivation for this limitation?

The reasoning is detailed in the PEP here.

1 Like

Thank you yes, that makes perfect sense. I realize that there are many important developments in the typing world, but I hope to see the extension proposed in the PEP implemented one day.

1 Like

(You mean PEP 612.)

Yes, thanks edited.