microsoft / microsoft/pyright

False positive incompatible override with *args + keyword-only param

Open
#10,643 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
15.6k
Forks
1.8k
Avg merge
12h 13m
Merged PRs (30d)
52

Description

```
class A:
def test(self, x: int): ...

class B(A):
def test(self, *args: int, x: int = 1): ...

a: A = B()
a.test(1)
a.test(x=1)
```

The following snippet gives the error "base parameter "x" is keyword parameter, override parameter is position-only"

However, as shown from the last 2 lines, the two possible ways to call `A.test` are valid at runtime for `B.test`.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the reported A and B example through Pyright and confirm the incompatible-override diagnostic. Trace the override compatibility check for *args and keyword-only parameters; done means both shown calls are accepted while genuinely incompatible overrides remain diagnosed.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.