mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-08 21:14:48 +08:00
Buffer support for re (#7679)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import collections # Needed by aliases like DefaultDict, see mypy issue 2986
|
||||
import sys
|
||||
from _typeshed import Self as TypeshedSelf, SupportsKeysAndGetItem
|
||||
from _typeshed import ReadableBuffer, Self as TypeshedSelf, SupportsKeysAndGetItem
|
||||
from abc import ABCMeta, abstractmethod
|
||||
from types import BuiltinFunctionType, CodeType, FrameType, FunctionType, MethodType, ModuleType, TracebackType
|
||||
from typing_extensions import Literal as _Literal, ParamSpec as _ParamSpec, final as _final
|
||||
@@ -1079,7 +1079,10 @@ class Match(Generic[AnyStr]):
|
||||
# this match instance.
|
||||
@property
|
||||
def re(self) -> Pattern[AnyStr]: ...
|
||||
def expand(self, template: AnyStr) -> AnyStr: ...
|
||||
@overload
|
||||
def expand(self: Match[str], template: str) -> str: ...
|
||||
@overload
|
||||
def expand(self: Match[bytes], template: ReadableBuffer) -> bytes: ...
|
||||
# group() returns "AnyStr" or "AnyStr | None", depending on the pattern.
|
||||
@overload
|
||||
def group(self, __group: _Literal[0] = ...) -> AnyStr: ...
|
||||
@@ -1124,20 +1127,49 @@ class Pattern(Generic[AnyStr]):
|
||||
def groups(self) -> int: ...
|
||||
@property
|
||||
def pattern(self) -> AnyStr: ...
|
||||
def search(self, string: AnyStr, pos: int = ..., endpos: int = ...) -> Match[AnyStr] | None: ...
|
||||
def match(self, string: AnyStr, pos: int = ..., endpos: int = ...) -> Match[AnyStr] | None: ...
|
||||
def fullmatch(self, string: AnyStr, pos: int = ..., endpos: int = ...) -> Match[AnyStr] | None: ...
|
||||
def split(self, string: AnyStr, maxsplit: int = ...) -> list[AnyStr | Any]: ...
|
||||
def findall(self, string: AnyStr, pos: int = ..., endpos: int = ...) -> list[Any]: ...
|
||||
def finditer(self, string: AnyStr, pos: int = ..., endpos: int = ...) -> Iterator[Match[AnyStr]]: ...
|
||||
@overload
|
||||
def sub(self, repl: AnyStr, string: AnyStr, count: int = ...) -> AnyStr: ...
|
||||
def search(self: Pattern[str], string: str, pos: int = ..., endpos: int = ...) -> Match[str] | None: ...
|
||||
@overload
|
||||
def sub(self, repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int = ...) -> AnyStr: ...
|
||||
def search(self: Pattern[bytes], string: ReadableBuffer, pos: int = ..., endpos: int = ...) -> Match[bytes] | None: ...
|
||||
@overload
|
||||
def subn(self, repl: AnyStr, string: AnyStr, count: int = ...) -> tuple[AnyStr, int]: ...
|
||||
def match(self: Pattern[str], string: str, pos: int = ..., endpos: int = ...) -> Match[str] | None: ...
|
||||
@overload
|
||||
def subn(self, repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, count: int = ...) -> tuple[AnyStr, int]: ...
|
||||
def match(self: Pattern[bytes], string: ReadableBuffer, pos: int = ..., endpos: int = ...) -> Match[bytes] | None: ...
|
||||
@overload
|
||||
def fullmatch(self: Pattern[str], string: str, pos: int = ..., endpos: int = ...) -> Match[str] | None: ...
|
||||
@overload
|
||||
def fullmatch(self: Pattern[bytes], string: ReadableBuffer, pos: int = ..., endpos: int = ...) -> Match[bytes] | None: ...
|
||||
@overload
|
||||
def split(self: Pattern[str], string: str, maxsplit: int = ...) -> list[str | Any]: ...
|
||||
@overload
|
||||
def split(self: Pattern[bytes], string: ReadableBuffer, maxsplit: int = ...) -> list[bytes | Any]: ...
|
||||
# return type depends on the number of groups in the pattern
|
||||
@overload
|
||||
def findall(self: Pattern[str], string: str, pos: int = ..., endpos: int = ...) -> list[Any]: ...
|
||||
@overload
|
||||
def findall(self: Pattern[bytes], string: ReadableBuffer, pos: int = ..., endpos: int = ...) -> list[Any]: ...
|
||||
@overload
|
||||
def finditer(self: Pattern[str], string: str, pos: int = ..., endpos: int = ...) -> Iterator[Match[str]]: ...
|
||||
@overload
|
||||
def finditer(self: Pattern[bytes], string: ReadableBuffer, pos: int = ..., endpos: int = ...) -> Iterator[Match[bytes]]: ...
|
||||
@overload
|
||||
def sub(self: Pattern[str], repl: str | Callable[[Match[str]], str], string: str, count: int = ...) -> str: ...
|
||||
@overload
|
||||
def sub(
|
||||
self: Pattern[bytes],
|
||||
repl: ReadableBuffer | Callable[[Match[bytes]], ReadableBuffer],
|
||||
string: ReadableBuffer,
|
||||
count: int = ...,
|
||||
) -> bytes: ...
|
||||
@overload
|
||||
def subn(self: Pattern[str], repl: str | Callable[[Match[str]], str], string: str, count: int = ...) -> tuple[str, int]: ...
|
||||
@overload
|
||||
def subn(
|
||||
self: Pattern[bytes],
|
||||
repl: ReadableBuffer | Callable[[Match[bytes]], ReadableBuffer],
|
||||
string: ReadableBuffer,
|
||||
count: int = ...,
|
||||
) -> tuple[bytes, int]: ...
|
||||
def __copy__(self) -> Pattern[AnyStr]: ...
|
||||
def __deepcopy__(self, __memo: Any) -> Pattern[AnyStr]: ...
|
||||
if sys.version_info >= (3, 9):
|
||||
|
||||
Reference in New Issue
Block a user