Move error messages for keyword arguments with ParamSpec
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Feature
At the moment, you need --extra-checks to catch this pedantic thing:
from typing import Concatenate, ParamSpec
from collections.abc import Callable
P = ParamSpec("P")
def f(a: Callable[P, None]) -> Callable[Concatenate[int, P], None]:
def inner(x: int, *args: P.args, **kwargs: P.kwargs) -> None: # proposal: warn here
a(*args, **kwargs)
return inner # warns on this
Instead, @dhruvmanila came up with a different rule: warn on the definition of functions that have a keyword argument + ParamSpec *args/**kwargs. I think this is better, because we're trying to move away from flags which modify behavior strangely AFAIK. Then, regardless of error, we would treat x as positional-only.
Pitch
We would remove any custom subtyping (iirc, that's how --extra-checks works now), instead just replacing functions with a better version if it has *args: P.args, **kwargs: P.kwargs. Then we would have a disabled-by-default error code for this new check.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no files or tests. Start by tracing the current --extra-checks handling and the ParamSpec checking for keyword arguments, then compare the proposed definition-time warning with the existing behavior. Done means removing the custom subtyping behavior, adding the disabled-by-default error check, and treating the named argument as positional-only.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100