microsoft / microsoft/pyright

implicit override not reported for overloaded methods without implementation

Open
#10,645 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
15.6k
Forks
1.8k
Avg merge
12h 13m
Merged PRs (30d)
52

Description

Overloaded methods without implementation (i.e. in a `Protocol` or a `.pyi`) are not flagged when using `reportImplicitOverride=true` if they override a method but not decorated as such:

```py
from typing import Literal, Protocol, overload

class BoolFormatter(Protocol):
def format_bool(self, b: bool, /) -> str: ...

class LiteralBoolFormatter(BoolFormatter, Protocol):
@overload
def format_bool(self, b: Literal[True], /) -> Literal["⊤"]: ...
@overload
def format_bool(self, b: Literal[False], /) -> Literal["⊥"]: ...
@overload # I'll open another issue for this
def format_bool(self, b: bool, /) -> Literal["⊤", "⊥"]: ...
```

[playground](https://pyright-play.net/?pythonVersion=3.14&strict=true&reportImplicitOverride=true&code=GYJw9gtgBALgngBwJYDsDmUkQWEMoAySMApiAIYA2ANFAArgxgDGYNUYAbmZWOQCYAoQc0rkAzuKgAhMGwBiuCORikQACgZgmrSgEoAXIKgmo-EsCjAlKgPoAjOZXXiSlYLXsGojtrQD0elAAtAB8UOIwIN4AdHHCohJSRGpUsgo2qmTq6ZSKIMpZILRaOmyGxqYAAlw8fEKmZhZWmQ5OLm4ePt4pZFQA2gAqIACuJAC6AUFhhMR9lP0ARIAlRIvjsfGNNdwgvAKVJuaW1gV2vs6u7p49cxQL8lSuk1CBIeG9d0uApURrGzEHUG2dQEJgAxFAAJIAckolA4CBIKCg5BQ2gAFmRMJIxi0QLA0UgpACjrjCm02B0rt0fE4pm9ZqkFitFrRFj91lA4jEgA)

In a `.pyi` this false negative also occurs outside of a `Protocol`:

```pyi
from typing import Literal, overload

class BaseFormatter:
def format_bool(self, b: bool, /) -> str: ...

class Formatter(BaseFormatter):
@overload
def format_bool(self, b: Literal[True], /) -> Literal["⊤"]: ...
@overload
def format_bool(self, b: Literal[False], /) -> Literal["⊥"]: ...
@overload
def format_bool(self, b: bool, /) -> Literal["⊤", "⊥"]: ...
```

Contributor guide

Open the contributing guide

Research direction

Start with the linked pyright-play.com reproduction and compare the Protocol example with the .pyi example while reportImplicitOverride is enabled. Trace how overloaded declarations without implementations are checked, then verify that both cases report the missing implicit override without changing unrelated overload behavior.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.