singledispatch and TypeVar return type
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.1k
- Forks
- 2.1k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 82
Description
It seems that singledispatch typing is not very accurate. In particular, it does not respect TypeVar used in the return type:
T = TypeVar("T")
@singledispatch
def my_fun(
val: T,
) -> List[T]:
return list(val)
my_fun(5)
my_fun("Ĝis la revido!")
Here the type of the returned value would always be revealed as List[T] instead of different types for different inputs.
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 reproducing the example with Python's singledispatch typing and inspect the relevant typeshed definitions. Determine how the TypeVar in the return type is handled; done means calls with different argument types reveal correspondingly specialized List return types.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100