Closed
Description
This fails:
import re
from typing import Union, Pattern
def f(pattern):
# type: (Union[str, Pattern[str]]) -> None
re.search(pattern, "")
example.py:6: error: Argument 1 to "search" has incompatible type "Union[str, Pattern[str]]"; expected "unicode"
However, this passes without comment:
def g(pattern):
# type: (Union[str, Pattern[str]]) -> None
if isinstance(pattern, str):
re.search(pattern, "")
else:
re.search(pattern, "")