Skip to content

Commit d34a45d

Browse files
authored
sre parse_template allows byte sources (#4604)
Resolves #4331
1 parent 8a1be21 commit d34a45d

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

stdlib/3/sre_parse.pyi

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import sys
44
from sre_constants import _NamedIntConstant as _NIC, error as _Error
5-
from typing import Any, Dict, FrozenSet, Iterable, List, Match, Optional, Pattern as _Pattern, Tuple, Union
5+
from typing import Any, Dict, FrozenSet, Iterable, List, Match, Optional, Pattern as _Pattern, Tuple, Union, overload
66

77
SPECIAL_CHARS: str
88
REPEAT_CHARS: str
@@ -85,13 +85,20 @@ class Tokenizer:
8585

8686
def fix_flags(src: Union[str, bytes], flags: int) -> int: ...
8787

88-
_TemplateType = Tuple[List[Tuple[int, int]], List[str]]
88+
_TemplateType = Tuple[List[Tuple[int, int]], List[Optional[str]]]
89+
_TemplateByteType = Tuple[List[Tuple[int, int]], List[Optional[bytes]]]
8990
if sys.version_info >= (3, 8):
9091
def parse(str: str, flags: int = ..., state: Optional[State] = ...) -> SubPattern: ...
92+
@overload
9193
def parse_template(source: str, state: _Pattern[Any]) -> _TemplateType: ...
94+
@overload
95+
def parse_template(source: bytes, state: _Pattern[Any]) -> _TemplateByteType: ...
9296

9397
else:
9498
def parse(str: str, flags: int = ..., pattern: Optional[Pattern] = ...) -> SubPattern: ...
99+
@overload
95100
def parse_template(source: str, pattern: _Pattern[Any]) -> _TemplateType: ...
101+
@overload
102+
def parse_template(source: bytes, pattern: _Pattern[Any]) -> _TemplateByteType: ...
96103

97104
def expand_template(template: _TemplateType, match: Match[Any]) -> str: ...

0 commit comments

Comments
 (0)