-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add regex stubs #6713
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add regex stubs #6713
Changes from 11 commits
9207bcb
76656d4
4b43f7d
6f7a6cf
15f4fec
7d3bbf3
8284e84
1be94ad
5ddc098
fca60fb
7944312
021ca84
0453e3c
5ce5e17
1961df1
dad0a1f
c7e64ae
eb84b36
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
regex._regex.Match | ||
regex._regex.Pattern | ||
regex._regex.Scanner | ||
regex._regex.Splitter | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
version = "2021.11.10" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .regex import * |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,184 @@ | ||
from typing import Any, AnyStr, Callable, Generic, Iterator, TypeVar, overload | ||
|
||
_T = TypeVar("_T") | ||
|
||
class Pattern(Generic[AnyStr]): | ||
jpy-git marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
pattern: AnyStr | ||
flags: int | ||
groups: int | ||
groupindex: dict[str, int] | ||
named_lists: dict[str, frozenset[AnyStr]] | ||
jpy-git marked this conversation as resolved.
Show resolved
Hide resolved
|
||
def search( | ||
self, | ||
string: AnyStr, | ||
pos: int | None = ..., | ||
endpos: int | None = ..., | ||
concurrent: bool | None = ..., | ||
timeout: int | None = ..., | ||
) -> Match[AnyStr] | None: ... | ||
def match( | ||
self, | ||
string: AnyStr, | ||
pos: int | None = ..., | ||
endpos: int | None = ..., | ||
concurrent: bool | None = ..., | ||
timeout: int | None = ..., | ||
) -> Match[AnyStr] | None: ... | ||
def fullmatch( | ||
self, | ||
string: AnyStr, | ||
pos: int | None = ..., | ||
endpos: int | None = ..., | ||
concurrent: bool | None = ..., | ||
timeout: int | None = ..., | ||
) -> Match[AnyStr] | None: ... | ||
def split( | ||
self, string: AnyStr, maxsplit: int = ..., concurrent: bool | None = ..., timeout: int | None = ... | ||
) -> list[AnyStr]: ... | ||
def splititer( | ||
self, string: AnyStr, maxsplit: int = ..., concurrent: bool | None = ..., timeout: int | None = ... | ||
) -> Splitter[AnyStr]: ... | ||
def findall( | ||
self, | ||
string: AnyStr, | ||
pos: int | None = ..., | ||
endpos: int | None = ..., | ||
overlapped: bool = ..., | ||
concurrent: bool | None = ..., | ||
timeout: int | None = ..., | ||
) -> list[Any]: ... | ||
def finditer( | ||
self, | ||
string: AnyStr, | ||
pos: int | None = ..., | ||
endpos: int | None = ..., | ||
overlapped: bool = ..., | ||
concurrent: bool | None = ..., | ||
timeout: int | None = ..., | ||
) -> Scanner[AnyStr]: ... | ||
def sub( | ||
self, | ||
repl: AnyStr | Callable[[Match[AnyStr]], AnyStr], | ||
string: AnyStr, | ||
count: int = ..., | ||
flags: int = ..., | ||
pos: int | None = ..., | ||
endpos: int | None = ..., | ||
concurrent: bool | None = ..., | ||
timeout: int | None = ..., | ||
) -> AnyStr: ... | ||
def subf( | ||
self, | ||
format: AnyStr | Callable[[Match[AnyStr]], AnyStr], | ||
string: AnyStr, | ||
count: int = ..., | ||
flags: int = ..., | ||
pos: int | None = ..., | ||
endpos: int | None = ..., | ||
concurrent: bool | None = ..., | ||
timeout: int | None = ..., | ||
) -> AnyStr: ... | ||
def subn( | ||
self, | ||
repl: AnyStr | Callable[[Match[AnyStr]], AnyStr], | ||
string: AnyStr, | ||
count: int = ..., | ||
flags: int = ..., | ||
pos: int | None = ..., | ||
endpos: int | None = ..., | ||
concurrent: bool | None = ..., | ||
timeout: int | None = ..., | ||
) -> tuple[AnyStr, int]: ... | ||
def subfn( | ||
self, | ||
format: AnyStr | Callable[[Match[AnyStr]], AnyStr], | ||
string: AnyStr, | ||
count: int = ..., | ||
flags: int = ..., | ||
pos: int | None = ..., | ||
endpos: int | None = ..., | ||
concurrent: bool | None = ..., | ||
timeout: int | None = ..., | ||
) -> tuple[AnyStr, int]: ... | ||
def scanner( | ||
self, | ||
string: AnyStr, | ||
pos: int | None = ..., | ||
endpos: int | None = ..., | ||
overlapped: bool = ..., | ||
concurrent: bool | None = ..., | ||
timeout: int | None = ..., | ||
) -> Scanner[AnyStr]: ... | ||
|
||
class Match(Generic[AnyStr]): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this missing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense, will make a PR 👍 |
||
|
||
re: Pattern[AnyStr] | ||
string: AnyStr | ||
pos: int | ||
endpos: int | ||
partial: bool | ||
regs: tuple[tuple[int, int], ...] | ||
fuzzy_counts: tuple[int, int, int] | ||
fuzzy_changes: tuple[list[int], list[int], list[int]] | ||
lastgroup: str | None | ||
lastindex: int | None | ||
@overload | ||
def group(self, __group: int | str = ...) -> AnyStr | None: ... | ||
jpy-git marked this conversation as resolved.
Show resolved
Hide resolved
|
||
@overload | ||
def group(self, __group1: int | str, __group2: int | str, *groups: int | str) -> tuple[AnyStr | None, ...]: ... | ||
@overload | ||
def groups(self, default: None = ...) -> tuple[AnyStr | None, ...]: ... | ||
@overload | ||
def groups(self, default: _T) -> tuple[AnyStr | _T, ...]: ... | ||
@overload | ||
def groupdict(self, default: None = ...) -> dict[str, AnyStr | None]: ... | ||
@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: ... | ||
|
||
class Splitter(Generic[AnyStr]): | ||
|
||
pattern: Pattern[AnyStr] | ||
def __iter__(self) -> Iterator[AnyStr]: ... | ||
jpy-git marked this conversation as resolved.
Show resolved
Hide resolved
|
||
def __next__(self) -> AnyStr: ... | ||
def split(self) -> AnyStr | None: ... | ||
|
||
class Scanner(Generic[AnyStr]): | ||
|
||
pattern: Pattern[AnyStr] | ||
def __iter__(self) -> Iterator[Match[AnyStr]]: ... | ||
def __next__(self) -> Match[AnyStr]: ... | ||
def match(self) -> Match[AnyStr] | None: ... | ||
def search(self) -> Match[AnyStr] | None: ... |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from typing import Any, AnyStr, Callable | ||
|
||
class error(Exception): | ||
def __init__(self, message: str, pattern: AnyStr | None = ..., pos: int | None = ...) -> None: ... | ||
|
||
A: int | ||
ASCII: int | ||
B: int | ||
BESTMATCH: int | ||
D: int | ||
DEBUG: int | ||
E: int | ||
ENHANCEMATCH: int | ||
F: int | ||
FULLCASE: int | ||
I: int | ||
IGNORECASE: int | ||
L: int | ||
LOCALE: int | ||
M: int | ||
MULTILINE: int | ||
P: int | ||
POSIX: int | ||
R: int | ||
REVERSE: int | ||
T: int | ||
TEMPLATE: int | ||
S: int | ||
DOTALL: int | ||
U: int | ||
UNICODE: int | ||
V0: int | ||
VERSION0: int | ||
V1: int | ||
VERSION1: int | ||
W: int | ||
WORD: int | ||
X: int | ||
VERBOSE: int | ||
|
||
DEFAULT_VERSION: int | ||
|
||
class Scanner: | ||
def __init__(self, lexicon: list[tuple[AnyStr, Callable[[Scanner, AnyStr], Any] | Any | None]], flags: int = ...) -> None: ... | ||
def scan(self, string: AnyStr) -> tuple[list[Any], AnyStr]: ... | ||
jpy-git marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
from typing import Any, AnyStr, Callable, overload | ||
|
||
from . import _regex | ||
from ._regex_core import * | ||
|
||
__version__: str | ||
|
||
def compile( | ||
pattern: AnyStr | _regex.Pattern[AnyStr], flags: int = ..., ignore_unused: bool = ..., **kwargs: Any | ||
) -> _regex.Pattern[AnyStr]: ... | ||
def search( | ||
pattern: AnyStr | _regex.Pattern[AnyStr], | ||
string: AnyStr, | ||
flags: int = ..., | ||
pos: int | None = ..., | ||
endpos: int | None = ..., | ||
partial: bool = ..., | ||
concurrent: bool | None = ..., | ||
timeout: int | None = ..., | ||
ignore_unused: bool = ..., | ||
**kwargs: Any, | ||
) -> _regex.Match[AnyStr] | None: ... | ||
def match( | ||
pattern: AnyStr | _regex.Pattern[AnyStr], | ||
string: AnyStr, | ||
flags: int = ..., | ||
pos: int | None = ..., | ||
endpos: int | None = ..., | ||
partial: bool = ..., | ||
concurrent: bool | None = ..., | ||
timeout: int | None = ..., | ||
ignore_unused: bool = ..., | ||
**kwargs: Any, | ||
) -> _regex.Match[AnyStr] | None: ... | ||
def fullmatch( | ||
pattern: AnyStr | _regex.Pattern[AnyStr], | ||
string: AnyStr, | ||
flags: int = ..., | ||
pos: int | None = ..., | ||
endpos: int | None = ..., | ||
partial: bool = ..., | ||
concurrent: bool | None = ..., | ||
timeout: int | None = ..., | ||
ignore_unused: bool = ..., | ||
**kwargs: Any, | ||
) -> _regex.Match[AnyStr] | None: ... | ||
def split( | ||
pattern: AnyStr | _regex.Pattern[AnyStr], | ||
string: AnyStr, | ||
maxsplit: int = ..., | ||
flags: int = ..., | ||
concurrent: bool | None = ..., | ||
timeout: int | None = ..., | ||
ignore_unused: bool = ..., | ||
**kwargs: Any, | ||
) -> list[AnyStr]: ... | ||
def splititer( | ||
pattern: AnyStr | _regex.Pattern[AnyStr], | ||
string: AnyStr, | ||
maxsplit: int = ..., | ||
flags: int = ..., | ||
concurrent: bool | None = ..., | ||
timeout: int | None = ..., | ||
ignore_unused: bool = ..., | ||
**kwargs: Any, | ||
) -> _regex.Splitter[AnyStr]: ... | ||
def findall( | ||
pattern: AnyStr | _regex.Pattern[AnyStr], | ||
string: AnyStr, | ||
flags: int = ..., | ||
pos: int | None = ..., | ||
endpos: int | None = ..., | ||
overlapped: bool = ..., | ||
concurrent: bool | None = ..., | ||
timeout: int | None = ..., | ||
ignore_unused: bool = ..., | ||
**kwargs: Any, | ||
) -> list[Any]: ... | ||
def finditer( | ||
pattern: AnyStr | _regex.Pattern[AnyStr], | ||
string: AnyStr, | ||
flags: int = ..., | ||
pos: int | None = ..., | ||
endpos: int | None = ..., | ||
overlapped: bool = ..., | ||
partial: bool = ..., | ||
concurrent: bool | None = ..., | ||
timeout: int | None = ..., | ||
ignore_unused: bool = ..., | ||
**kwargs: Any, | ||
) -> _regex.Scanner[AnyStr]: ... | ||
def sub( | ||
pattern: AnyStr | _regex.Pattern[AnyStr], | ||
repl: AnyStr | Callable[[_regex.Match[AnyStr]], AnyStr], | ||
string: AnyStr, | ||
count: int = ..., | ||
flags: int = ..., | ||
pos: int | None = ..., | ||
endpos: int | None = ..., | ||
concurrent: bool | None = ..., | ||
timeout: int | None = ..., | ||
ignore_unused: bool = ..., | ||
**kwargs: Any, | ||
) -> AnyStr: ... | ||
def subf( | ||
pattern: AnyStr | _regex.Pattern[AnyStr], | ||
format: AnyStr | Callable[[_regex.Match[AnyStr]], AnyStr], | ||
string: AnyStr, | ||
count: int = ..., | ||
flags: int = ..., | ||
pos: int | None = ..., | ||
endpos: int | None = ..., | ||
concurrent: bool | None = ..., | ||
timeout: int | None = ..., | ||
ignore_unused: bool = ..., | ||
**kwargs: Any, | ||
) -> AnyStr: ... | ||
def subn( | ||
pattern: AnyStr | _regex.Pattern[AnyStr], | ||
repl: AnyStr | Callable[[_regex.Match[AnyStr]], AnyStr], | ||
string: AnyStr, | ||
count: int = ..., | ||
flags: int = ..., | ||
pos: int | None = ..., | ||
endpos: int | None = ..., | ||
concurrent: bool | None = ..., | ||
timeout: int | None = ..., | ||
jpy-git marked this conversation as resolved.
Show resolved
Hide resolved
|
||
ignore_unused: bool = ..., | ||
**kwargs: Any, | ||
) -> AnyStr: ... | ||
def subfn( | ||
pattern: AnyStr | _regex.Pattern[AnyStr], | ||
format: AnyStr | Callable[[_regex.Match[AnyStr]], AnyStr], | ||
string: AnyStr, | ||
count: int = ..., | ||
flags: int = ..., | ||
pos: int | None = ..., | ||
endpos: int | None = ..., | ||
concurrent: bool | None = ..., | ||
timeout: int | None = ..., | ||
ignore_unused: bool = ..., | ||
**kwargs: Any, | ||
) -> tuple[AnyStr, int]: ... | ||
def purge() -> None: ... | ||
@overload | ||
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]: ... | ||
|
||
Pattern = _regex.Pattern | ||
Match = _regex.Match | ||
Regex = compile | ||
Akuli marked this conversation as resolved.
Show resolved
Hide resolved
|
Uh oh!
There was an error while loading. Please reload this page.