"object" not callable when creating an instance of tuple by using type alias
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Bug Report
Mypy shows an error when creating an instance of tuple by using type alias. Error is not present when doing the same with type alias of a list. It's likely caused by the way tuples are instantiated directly from the __new__ method.
To Reproduce
Vector = tuple[int]
v = Vector([1,2,3])
Expected Behavior
No error
Actual Behavior
error: "object" not callable
Your Environment
- Mypy version used: 0.812
- Mypy command-line flags: none
- Mypy configuration options from
mypy.ini(and other config files): none - Python version used: 3.9.2
- Operating system and version: Windows 10
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 with the reproducer using Vector = tuple[int] and Vector([1,2,3]), then compare how mypy handles this tuple alias with the equivalent list alias. Run mypy against the example and trace the tuple instantiation and __new__ handling. Done means the valid tuple construction no longer reports "object" not callable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100