Parametrised Callable allowed only when used as type alias
Open
Nobody has claimed this yet.
topic: documentation
- Dominant language
- Python
- Stars
- 1.8k
- Forks
- 302
- Avg merge
- 23h
- Merged PRs (30d)
- 8
Description
I've found a case where a Callable is not allowed when used directly, but is allowed if used as an alias
from typing import TypeVar, Callable
T = TypeVar('T')
MkFoo = Callable[[T], list[T]]
def foo(mkfoo: MkFoo) -> None:
_ = mkfoo(0)
works, but replacing MkFoo by its definition
def foo(mkfoo: Callable[[T], list[T]]) -> None:
_ = mkfoo(0)
produces
main.py:13: error: Argument 1 has incompatible type "int"; expected "T"
Contributor guide
No contributing guide indexed for this repository
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 with the two reproductions shown in main.py, comparing the parametrised Callable used directly with the equivalent type alias. Check the resulting type-checker behavior and existing discussion; done means determining whether both forms should be accepted and adding or updating coverage for the agreed behavior.
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