`in` operator error with Generator
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Bug Report
https://mypy-play.net/?mypy=latest&python=3.12&gist=790ec23819f191c250a9574f2b123d8d
To Reproduce
1 in (i for i in (signal.SIGINT,))
Expected Behavior
No error
Actual Behavior
error: Unsupported operand types for in ("int" and "Generator[Signals, None, None]") [operator]
If the generator is changed to a list comprehension, there is no error
Your Environment
- Mypy version used: 2.1.0 and master branch
- Python version used: 3.12
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 running the mypy-play reproduction from the issue with Python 3.12, then trace how mypy checks the in operator when the right-hand side is a generator. Add a regression test covering the shown signal.SIGINT expression; done means it produces no unsupported-operand error while the existing list-comprehension behavior remains unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100