christophertubbs / christophertubbs/EventStream

Edit references to ParamSpec

Open
#6 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

Issues arise when defining arguments of type `Callable` that may or may not accept variable arguments. There are two naive ways to define variable arguments `typing.Callable[[int, str, typing.Tuple[typing.Any, ...], typing.Dict[str, typing.Any]], typing.Any]` as read by PyCharm, or:

```
P = typing.ParamSpec("P")

EXAMPLE = typing.Callable[[int, str, P], typing.Any]
```

Both ways can trip up a linter when they are supposed to accept functions like `def example(i: int, j: str = "nope", *args)` or `def example(i: int, j: str, q: bool = False, **kwargs)` since neither correctly use a firm `ParamSpec` or use the `tuple` or `dict` and don't use the exact parameters.

The solution is to use:

```
P = typing.ParamSpec("P")

EXAMPLE = typing.Callable[typing.Concatenate[int, str, P], typing.Any]
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Search the repository for references to Callable and ParamSpec, then inspect the affected annotations against the examples in the issue. Update the references to use ParamSpec with Concatenate where the fixed arguments are part of the callable signature, and confirm the affected lint checks accept the resulting types.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Refactor
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.