@overload type checking for overload signatures
- Dominant language
- Python
- Stars
- 15.6k
- Forks
- 1.8k
- Avg merge
- 12h 13m
- Merged PRs (30d)
- 52
Description
I read through https://github.com/microsoft/pyright/issues/2806
Is there possibility of adding an opt in feature of type checking against overload signatures?
For default values, for example
```python
@overload
def f() -> str: ...
@overload
def f(a: int) -> int: ...
@overload
def f(a: str) -> str: ...
def f(a: int | str | None = None) -> int | str:
if a is None:
return "None"
return a
```
this `def f() -> str:` would be type checked the same as
```python
def f() -> str:
a = None
if a is None:
return "None"
return a
```
I know there are cases where this behavior doesn't work, but if this feature exists, I would just happily enable it and prohibit implementation that doesn't align with it.
Contributor guide
Research direction
Start by reading issue #2806 and the overload-signature behavior described in this issue. Locate Pyright's overload implementation checks and related tests, then define the opt-in configuration and edge-case behavior; done means the proposed default-value example and incompatible implementations are covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100