Skip to content

Commit 3cfc315

Browse files
authored
Partially restore old (imprecise) signature of Match.group() (#3190)
This partially reverts #3172
1 parent 5638d29 commit 3cfc315

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

stdlib/3/typing.pyi

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ from abc import abstractmethod, ABCMeta
55
from types import CodeType, FrameType, TracebackType
66
import collections # Needed by aliases like DefaultDict, see mypy issue 2986
77

8-
if sys.version_info < (3, 8):
9-
from typing_extensions import Literal
10-
118
# Definitions of special type checking related constructs. Their definition
129
# are not used, so their value does not matter.
1310

@@ -528,17 +525,16 @@ class Match(Generic[AnyStr]):
528525

529526
def expand(self, template: AnyStr) -> AnyStr: ...
530527

528+
# TODO: The return for a group may be None, except if __group is 0 or not given.
531529
@overload
532-
def group(self, __group: Literal[0] = ...) -> AnyStr: ...
533-
@overload
534-
def group(self, __group: Union[str, int]) -> Optional[AnyStr]: ...
530+
def group(self, __group: Union[str, int] = ...) -> AnyStr: ...
535531
@overload
536532
def group(
537533
self,
538534
__group1: Union[str, int],
539535
__group2: Union[str, int],
540536
*groups: Union[str, int],
541-
) -> Tuple[Optional[AnyStr], ...]: ...
537+
) -> Tuple[AnyStr, ...]: ...
542538

543539
def groups(self, default: AnyStr = ...) -> Sequence[AnyStr]: ...
544540
def groupdict(self, default: AnyStr = ...) -> dict[str, AnyStr]: ...

0 commit comments

Comments
 (0)