Closed
Description
Currenty all functions in re are typed with AnyStr
, so for example re.match
is defined as follows:
@overload
def match(pattern: AnyStr, string: AnyStr, flags: int = ...) -> Match[AnyStr]: ...
This is a problem, because since AnyStr
is defined as
AnyStr = TypeVar('AnyStr', bytes, str)
You cannot use, for example, a str pattern on an unicode string, which does work fine in Python 2.7.
Which way should this be changed to, so that typeshed reflects the reality?
The same problem appears in a lot of places, since it is used as if it was Union[str, unicode]
.
Metadata
Metadata
Assignees
Labels
No labels