(🐞) no error when can't able to infer type argument and becomes `Never`
Open
Nobody has claimed this yet.
bug
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
# Some stub
from typing import TypeVar
T = TypeVar("T")
def something(x: T = ...) -> T:
"""x, the parameter for everything (formally Twitter)"""
# some other file
f: object
f = something()
reveal_type(f) # Never
if f:
print("hi") # unreachable
print("hi") # unreachable
We have an interesting array of bugs on display here, but most importantly I think, is that the call to something doesn't report that T can't be inferred.
Seeing as f is object here, I would expect T to be inferred as object
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
Reproduce the reported example in mypy and inspect the type-inference and error-reporting paths used for a call with an unconstrained TypeVar default. Verify the intended result for f: object = something() and ensure the completed behavior no longer silently produces Never or marks the following code unreachable.
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
- 35/100