diff --git a/stubs/regex/@tests/stubtest_allowlist.txt b/stubs/regex/@tests/stubtest_allowlist.txt index c564d57bee85..5629e03e968a 100644 --- a/stubs/regex/@tests/stubtest_allowlist.txt +++ b/stubs/regex/@tests/stubtest_allowlist.txt @@ -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 @@ -18,6 +13,3 @@ 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 e2e362f31f22..eac4fb944388 100644 --- a/stubs/regex/METADATA.toml +++ b/stubs/regex/METADATA.toml @@ -1,2 +1,2 @@ -version = "2025.9.18" +version = "2025.10.23" upstream_repository = "https://github.com/mrabarnett/mrab-regex" diff --git a/stubs/regex/regex/__init__.pyi b/stubs/regex/regex/__init__.pyi index f310be632191..92e7589d0181 100644 --- a/stubs/regex/regex/__init__.pyi +++ b/stubs/regex/regex/__init__.pyi @@ -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", +] diff --git a/stubs/regex/regex/regex.pyi b/stubs/regex/regex/_main.pyi similarity index 95% rename from stubs/regex/regex/regex.pyi rename to stubs/regex/regex/_main.pyi index 990feb4c648e..a37774c6ebde 100644 --- a/stubs/regex/regex/regex.pyi +++ b/stubs/regex/regex/_main.pyi @@ -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, @@ -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 diff --git a/stubs/regex/regex/_regex.pyi b/stubs/regex/regex/_regex.pyi index d9515249b49f..c80e1662c33d 100644 --- a/stubs/regex/regex/_regex.pyi +++ b/stubs/regex/regex/_regex.pyi @@ -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]): diff --git a/stubs/regex/regex/_regex_core.pyi b/stubs/regex/regex/_regex_core.pyi index 7ca60c07e01f..5778565d5fcc 100644 --- a/stubs/regex/regex/_regex_core.pyi +++ b/stubs/regex/regex/_regex_core.pyi @@ -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: ... @@ -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 = VERSION1 _Lexicon: TypeAlias = list[tuple[AnyStr, Callable[[Scanner[AnyStr], AnyStr], Any]]]