-
-
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
Merged
Merged
Add regex stubs #6713
Changes from 2 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
9207bcb
Add initial regex stubs
jpy-git 76656d4
Remove stubgen comments
jpy-git 4b43f7d
Remove unused import
jpy-git 6f7a6cf
Add C module classes
jpy-git 15f4fec
Use type alias for Pattern and Match
jpy-git 7d3bbf3
Use frozenset over Frozenset
jpy-git 8284e84
Add error and Scanner
jpy-git 1be94ad
Add error and Scanner
jpy-git 5ddc098
use list[Any] instead of union return
jpy-git fca60fb
Update stubs/regex/regex/regex.pyi
jpy-git 7944312
Remove unnecessary overrides
jpy-git 021ca84
Use Mapping over dict
jpy-git 0453e3c
Remove undocumented Scanner class and use _typeshed.Self
jpy-git 5ce5e17
Add stubtest comment
jpy-git 1961df1
Align returns with re
jpy-git dad0a1f
Update stubs/regex/@tests/stubtest_allowlist.txt
jpy-git c7e64ae
Implement review feedback
jpy-git eb84b36
Use typing_extensions for Literal and final
jpy-git File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
version = "2021.11.10" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .regex import * |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from typing import Any | ||
|
||
class Pattern: | ||
def __getattr__(self, name: str) -> Any: ... # incomplete | ||
|
||
class Match: | ||
def __getattr__(self, name: str) -> Any: ... # incomplete | ||
|
||
class Scanner: | ||
def __getattr__(self, name: str) -> Any: ... # incomplete | ||
|
||
class Splitter: | ||
def __getattr__(self, name: str) -> Any: ... # incomplete | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,349 @@ | ||
from typing import Any, AnyStr, Callable, NoReturn, Tuple, _Alias, overload | ||
|
||
import regex._regex as _regex | ||
|
||
__version__: str | ||
|
||
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 | ||
|
||
@overload | ||
def compile(pattern: AnyStr, flags: int = ..., ignore_unused: bool = ..., **kwargs: Any) -> _regex.Pattern: ... | ||
@overload | ||
def compile(pattern: _regex.Pattern, flags: int = ..., ignore_unused: bool = ..., **kwargs: Any) -> _regex.Pattern: ... | ||
jpy-git marked this conversation as resolved.
Show resolved
Hide resolved
|
||
@overload | ||
def search( | ||
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 | None: ... | ||
@overload | ||
def search( | ||
pattern: _regex.Pattern, | ||
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 | None: ... | ||
@overload | ||
def match( | ||
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: ... | ||
@overload | ||
def match( | ||
pattern: _regex.Pattern, | ||
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: ... | ||
@overload | ||
def fullmatch( | ||
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: ... | ||
@overload | ||
def fullmatch( | ||
pattern: _regex.Pattern, | ||
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: ... | ||
@overload | ||
def split( | ||
pattern: AnyStr, | ||
string: AnyStr, | ||
maxsplit: int = ..., | ||
flags: int = ..., | ||
concurrent: bool | None = ..., | ||
timeout: int | None = ..., | ||
ignore_unused: bool = ..., | ||
**kwargs: Any, | ||
) -> list[AnyStr]: ... | ||
@overload | ||
def split( | ||
pattern: _regex.Pattern, | ||
string: AnyStr, | ||
maxsplit: int = ..., | ||
flags: int = ..., | ||
concurrent: bool | None = ..., | ||
timeout: int | None = ..., | ||
ignore_unused: bool = ..., | ||
**kwargs: Any, | ||
) -> list[AnyStr]: ... | ||
@overload | ||
def splititer( | ||
pattern: AnyStr, | ||
string: AnyStr, | ||
maxsplit: int = ..., | ||
flags: int = ..., | ||
concurrent: bool | None = ..., | ||
timeout: int | None = ..., | ||
ignore_unused: bool = ..., | ||
**kwargs: Any, | ||
) -> _regex.Splitter: ... | ||
@overload | ||
def splititer( | ||
pattern: _regex.Pattern, | ||
string: AnyStr, | ||
maxsplit: int = ..., | ||
flags: int = ..., | ||
concurrent: bool | None = ..., | ||
timeout: int | None = ..., | ||
ignore_unused: bool = ..., | ||
**kwargs: Any, | ||
) -> _regex.Splitter: ... | ||
@overload | ||
def findall( | ||
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[str] | list[Tuple[str, ...]]: ... | ||
jpy-git marked this conversation as resolved.
Show resolved
Hide resolved
|
||
@overload | ||
def findall( | ||
pattern: _regex.Pattern, | ||
string: AnyStr, | ||
flags: int = ..., | ||
pos: int | None = ..., | ||
endpos: int | None = ..., | ||
overlapped: bool = ..., | ||
concurrent: bool | None = ..., | ||
timeout: int | None = ..., | ||
ignore_unused: bool = ..., | ||
**kwargs: Any, | ||
) -> list[str] | list[Tuple[str, ...]]: ... | ||
jpy-git marked this conversation as resolved.
Show resolved
Hide resolved
|
||
@overload | ||
def finditer( | ||
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: ... | ||
@overload | ||
def finditer( | ||
pattern: _regex.Pattern, | ||
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: ... | ||
def purge() -> None: ... | ||
@overload | ||
def cache_all(value: bool = ...) -> NoReturn: ... | ||
@overload | ||
def cache_all(value: None = ...) -> bool: ... | ||
def escape(pattern: AnyStr, special_only: bool = ..., literal_spaces: bool = ...) -> AnyStr: ... | ||
@overload | ||
def template(pattern: AnyStr, flags: int = ...) -> _regex.Pattern: ... | ||
@overload | ||
def template(pattern: _regex.Pattern, flags: int = ...) -> _regex.Pattern: ... | ||
@overload | ||
def sub( | ||
pattern: AnyStr, | ||
repl: AnyStr | Callable[[_regex.Match], 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: ... | ||
@overload | ||
def sub( | ||
pattern: _regex.Pattern, | ||
repl: AnyStr | Callable[[_regex.Match], 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: ... | ||
@overload | ||
def subf( | ||
pattern: AnyStr, | ||
format: AnyStr | Callable[[_regex.Match], 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: ... | ||
@overload | ||
def subf( | ||
pattern: _regex.Pattern, | ||
format: AnyStr | Callable[[_regex.Match], 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: ... | ||
@overload | ||
def subn( | ||
pattern: AnyStr, | ||
repl: AnyStr | Callable[[_regex.Match], 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: ... | ||
@overload | ||
def subn( | ||
pattern: _regex.Pattern, | ||
repl: AnyStr | Callable[[_regex.Match], 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: ... | ||
@overload | ||
def subfn( | ||
pattern: AnyStr, | ||
format: AnyStr | Callable[[_regex.Match], 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]: ... | ||
@overload | ||
def subfn( | ||
pattern: _regex.Pattern, | ||
format: AnyStr | Callable[[_regex.Match], 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]: ... | ||
|
||
Pattern: _regex.Pattern | ||
Match: _regex.Match | ||
jpy-git marked this conversation as resolved.
Show resolved
Hide resolved
jpy-git marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Regex = compile | ||
Akuli marked this conversation as resolved.
Show resolved
Hide resolved
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.