Skip to content

Commit a9c442f

Browse files
committed
Add cast to please mypy
1 parent fe640f0 commit a9c442f

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/mypy_issues/diff.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from abc import ABC, abstractmethod
1111
from collections.abc import Iterator
1212
from pathlib import Path
13-
from typing import ClassVar, Final, TextIO
13+
from typing import ClassVar, Final, TextIO, cast
1414

1515
from pygments import highlight
1616
from pygments.formatters import TerminalTrueColorFormatter
@@ -301,7 +301,10 @@ def _normalize(text: str, *, ignore_notes: bool) -> list[str]:
301301
text = re.sub(r"Optional\[(\w+?)\]", r"\1 | None", text)
302302
text = re.sub(r'"Optional\[(.+?)\]"', r'"\1 | None"', text)
303303
while "Union[" in text:
304-
text = re.sub(r"Union\[(.+)", lambda m: _piped_union(m.group(1)), text)
304+
# https://github.com/python/mypy/issues/18738
305+
text = re.sub(
306+
r"Union\[(.+)", lambda m: _piped_union(cast(str, m.group(1))), text
307+
)
305308
for mod in [
306309
r'Skipping analyzing "(.+?)": found module but no type hints or library stubs',
307310
r'Skipping analyzing "(.+)": module is installed, but missing library stubs or py\.typed marker',

0 commit comments

Comments
 (0)