Closed

Description
Bug Report
I am typechecking a match statement with a tuple of union types and it fails.
To Reproduce
Playground: https://mypy-play.net/?mypy=latest&python=3.10&gist=992b588ec7e4807f3105db45fa9ef0a8
My union type:
TransactionType = str | int | None
(Problem persists even if I do:
from typing import Union
TransactionType = Union[str | int | None]
)
This works fine:
def test(a: TransactionType) -> bool:
match a:
case str():
a.lower()
return True
case _:
return False
This causes an error:
def test2(a: TransactionType, b: TransactionType) -> bool:
match a,b:
case str(), _:
a.lower()
return True
case _:
return False
Actual Behavior
main.py:13: error: Item "int" of "Union[str, int, None]" has no attribute "lower" [union-attr]
main.py:13: error: Item "None" of "Union[str, int, None]" has no attribute "lower" [union-attr]
Found 2 errors in 1 file (checked 1 source file)
Your Environment
- Mypy version used: 1.3.0
- Mypy command-line flags: None
- Mypy configuration options from
mypy.ini
(and other config files): None - Python version used: 3.10 (also tested on 3.11, same problem)