Setting two arguments to `Optional` within `reveal_type()` doesn't get error
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
*Memo:
mypy test.py
mypy 1.19.1
Python 3.14.0
Windows 11
Setting two arguments to Optional properly gets the error as shown below:
from typing import Optional
# ↓↓↓ ↓↓↓
v: Optional[int, str] = 100 # Error
error: Optional[...] must have exactly one type argument
But, setting two arguments to Optional within reveal_type() doesn't get the error as shown below so the error should occur:
from typing import Optional, reveal_type
# ↓↓↓ ↓↓↓
reveal_type(Optional[int, str]) # No error
note: Revealed type is "typing._SpecialForm"
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 issue from the provided test.py snippets with mypy 1.19.1 on Python 3.14. Start by tracing how reveal_type() handles Optional[int, str] compared with an annotation context. Done means the reveal_type() expression reports the same invalid-argument error as the annotation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 62/100