Open
Description
Original report by Anonymous.
The following code fails under both mypy and pyright:
import re
a: int = 1
m = re.match('foo', 'foobar')
if m:
a = m[1]
As "str" is incompatible with "int". But the same does not happen for the regex
module.
Is the solution something like
from typing import Match
m: Match[str] | None = regex.match(...)
or is there a better way to enable type checking here?
Thanks,
Rich