Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions stubs/regex/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
# TODO: missing from stub
regex.__all__
regex._regex_core.__all__
regex.regex.__all__

# Not exported in C modules:
regex._regex.Splitter
regex._regex.Scanner
Expand All @@ -18,6 +13,3 @@ regex._regex.get_properties
regex._regex.has_property_value
regex._regex.CODE_SIZE
regex._regex.MAGIC

# Tests:
regex.test_regex
2 changes: 1 addition & 1 deletion stubs/regex/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version = "2025.9.18"
version = "2025.10.23"
upstream_repository = "https://github.com/mrabarnett/mrab-regex"
65 changes: 64 additions & 1 deletion stubs/regex/regex/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1 +1,64 @@
from .regex import *
from ._main import *

# Sync with regex._main.__all__
__all__ = [
"cache_all",
"compile",
"DEFAULT_VERSION",
"escape",
"findall",
"finditer",
"fullmatch",
"match",
"purge",
"search",
"split",
"splititer",
"sub",
"subf",
"subfn",
"subn",
"template",
"Scanner",
"A",
"ASCII",
"B",
"BESTMATCH",
"D",
"DEBUG",
"E",
"ENHANCEMATCH",
"S",
"DOTALL",
"F",
"FULLCASE",
"I",
"IGNORECASE",
"L",
"LOCALE",
"M",
"MULTILINE",
"P",
"POSIX",
"R",
"REVERSE",
"T",
"TEMPLATE",
"U",
"UNICODE",
"V0",
"VERSION0",
"V1",
"VERSION1",
"X",
"VERBOSE",
"W",
"WORD",
"error",
"Regex",
"__version__",
"__doc__",
"RegexFlag",
"Pattern",
"Match",
]
66 changes: 66 additions & 0 deletions stubs/regex/regex/regex.pyi → stubs/regex/regex/_main.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,69 @@ _T = TypeVar("_T")

__version__: str

# Sync with regex.__init__.__all__
__all__ = [
"cache_all",
"compile",
"DEFAULT_VERSION",
"escape",
"findall",
"finditer",
"fullmatch",
"match",
"purge",
"search",
"split",
"splititer",
"sub",
"subf",
"subfn",
"subn",
"template",
"Scanner",
"A",
"ASCII",
"B",
"BESTMATCH",
"D",
"DEBUG",
"E",
"ENHANCEMATCH",
"S",
"DOTALL",
"F",
"FULLCASE",
"I",
"IGNORECASE",
"L",
"LOCALE",
"M",
"MULTILINE",
"P",
"POSIX",
"R",
"REVERSE",
"T",
"TEMPLATE",
"U",
"UNICODE",
"V0",
"VERSION0",
"V1",
"VERSION1",
"X",
"VERBOSE",
"W",
"WORD",
"error",
"Regex",
"__version__",
"__doc__",
"RegexFlag",
"Pattern",
"Match",
]

def compile(
pattern: AnyStr | Pattern[AnyStr],
flags: int = 0,
Expand Down Expand Up @@ -312,6 +375,9 @@ def cache_all(value: bool = True) -> None: ...
@overload
def cache_all(value: None) -> bool: ...
def escape(pattern: AnyStr, special_only: bool = True, literal_spaces: bool = False) -> AnyStr: ...

DEFAULT_VERSION = RegexFlag.VERSION0

def template(pattern: AnyStr | Pattern[AnyStr], flags: int = 0) -> Pattern[AnyStr]: ...

Regex = compile
Expand Down
2 changes: 1 addition & 1 deletion stubs/regex/regex/_regex.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from typing import Any, AnyStr, Generic, final
from typing_extensions import Self

from .regex import Match, Pattern
from ._main import Match, Pattern

@final
class Splitter(Generic[AnyStr]):
Expand Down
78 changes: 59 additions & 19 deletions stubs/regex/regex/_regex_core.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,47 @@ from collections.abc import Callable
from typing import Any, AnyStr, Generic
from typing_extensions import TypeAlias

from .regex import Pattern
from ._main import Pattern

__all__ = [
"A",
"ASCII",
"B",
"BESTMATCH",
"D",
"DEBUG",
"E",
"ENHANCEMATCH",
"F",
"FULLCASE",
"I",
"IGNORECASE",
"L",
"LOCALE",
"M",
"MULTILINE",
"P",
"POSIX",
"R",
"REVERSE",
"S",
"DOTALL",
"T",
"TEMPLATE",
"U",
"UNICODE",
"V0",
"VERSION0",
"V1",
"VERSION1",
"W",
"WORD",
"X",
"VERBOSE",
"error",
"Scanner",
"RegexFlag",
]

class error(Exception):
def __init__(self, message: str, pattern: AnyStr | None = None, pos: int | None = None) -> None: ...
Expand Down Expand Up @@ -44,42 +84,42 @@ class RegexFlag(enum.IntFlag):
X = 0x40
VERBOSE = X

A = RegexFlag.A
ASCII = RegexFlag.ASCII
B = RegexFlag.B
BESTMATCH = RegexFlag.BESTMATCH
D = RegexFlag.D
DEBUG = RegexFlag.DEBUG
E = RegexFlag.E
ENHANCEMATCH = RegexFlag.ENHANCEMATCH
F = RegexFlag.F
FULLCASE = RegexFlag.FULLCASE
I = RegexFlag.I
IGNORECASE = RegexFlag.IGNORECASE
L = RegexFlag.L
LOCALE = RegexFlag.LOCALE
M = RegexFlag.M
MULTILINE = RegexFlag.MULTILINE
P = RegexFlag.P
POSIX = RegexFlag.POSIX
R = RegexFlag.R
REVERSE = RegexFlag.REVERSE
T = RegexFlag.T
TEMPLATE = RegexFlag.TEMPLATE
S = RegexFlag.S
DOTALL = RegexFlag.DOTALL
U = RegexFlag.U
UNICODE = RegexFlag.UNICODE
V0 = RegexFlag.V0
VERBOSE = RegexFlag.VERBOSE
VERSION0 = RegexFlag.VERSION0
V1 = RegexFlag.V1
VERSION1 = RegexFlag.VERSION1
W = RegexFlag.W
WORD = RegexFlag.WORD
A = RegexFlag.A
B = RegexFlag.B
D = RegexFlag.D
E = RegexFlag.E
F = RegexFlag.F
I = RegexFlag.I
L = RegexFlag.L
M = RegexFlag.M
P = RegexFlag.P
R = RegexFlag.R
S = RegexFlag.S
U = RegexFlag.U
V0 = RegexFlag.V0
V1 = RegexFlag.V1
W = RegexFlag.W
X = RegexFlag.X
VERBOSE = RegexFlag.VERBOSE
T = RegexFlag.T

DEFAULT_VERSION: RegexFlag
DEFAULT_VERSION = VERSION0
Comment thread
donbarbos marked this conversation as resolved.
Outdated

_Lexicon: TypeAlias = list[tuple[AnyStr, Callable[[Scanner[AnyStr], AnyStr], Any]]]

Expand Down