diff --git a/stubs/regex/@tests/stubtest_allowlist.txt b/stubs/regex/@tests/stubtest_allowlist.txt index 2f05cbed1..1591d7371 100644 --- a/stubs/regex/@tests/stubtest_allowlist.txt +++ b/stubs/regex/@tests/stubtest_allowlist.txt @@ -1,6 +1,18 @@ -# These classes are defined in regex/_regex.c and are returned by the public API functions. -# The stubs are defined in regex/_regex.pyi but these classes aren't present at runtime. -regex._regex.Match -regex._regex.Pattern -regex._regex.Scanner +# Not exported in C modules: regex._regex.Splitter +regex._regex.Scanner + +# Implementation details: +regex._regex.compile +regex._regex.copyright +regex._regex.fold_case +regex._regex.get_all_cases +regex._regex.get_code_size +regex._regex.get_expand_on_folding +regex._regex.get_properties +regex._regex.has_property_value +regex._regex.CODE_SIZE +regex._regex.MAGIC + +# Tests: +regex.test_regex diff --git a/stubs/regex/METADATA.toml b/stubs/regex/METADATA.toml index f508c79b6..ebc555e39 100644 --- a/stubs/regex/METADATA.toml +++ b/stubs/regex/METADATA.toml @@ -1 +1,4 @@ version = "2022.10.31" + +[tool.stubtest] +ignore_missing_stub = false diff --git a/stubs/regex/regex/_regex.pyi b/stubs/regex/regex/_regex.pyi index 9cf70db3e..60cd19e6c 100644 --- a/stubs/regex/regex/_regex.pyi +++ b/stubs/regex/regex/_regex.pyi @@ -1,329 +1,13 @@ -from _typeshed import ReadableBuffer, Self -from collections.abc import Callable, Mapping -from typing import Any, AnyStr, Generic, TypeVar, overload -from typing_extensions import Literal, final +# This is actually a C-extension module. +# Not all types defined in C are exported to Python. +# For example: `Pattern` and `Match` are not exported +# and are redefined in `regex.regex module. -_T = TypeVar("_T") +from _typeshed import Self +from typing import Any, AnyStr, Generic +from typing_extensions import final -@final -class Pattern(Generic[AnyStr]): - @property - def flags(self) -> int: ... - @property - def groupindex(self) -> Mapping[str, int]: ... - @property - def groups(self) -> int: ... - @property - def pattern(self) -> AnyStr: ... - @property - def named_lists(self) -> Mapping[str, frozenset[AnyStr]]: ... - @overload - def search( - self: Pattern[str], - string: str, - pos: int = ..., - endpos: int = ..., - concurrent: bool | None = ..., - timeout: float | None = ..., - ) -> Match[str] | None: ... - @overload - def search( - self: Pattern[bytes], - string: ReadableBuffer, - pos: int = ..., - endpos: int = ..., - concurrent: bool | None = ..., - timeout: float | None = ..., - ) -> Match[bytes] | None: ... - @overload - def match( - self: Pattern[str], - string: str, - pos: int = ..., - endpos: int = ..., - concurrent: bool | None = ..., - timeout: float | None = ..., - ) -> Match[str] | None: ... - @overload - def match( - self: Pattern[bytes], - string: ReadableBuffer, - pos: int = ..., - endpos: int = ..., - concurrent: bool | None = ..., - timeout: float | None = ..., - ) -> Match[bytes] | None: ... - @overload - def fullmatch( - self: Pattern[str], - string: str, - pos: int = ..., - endpos: int = ..., - concurrent: bool | None = ..., - timeout: float | None = ..., - ) -> Match[str] | None: ... - @overload - def fullmatch( - self: Pattern[bytes], - string: ReadableBuffer, - pos: int = ..., - endpos: int = ..., - concurrent: bool | None = ..., - timeout: float | None = ..., - ) -> Match[bytes] | None: ... - @overload - def split( - self: Pattern[str], string: str, maxsplit: int = ..., concurrent: bool | None = ..., timeout: float | None = ... - ) -> list[str | Any]: ... - @overload - def split( - self: Pattern[bytes], - string: ReadableBuffer, - maxsplit: int = ..., - concurrent: bool | None = ..., - timeout: float | None = ..., - ) -> list[bytes | Any]: ... - @overload - def splititer( - self: Pattern[str], string: str, maxsplit: int = ..., concurrent: bool | None = ..., timeout: float | None = ... - ) -> Splitter[str]: ... - @overload - def splititer( - self: Pattern[bytes], - string: ReadableBuffer, - maxsplit: int = ..., - concurrent: bool | None = ..., - timeout: float | None = ..., - ) -> Splitter[bytes]: ... - @overload - def findall( - self: Pattern[str], - string: str, - pos: int = ..., - endpos: int = ..., - overlapped: bool = ..., - concurrent: bool | None = ..., - timeout: float | None = ..., - ) -> list[Any]: ... - @overload - def findall( - self: Pattern[bytes], - string: ReadableBuffer, - pos: int = ..., - endpos: int = ..., - overlapped: bool = ..., - concurrent: bool | None = ..., - timeout: float | None = ..., - ) -> list[Any]: ... - @overload - def finditer( - self: Pattern[str], - string: str, - pos: int = ..., - endpos: int = ..., - overlapped: bool = ..., - concurrent: bool | None = ..., - timeout: float | None = ..., - ) -> Scanner[str]: ... - @overload - def finditer( - self: Pattern[bytes], - string: ReadableBuffer, - pos: int = ..., - endpos: int = ..., - overlapped: bool = ..., - concurrent: bool | None = ..., - timeout: float | None = ..., - ) -> Scanner[bytes]: ... - @overload - def sub( - self: Pattern[str], - repl: str | Callable[[Match[str]], str], - string: str, - count: int = ..., - flags: int = ..., - pos: int | None = ..., - endpos: int | None = ..., - concurrent: bool | None = ..., - timeout: float | None = ..., - ) -> str: ... - @overload - def sub( - self: Pattern[bytes], - repl: ReadableBuffer | Callable[[Match[bytes]], ReadableBuffer], - string: ReadableBuffer, - count: int = ..., - flags: int = ..., - pos: int | None = ..., - endpos: int | None = ..., - concurrent: bool | None = ..., - timeout: float | None = ..., - ) -> bytes: ... - @overload - def subf( - self: Pattern[str], - format: str | Callable[[Match[str]], str], - string: str, - count: int = ..., - flags: int = ..., - pos: int | None = ..., - endpos: int | None = ..., - concurrent: bool | None = ..., - timeout: float | None = ..., - ) -> str: ... - @overload - def subf( - self: Pattern[bytes], - format: ReadableBuffer | Callable[[Match[bytes]], ReadableBuffer], - string: ReadableBuffer, - count: int = ..., - flags: int = ..., - pos: int | None = ..., - endpos: int | None = ..., - concurrent: bool | None = ..., - timeout: float | None = ..., - ) -> bytes: ... - @overload - def subn( - self: Pattern[str], - repl: str | Callable[[Match[str]], str], - string: str, - count: int = ..., - flags: int = ..., - pos: int | None = ..., - endpos: int | None = ..., - concurrent: bool | None = ..., - timeout: float | None = ..., - ) -> tuple[str, int]: ... - @overload - def subn( - self: Pattern[bytes], - repl: ReadableBuffer | Callable[[Match[bytes]], ReadableBuffer], - string: ReadableBuffer, - count: int = ..., - flags: int = ..., - pos: int | None = ..., - endpos: int | None = ..., - concurrent: bool | None = ..., - timeout: float | None = ..., - ) -> tuple[bytes, int]: ... - @overload - def subfn( - self: Pattern[str], - format: str | Callable[[Match[str]], str], - string: str, - count: int = ..., - flags: int = ..., - pos: int | None = ..., - endpos: int | None = ..., - concurrent: bool | None = ..., - timeout: float | None = ..., - ) -> tuple[str, int]: ... - @overload - def subfn( - self: Pattern[bytes], - format: ReadableBuffer | Callable[[Match[bytes]], ReadableBuffer], - string: ReadableBuffer, - count: int = ..., - flags: int = ..., - pos: int | None = ..., - endpos: int | None = ..., - concurrent: bool | None = ..., - timeout: float | None = ..., - ) -> tuple[bytes, int]: ... - @overload - def scanner( - self: Pattern[str], - string: str, - pos: int | None = ..., - endpos: int | None = ..., - overlapped: bool = ..., - concurrent: bool | None = ..., - timeout: float | None = ..., - ) -> Scanner[str]: ... - @overload - def scanner( - self: Pattern[bytes], - string: bytes, - pos: int | None = ..., - endpos: int | None = ..., - overlapped: bool = ..., - concurrent: bool | None = ..., - timeout: float | None = ..., - ) -> Scanner[bytes]: ... - -@final -class Match(Generic[AnyStr]): - @property - def pos(self) -> int: ... - @property - def endpos(self) -> int: ... - @property - def lastindex(self) -> int | None: ... - @property - def lastgroup(self) -> str | None: ... - @property - def string(self) -> AnyStr: ... - @property - def re(self) -> Pattern[AnyStr]: ... - @property - def partial(self) -> bool: ... - @property - def regs(self) -> tuple[tuple[int, int], ...]: ... - @property - def fuzzy_counts(self) -> tuple[int, int, int]: ... - @property - def fuzzy_changes(self) -> tuple[list[int], list[int], list[int]]: ... - @overload - def group(self, __group: Literal[0] = ...) -> AnyStr: ... - @overload - def group(self, __group: int | str = ...) -> AnyStr | Any: ... - @overload - def group(self, __group1: int | str, __group2: int | str, *groups: int | str) -> tuple[AnyStr | Any, ...]: ... - @overload - def groups(self, default: None = ...) -> tuple[AnyStr | Any, ...]: ... - @overload - def groups(self, default: _T) -> tuple[AnyStr | _T, ...]: ... - @overload - def groupdict(self, default: None = ...) -> dict[str, AnyStr | Any]: ... - @overload - def groupdict(self, default: _T) -> dict[str, AnyStr | _T]: ... - @overload - def span(self, __group: int | str = ...) -> tuple[int, int]: ... - @overload - def span(self, __group1: int | str, __group2: int | str, *groups: int | str) -> tuple[tuple[int, int], ...]: ... - @overload - def spans(self, __group: int | str = ...) -> list[tuple[int, int]]: ... - @overload - def spans(self, __group1: int | str, __group2: int | str, *groups: int | str) -> tuple[list[tuple[int, int]], ...]: ... - @overload - def start(self, __group: int | str = ...) -> int: ... - @overload - def start(self, __group1: int | str, __group2: int | str, *groups: int | str) -> tuple[int, ...]: ... - @overload - def starts(self, __group: int | str = ...) -> list[int]: ... - @overload - def starts(self, __group1: int | str, __group2: int | str, *groups: int | str) -> tuple[list[int], ...]: ... - @overload - def end(self, __group: int | str = ...) -> int: ... - @overload - def end(self, __group1: int | str, __group2: int | str, *groups: int | str) -> tuple[int, ...]: ... - @overload - def ends(self, __group: int | str = ...) -> list[int]: ... - @overload - def ends(self, __group1: int | str, __group2: int | str, *groups: int | str) -> tuple[list[int], ...]: ... - def expand(self, template: AnyStr) -> AnyStr: ... - def expandf(self, format: AnyStr) -> AnyStr: ... - @overload - def captures(self, __group: int | str = ...) -> list[AnyStr]: ... - @overload - def captures(self, __group1: int | str, __group2: int | str, *groups: int | str) -> tuple[list[AnyStr], ...]: ... - def capturesdict(self) -> dict[str, list[AnyStr]]: ... - def detach_string(self) -> None: ... - @overload - def __getitem__(self, __key: Literal[0]) -> AnyStr: ... - @overload - def __getitem__(self, __key: int | str) -> AnyStr | Any: ... +from .regex import Match, Pattern @final class Splitter(Generic[AnyStr]): diff --git a/stubs/regex/regex/_regex_core.pyi b/stubs/regex/regex/_regex_core.pyi index 5af02ff8d..cca9a476c 100644 --- a/stubs/regex/regex/_regex_core.pyi +++ b/stubs/regex/regex/_regex_core.pyi @@ -1,5 +1,9 @@ import enum -from typing import AnyStr +from collections.abc import Callable +from typing import Any, AnyStr, Generic +from typing_extensions import TypeAlias + +from .regex import Pattern class error(Exception): def __init__(self, message: str, pattern: AnyStr | None = ..., pos: int | None = ...) -> None: ... @@ -76,3 +80,12 @@ X: int VERBOSE: int DEFAULT_VERSION: int + +_Lexicon: TypeAlias = list[tuple[AnyStr, Callable[[Scanner[AnyStr], AnyStr], Any]]] + +class Scanner(Generic[AnyStr]): + lexicon: _Lexicon[AnyStr] + scanner: Pattern[AnyStr] + + def __init__(self, lexicon: _Lexicon[AnyStr], flags: int = ...) -> None: ... + def scan(self, string: AnyStr) -> tuple[list[Any], AnyStr]: ... diff --git a/stubs/regex/regex/regex.pyi b/stubs/regex/regex/regex.pyi index 694da59e2..594284129 100644 --- a/stubs/regex/regex/regex.pyi +++ b/stubs/regex/regex/regex.pyi @@ -1,20 +1,26 @@ -from _typeshed import ReadableBuffer -from collections.abc import Callable -from typing import Any, AnyStr, overload +import sys +from _typeshed import ReadableBuffer, Self +from collections.abc import Callable, Mapping +from typing import Any, AnyStr, Generic, TypeVar, overload +from typing_extensions import Literal, final from . import _regex -from ._regex import Match as Match, Pattern as Pattern from ._regex_core import * +if sys.version_info >= (3, 9): + from types import GenericAlias + +_T = TypeVar("_T") + __version__: str def compile( - pattern: AnyStr | _regex.Pattern[AnyStr], + pattern: AnyStr | Pattern[AnyStr], flags: int = ..., ignore_unused: bool = ..., cache_pattern: bool | None = ..., **kwargs: Any, -) -> _regex.Pattern[AnyStr]: ... +) -> Pattern[AnyStr]: ... @overload def search( pattern: str | Pattern[str], @@ -27,7 +33,7 @@ def search( timeout: float | None = ..., ignore_unused: bool = ..., **kwargs: Any, -) -> _regex.Match[str] | None: ... +) -> Match[str] | None: ... @overload def search( pattern: bytes | Pattern[bytes], @@ -40,7 +46,7 @@ def search( timeout: float | None = ..., ignore_unused: bool = ..., **kwargs: Any, -) -> _regex.Match[bytes] | None: ... +) -> Match[bytes] | None: ... @overload def match( pattern: str | Pattern[str], @@ -53,7 +59,7 @@ def match( timeout: float | None = ..., ignore_unused: bool = ..., **kwargs: Any, -) -> _regex.Match[str] | None: ... +) -> Match[str] | None: ... @overload def match( pattern: bytes | Pattern[bytes], @@ -66,7 +72,7 @@ def match( timeout: float | None = ..., ignore_unused: bool = ..., **kwargs: Any, -) -> _regex.Match[bytes] | None: ... +) -> Match[bytes] | None: ... @overload def fullmatch( pattern: str | Pattern[str], @@ -79,7 +85,7 @@ def fullmatch( timeout: float | None = ..., ignore_unused: bool = ..., **kwargs: Any, -) -> _regex.Match[str] | None: ... +) -> Match[str] | None: ... @overload def fullmatch( pattern: bytes | Pattern[bytes], @@ -92,10 +98,10 @@ def fullmatch( timeout: float | None = ..., ignore_unused: bool = ..., **kwargs: Any, -) -> _regex.Match[bytes] | None: ... +) -> Match[bytes] | None: ... @overload def split( - pattern: str | _regex.Pattern[str], + pattern: str | Pattern[str], string: str, maxsplit: int = ..., flags: int = ..., @@ -106,7 +112,7 @@ def split( ) -> list[str | Any]: ... @overload def split( - pattern: ReadableBuffer | _regex.Pattern[bytes], + pattern: ReadableBuffer | Pattern[bytes], string: ReadableBuffer, maxsplit: int = ..., flags: int = ..., @@ -117,7 +123,7 @@ def split( ) -> list[bytes | Any]: ... @overload def splititer( - pattern: str | _regex.Pattern[str], + pattern: str | Pattern[str], string: str, maxsplit: int = ..., flags: int = ..., @@ -128,7 +134,7 @@ def splititer( ) -> _regex.Splitter[str]: ... @overload def splititer( - pattern: ReadableBuffer | _regex.Pattern[bytes], + pattern: ReadableBuffer | Pattern[bytes], string: ReadableBuffer, maxsplit: int = ..., flags: int = ..., @@ -139,7 +145,7 @@ def splititer( ) -> _regex.Splitter[bytes]: ... @overload def findall( - pattern: str | _regex.Pattern[str], + pattern: str | Pattern[str], string: str, flags: int = ..., pos: int | None = ..., @@ -152,7 +158,7 @@ def findall( ) -> list[Any]: ... @overload def findall( - pattern: ReadableBuffer | _regex.Pattern[bytes], + pattern: ReadableBuffer | Pattern[bytes], string: ReadableBuffer, flags: int = ..., pos: int | None = ..., @@ -165,7 +171,7 @@ def findall( ) -> list[Any]: ... @overload def finditer( - pattern: str | _regex.Pattern[str], + pattern: str | Pattern[str], string: str, flags: int = ..., pos: int | None = ..., @@ -176,10 +182,10 @@ def finditer( timeout: float | None = ..., ignore_unused: bool = ..., **kwargs: Any, -) -> _regex.Scanner[str]: ... +) -> Scanner[str]: ... @overload def finditer( - pattern: ReadableBuffer | _regex.Pattern[bytes], + pattern: ReadableBuffer | Pattern[bytes], string: ReadableBuffer, flags: int = ..., pos: int | None = ..., @@ -190,11 +196,11 @@ def finditer( timeout: float | None = ..., ignore_unused: bool = ..., **kwargs: Any, -) -> _regex.Scanner[bytes]: ... +) -> Scanner[bytes]: ... @overload def sub( - pattern: str | _regex.Pattern[str], - repl: str | Callable[[_regex.Match[str]], str], + pattern: str | Pattern[str], + repl: str | Callable[[Match[str]], str], string: str, count: int = ..., flags: int = ..., @@ -207,8 +213,8 @@ def sub( ) -> str: ... @overload def sub( - pattern: ReadableBuffer | _regex.Pattern[bytes], - repl: ReadableBuffer | Callable[[_regex.Match[bytes]], ReadableBuffer], + pattern: ReadableBuffer | Pattern[bytes], + repl: ReadableBuffer | Callable[[Match[bytes]], ReadableBuffer], string: ReadableBuffer, count: int = ..., flags: int = ..., @@ -221,8 +227,8 @@ def sub( ) -> bytes: ... @overload def subf( - pattern: str | _regex.Pattern[str], - format: str | Callable[[_regex.Match[str]], str], + pattern: str | Pattern[str], + format: str | Callable[[Match[str]], str], string: str, count: int = ..., flags: int = ..., @@ -235,8 +241,8 @@ def subf( ) -> str: ... @overload def subf( - pattern: ReadableBuffer | _regex.Pattern[bytes], - format: ReadableBuffer | Callable[[_regex.Match[bytes]], ReadableBuffer], + pattern: ReadableBuffer | Pattern[bytes], + format: ReadableBuffer | Callable[[Match[bytes]], ReadableBuffer], string: ReadableBuffer, count: int = ..., flags: int = ..., @@ -249,8 +255,8 @@ def subf( ) -> bytes: ... @overload def subn( - pattern: str | _regex.Pattern[str], - repl: str | Callable[[_regex.Match[str]], str], + pattern: str | Pattern[str], + repl: str | Callable[[Match[str]], str], string: str, count: int = ..., flags: int = ..., @@ -263,8 +269,8 @@ def subn( ) -> tuple[str, int]: ... @overload def subn( - pattern: ReadableBuffer | _regex.Pattern[bytes], - repl: ReadableBuffer | Callable[[_regex.Match[bytes]], ReadableBuffer], + pattern: ReadableBuffer | Pattern[bytes], + repl: ReadableBuffer | Callable[[Match[bytes]], ReadableBuffer], string: ReadableBuffer, count: int = ..., flags: int = ..., @@ -277,8 +283,8 @@ def subn( ) -> tuple[bytes, int]: ... @overload def subfn( - pattern: str | _regex.Pattern[str], - format: str | Callable[[_regex.Match[str]], str], + pattern: str | Pattern[str], + format: str | Callable[[Match[str]], str], string: str, count: int = ..., flags: int = ..., @@ -291,8 +297,8 @@ def subfn( ) -> tuple[str, int]: ... @overload def subfn( - pattern: ReadableBuffer | _regex.Pattern[bytes], - format: ReadableBuffer | Callable[[_regex.Match[bytes]], ReadableBuffer], + pattern: ReadableBuffer | Pattern[bytes], + format: ReadableBuffer | Callable[[Match[bytes]], ReadableBuffer], string: ReadableBuffer, count: int = ..., flags: int = ..., @@ -309,6 +315,336 @@ def cache_all(value: bool = ...) -> None: ... @overload def cache_all(value: None) -> bool: ... def escape(pattern: AnyStr, special_only: bool = ..., literal_spaces: bool = ...) -> AnyStr: ... -def template(pattern: AnyStr | _regex.Pattern[AnyStr], flags: int = ...) -> _regex.Pattern[AnyStr]: ... +def template(pattern: AnyStr | Pattern[AnyStr], flags: int = ...) -> Pattern[AnyStr]: ... Regex = compile + +@final +class Pattern(Generic[AnyStr]): + @property + def flags(self) -> int: ... + @property + def groupindex(self) -> Mapping[str, int]: ... + @property + def groups(self) -> int: ... + @property + def pattern(self) -> AnyStr: ... + @property + def named_lists(self) -> Mapping[str, frozenset[AnyStr]]: ... + @overload + def search( + self: Pattern[str], + string: str, + pos: int = ..., + endpos: int = ..., + concurrent: bool | None = ..., + timeout: float | None = ..., + ) -> Match[str] | None: ... + @overload + def search( + self: Pattern[bytes], + string: ReadableBuffer, + pos: int = ..., + endpos: int = ..., + concurrent: bool | None = ..., + timeout: float | None = ..., + ) -> Match[bytes] | None: ... + @overload + def match( + self: Pattern[str], + string: str, + pos: int = ..., + endpos: int = ..., + concurrent: bool | None = ..., + timeout: float | None = ..., + ) -> Match[str] | None: ... + @overload + def match( + self: Pattern[bytes], + string: ReadableBuffer, + pos: int = ..., + endpos: int = ..., + concurrent: bool | None = ..., + timeout: float | None = ..., + ) -> Match[bytes] | None: ... + @overload + def fullmatch( + self: Pattern[str], + string: str, + pos: int = ..., + endpos: int = ..., + concurrent: bool | None = ..., + timeout: float | None = ..., + ) -> Match[str] | None: ... + @overload + def fullmatch( + self: Pattern[bytes], + string: ReadableBuffer, + pos: int = ..., + endpos: int = ..., + concurrent: bool | None = ..., + timeout: float | None = ..., + ) -> Match[bytes] | None: ... + @overload + def split( + self: Pattern[str], string: str, maxsplit: int = ..., concurrent: bool | None = ..., timeout: float | None = ... + ) -> list[str | Any]: ... + @overload + def split( + self: Pattern[bytes], + string: ReadableBuffer, + maxsplit: int = ..., + concurrent: bool | None = ..., + timeout: float | None = ..., + ) -> list[bytes | Any]: ... + @overload + def splititer( + self: Pattern[str], string: str, maxsplit: int = ..., concurrent: bool | None = ..., timeout: float | None = ... + ) -> _regex.Splitter[str]: ... + @overload + def splititer( + self: Pattern[bytes], + string: ReadableBuffer, + maxsplit: int = ..., + concurrent: bool | None = ..., + timeout: float | None = ..., + ) -> _regex.Splitter[bytes]: ... + @overload + def findall( + self: Pattern[str], + string: str, + pos: int = ..., + endpos: int = ..., + overlapped: bool = ..., + concurrent: bool | None = ..., + timeout: float | None = ..., + ) -> list[Any]: ... + @overload + def findall( + self: Pattern[bytes], + string: ReadableBuffer, + pos: int = ..., + endpos: int = ..., + overlapped: bool = ..., + concurrent: bool | None = ..., + timeout: float | None = ..., + ) -> list[Any]: ... + @overload + def finditer( + self: Pattern[str], + string: str, + pos: int = ..., + endpos: int = ..., + overlapped: bool = ..., + concurrent: bool | None = ..., + timeout: float | None = ..., + ) -> Scanner[str]: ... + @overload + def finditer( + self: Pattern[bytes], + string: ReadableBuffer, + pos: int = ..., + endpos: int = ..., + overlapped: bool = ..., + concurrent: bool | None = ..., + timeout: float | None = ..., + ) -> Scanner[bytes]: ... + @overload + def sub( + self: Pattern[str], + repl: str | Callable[[Match[str]], str], + string: str, + count: int = ..., + flags: int = ..., + pos: int | None = ..., + endpos: int | None = ..., + concurrent: bool | None = ..., + timeout: float | None = ..., + ) -> str: ... + @overload + def sub( + self: Pattern[bytes], + repl: ReadableBuffer | Callable[[Match[bytes]], ReadableBuffer], + string: ReadableBuffer, + count: int = ..., + flags: int = ..., + pos: int | None = ..., + endpos: int | None = ..., + concurrent: bool | None = ..., + timeout: float | None = ..., + ) -> bytes: ... + @overload + def subf( + self: Pattern[str], + format: str | Callable[[Match[str]], str], + string: str, + count: int = ..., + flags: int = ..., + pos: int | None = ..., + endpos: int | None = ..., + concurrent: bool | None = ..., + timeout: float | None = ..., + ) -> str: ... + @overload + def subf( + self: Pattern[bytes], + format: ReadableBuffer | Callable[[Match[bytes]], ReadableBuffer], + string: ReadableBuffer, + count: int = ..., + flags: int = ..., + pos: int | None = ..., + endpos: int | None = ..., + concurrent: bool | None = ..., + timeout: float | None = ..., + ) -> bytes: ... + @overload + def subn( + self: Pattern[str], + repl: str | Callable[[Match[str]], str], + string: str, + count: int = ..., + flags: int = ..., + pos: int | None = ..., + endpos: int | None = ..., + concurrent: bool | None = ..., + timeout: float | None = ..., + ) -> tuple[str, int]: ... + @overload + def subn( + self: Pattern[bytes], + repl: ReadableBuffer | Callable[[Match[bytes]], ReadableBuffer], + string: ReadableBuffer, + count: int = ..., + flags: int = ..., + pos: int | None = ..., + endpos: int | None = ..., + concurrent: bool | None = ..., + timeout: float | None = ..., + ) -> tuple[bytes, int]: ... + @overload + def subfn( + self: Pattern[str], + format: str | Callable[[Match[str]], str], + string: str, + count: int = ..., + flags: int = ..., + pos: int | None = ..., + endpos: int | None = ..., + concurrent: bool | None = ..., + timeout: float | None = ..., + ) -> tuple[str, int]: ... + @overload + def subfn( + self: Pattern[bytes], + format: ReadableBuffer | Callable[[Match[bytes]], ReadableBuffer], + string: ReadableBuffer, + count: int = ..., + flags: int = ..., + pos: int | None = ..., + endpos: int | None = ..., + concurrent: bool | None = ..., + timeout: float | None = ..., + ) -> tuple[bytes, int]: ... + @overload + def scanner( + self: Pattern[str], + string: str, + pos: int | None = ..., + endpos: int | None = ..., + overlapped: bool = ..., + concurrent: bool | None = ..., + timeout: float | None = ..., + ) -> Scanner[str]: ... + @overload + def scanner( + self: Pattern[bytes], + string: bytes, + pos: int | None = ..., + endpos: int | None = ..., + overlapped: bool = ..., + concurrent: bool | None = ..., + timeout: float | None = ..., + ) -> Scanner[bytes]: ... + def __copy__(self: Self) -> Self: ... + def __deepcopy__(self: Self) -> Self: ... + if sys.version_info >= (3, 9): + def __class_getitem__(cls, item: Any) -> GenericAlias: ... + +@final +class Match(Generic[AnyStr]): + @property + def pos(self) -> int: ... + @property + def endpos(self) -> int: ... + @property + def lastindex(self) -> int | None: ... + @property + def lastgroup(self) -> str | None: ... + @property + def string(self) -> AnyStr: ... + @property + def re(self) -> Pattern[AnyStr]: ... + @property + def partial(self) -> bool: ... + @property + def regs(self) -> tuple[tuple[int, int], ...]: ... + @property + def fuzzy_counts(self) -> tuple[int, int, int]: ... + @property + def fuzzy_changes(self) -> tuple[list[int], list[int], list[int]]: ... + @overload + def group(self, __group: Literal[0] = ...) -> AnyStr: ... + @overload + def group(self, __group: int | str = ...) -> AnyStr | Any: ... + @overload + def group(self, __group1: int | str, __group2: int | str, *groups: int | str) -> tuple[AnyStr | Any, ...]: ... + @overload + def groups(self, default: None = ...) -> tuple[AnyStr | Any, ...]: ... + @overload + def groups(self, default: _T) -> tuple[AnyStr | _T, ...]: ... + @overload + def groupdict(self, default: None = ...) -> dict[str, AnyStr | Any]: ... + @overload + def groupdict(self, default: _T) -> dict[str, AnyStr | _T]: ... + @overload + def span(self, __group: int | str = ...) -> tuple[int, int]: ... + @overload + def span(self, __group1: int | str, __group2: int | str, *groups: int | str) -> tuple[tuple[int, int], ...]: ... + @overload + def spans(self, __group: int | str = ...) -> list[tuple[int, int]]: ... + @overload + def spans(self, __group1: int | str, __group2: int | str, *groups: int | str) -> tuple[list[tuple[int, int]], ...]: ... + @overload + def start(self, __group: int | str = ...) -> int: ... + @overload + def start(self, __group1: int | str, __group2: int | str, *groups: int | str) -> tuple[int, ...]: ... + @overload + def starts(self, __group: int | str = ...) -> list[int]: ... + @overload + def starts(self, __group1: int | str, __group2: int | str, *groups: int | str) -> tuple[list[int], ...]: ... + @overload + def end(self, __group: int | str = ...) -> int: ... + @overload + def end(self, __group1: int | str, __group2: int | str, *groups: int | str) -> tuple[int, ...]: ... + @overload + def ends(self, __group: int | str = ...) -> list[int]: ... + @overload + def ends(self, __group1: int | str, __group2: int | str, *groups: int | str) -> tuple[list[int], ...]: ... + def expand(self, template: AnyStr) -> AnyStr: ... + def expandf(self, format: AnyStr) -> AnyStr: ... + @overload + def captures(self, __group: int | str = ...) -> list[AnyStr]: ... + @overload + def captures(self, __group1: int | str, __group2: int | str, *groups: int | str) -> tuple[list[AnyStr], ...]: ... + def capturesdict(self) -> dict[str, list[AnyStr]]: ... + def detach_string(self) -> None: ... + def allcaptures(self) -> tuple[list[AnyStr]]: ... + def allspans(self) -> tuple[list[tuple[int, int]]]: ... + @overload + def __getitem__(self, __key: Literal[0]) -> AnyStr: ... + @overload + def __getitem__(self, __key: int | str) -> AnyStr | Any: ... + def __copy__(self: Self) -> Self: ... + def __deepcopy__(self: Self) -> Self: ... + if sys.version_info >= (3, 9): + def __class_getitem__(cls, item: Any) -> GenericAlias: ...