(🎁) Warn when overload impl default value is incompatible with overload part default value
Open
Nobody has claimed this yet.
feature
topic-overloads
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
from typing import overload
@overload
def f(x: object): ...
@overload
def f(x: int = ...): ...
def f(x: object = ""): ...
While this code is type-safe, it's almost certainly a mistake. The default value of overload part 2 is never going to be met by the implementation.
- related: https://github.com/python/mypy/issues/11397, but I think this issue is actually the same issue, just in a more generic form.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing mypy's overload-checking logic using the example in the issue, focusing on how overload-part and implementation default values are compared. Done means emitting a diagnostic when an overload default cannot be met by the implementation default, while preserving the shown type-safe case otherwise.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100