Some incompatible overload implementations are only reported as incompatible in subclasses
- Dominant language
- Python
- Stars
- 15.6k
- Forks
- 1.8k
- Avg merge
- 12h 13m
- Merged PRs (30d)
- 52
Description
**Describe the bug**
In the following minimal example (code including all imports below):
```python
class Base:
@overload
def get(self, key): ...
@overload
def get(self, *keys): ... # allows item.get()
def get(self, key, *keys): ... # prohibits item.get(), so should be marked invalid but is not
```
the implementation of `get(self, key, *keys)` should be marked as invalid, as it does not conform to the second overload (`get(self, *keys)` allows calling `item.get()` with no arguments, whereas `get(self, key, *keys)` does not)
The method itself is not marked as invalid by pylance, but subclasses overriding the method with the exact same signature will be (correctly?) marked as invalid:
```python
class Derived(Base):
def get(self, key, *keys): ... # exact same signature as in Base, but now marked invalid -> reportIncompatibleMethodOverride
```
Additional info:
- the same issue occurs when using `typing_extension.overload` instead of `typing.overload`
- the same issue occurs when decorating the implementations with `@abc.abstractmethod`
**Code or Screenshots**
```python
from typing import overload
class Base:
@overload
def get(self, key): ...
@overload
def get(self, *keys): ...
def get(self, key, *keys): ...
class Derived(Base):
def get(self, key, *keys): ...
```
(translates into)
> The method `get` overrides the class "Base" in an incompatible manner.
> Number of positional parameters is not the same; the base method has 2, but the override method has 3 `Pylance(reportIncompatibleMethodOverride)`
> `base.py(22, 9)`: overridden method
**VS Code extension or command-line**
The screenshot was made in VSCode (1.127.0 Universal) with the latest pylance Plugin (2026.2.1) installed.
Contributor guide
Research direction
Start with the minimal Base and Derived example in the issue and reproduce both the overload implementation and reportIncompatibleMethodOverride diagnostics. Trace the overload validation and method-override checks to understand why the base implementation is accepted while the identical subclass method is rejected. Done means the implementation and override diagnostics are consistent with the overload signatures, including the zero-argument case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 65/100