Closed as not planned
Description
I've been trying to typecheck some code that uses re.match
but getting some unexpected Any
s in it that came from these typeshed definitions (especially the second and third ones):
# group() returns "AnyStr" or "AnyStr | None", depending on the pattern.
@overload
def group(self, group: Literal[0] = 0, /) -> AnyStr: ...
@overload
def group(self, group: str | int, /) -> AnyStr | Any: ...
@overload
def group(self, group1: str | int, group2: str | int, /, *groups: str | int) -> tuple[AnyStr | Any, ...]: ...
Under what circumstance is producing an Any
at this point a good plan? The AnyStr
is fine, but surely the Any
should be a None
? After all, right now it's saying "Oh, we could spontaneously return a lock object from the concurrency
module because we're feeling bored; no promises!" which is rather at variance with the documentation which says effectively "returns a substring if there is a match group, otherwise None
".
Metadata
Metadata
Assignees
Labels
No labels