`reportInvalidTypeVarUse` superfluous when using default values?
- Dominant language
- Python
- Stars
- 15.6k
- Forks
- 1.8k
- Avg merge
- 12h 13m
- Merged PRs (30d)
- 52
Description
Code sample in [pyright playground](https://pyright-play.net/?code=CYUwZgBGD20NoA0IF4IEsB2AXAugCgEMAnAcwC4IAbNAZy0RxQgDpWBKCAWgD4rb6EOCq2YAoIA)
```python
def foo[X = int](arg: list[X] = ...) -> list[X]: ...
```
`pyright` complains that
```
warning: Type variable "X" may go unsolved if caller supplies no argument for parameter "arg"
Provide an overload that specifies the return type when the argument is not supplied (reportInvalidTypeVarUse)
```
But that seems superfluous, given the default value. `reveal_type(foo())` produces `list[int]` as expected and not `list[Unknown]`.
I mean, I can see that maybe one still wants to get a warning here, but it feels more like a lint than an actual typing error.
I would like to silence such errors globally, but `reportInvalidTypeVarUse` also covers other "real" errors like incorrect type var scoping.
Contributor guide
Research direction
Start with the linked Pyright playground example and compare the reportInvalidTypeVarUse diagnostic with reveal_type(foo()). Determine whether a default argument should suppress or separate this diagnostic from other type-variable scoping errors; done means the behavior and configuration match the issue's intended distinction.
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
- 38/100