Position-only parameter mismatch has counts for expected/received swapped in too many parameters case
- Dominant language
- Python
- Stars
- 15.6k
- Forks
- 1.8k
- Avg merge
- 12h 13m
- Merged PRs (30d)
- 52
Description
**Describe the bug**
In the code/diagnostic below, the message is correct except for this part:
> Position-only parameter mismatch; expected 2 but received 1
That error is backwards, as the assignability being questioned here is `"(int, int) -> int"` into `"(int) -> int"`, so it should actually read
> Position-only parameter mismatch; expected 1 but received 2
The rest of the diagnostic, including the "Function accepts too many positional parameters" part, is correct.
**Code or Screenshots**
[Code in Pyright Playground](https://pyright-play.net/?strict=true&code=GYJw9gtgBALgngBwJYDsDmUkQWEMoDCAhgDYlEBGJApgLABQDAJtcFEQMYfUIwDOAfTApqACgAeALkKlyVagG0FqGABpMKGAF11KrQEooAWgB8UAHLDq0gHR2GzVlADu4dKJjOw04mUo0lPV1NA2MzSxFJBigY9i4efiERDy99IA)
```python
from typing import Callable
def accepts_one(x: Callable[[int], int]) -> None: ...
def wrong(two: Callable[[int, int], int]) -> None:
accepts_one(two)
```
Resulting diagnostic:
```
Argument of type "(int, int) -> int" cannot be assigned to parameter "x" of type "(int) -> int" in function "accepts_one"
Type "(int, int) -> int" is not assignable to type "(int) -> int"
Position-only parameter mismatch; expected 2 but received 1
Function accepts too many positional parameters; expected 1 but received 2 (reportArgumentType)
```
**VS Code extension or command-line**
Tested on Pyright Playground using Pyright version 1.1.414
Contributor guide
Research direction
Reproduce the reported example in the Pyright Playground using version 1.1.414, then trace the diagnostic generation for the position-only parameter mismatch. Confirm the assignability direction and update the relevant diagnostic handling so the expected and received counts match the stated types. Done means the message reports expected 1 and received 2 while preserving the rest of the diagnostic.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 70/100