Reassigning `type` fails to typecheck
Open
Nobody has claimed this yet.
bug
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
The following code:
_type = type
v: _type[object]
produces the following output:
$ mypy --enable-incomplete-feature=NewGenericSyntax test.pyi
test.pyi:3:4: error: "type" expects no type arguments, but 1 given [type-arg]
v: _type[object]
^
Found 1 error in 1 file (checked 1 source file)
This looks like a false positive to me.
$ mypy --version
mypy 1.11.0 (compiled: yes)
$ python3 --version
Python 3.12.3
$ lsb_release -d
No LSB modules are available.
Description: Ubuntu 24.04 LTS
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 diagnostic with the provided test.pyi snippet using mypy 1.11.0 and the stated Python version. Trace how mypy handles the reassigned type name, then add a regression test showing that _type[object] is accepted and run the relevant test suite.
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
- 45/100