From f2f343906d60a97576e4e00c29767bf138e04c65 Mon Sep 17 00:00:00 2001 From: donBarbos Date: Wed, 22 Oct 2025 08:58:12 +0400 Subject: [PATCH 1/4] [regex] Update to 2025.10.23 Closes: #14907 --- stubs/regex/@tests/stubtest_allowlist.txt | 8 --- stubs/regex/METADATA.toml | 2 +- stubs/regex/regex/__init__.pyi | 65 +++++++++++++++++- stubs/regex/regex/{regex.pyi => _main.pyi} | 65 ++++++++++++++++++ stubs/regex/regex/_regex.pyi | 2 +- stubs/regex/regex/_regex_core.pyi | 78 ++++++++++++++++------ 6 files changed, 190 insertions(+), 30 deletions(-) rename stubs/regex/regex/{regex.pyi => _main.pyi} (95%) 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..14af762bcd7a 100644 --- a/stubs/regex/regex/__init__.pyi +++ b/stubs/regex/regex/__init__.pyi @@ -1 +1,64 @@ -from .regex import * +from regex._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..1c7b637c3661 100644 --- a/stubs/regex/regex/regex.pyi +++ b/stubs/regex/regex/_main.pyi @@ -11,6 +11,68 @@ _T = TypeVar("_T") __version__: str +__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 +374,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..ba525fc65be5 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 regex 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..331e475d9456 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 regex 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 = VERSION0 _Lexicon: TypeAlias = list[tuple[AnyStr, Callable[[Scanner[AnyStr], AnyStr], Any]]] From 96e8a32b94ca6a268d4d76b3af83bbf140f051e9 Mon Sep 17 00:00:00 2001 From: donBarbos Date: Wed, 22 Oct 2025 09:17:33 +0400 Subject: [PATCH 2/4] Add another sync comment --- stubs/regex/regex/_main.pyi | 1 + 1 file changed, 1 insertion(+) diff --git a/stubs/regex/regex/_main.pyi b/stubs/regex/regex/_main.pyi index 1c7b637c3661..a37774c6ebde 100644 --- a/stubs/regex/regex/_main.pyi +++ b/stubs/regex/regex/_main.pyi @@ -11,6 +11,7 @@ _T = TypeVar("_T") __version__: str +# Sync with regex.__init__.__all__ __all__ = [ "cache_all", "compile", From 948340c17dc3392fac20654e4005431cd159d515 Mon Sep 17 00:00:00 2001 From: donBarbos Date: Wed, 22 Oct 2025 09:20:17 +0400 Subject: [PATCH 3/4] Fix import names --- stubs/regex/regex/__init__.pyi | 2 +- stubs/regex/regex/_regex.pyi | 2 +- stubs/regex/regex/_regex_core.pyi | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/stubs/regex/regex/__init__.pyi b/stubs/regex/regex/__init__.pyi index 14af762bcd7a..92e7589d0181 100644 --- a/stubs/regex/regex/__init__.pyi +++ b/stubs/regex/regex/__init__.pyi @@ -1,4 +1,4 @@ -from regex._main import * +from ._main import * # Sync with regex._main.__all__ __all__ = [ diff --git a/stubs/regex/regex/_regex.pyi b/stubs/regex/regex/_regex.pyi index ba525fc65be5..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 331e475d9456..db532208b11e 100644 --- a/stubs/regex/regex/_regex_core.pyi +++ b/stubs/regex/regex/_regex_core.pyi @@ -3,7 +3,7 @@ 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", From 9ef1edcd1304f37811f5cbcc823afb1b67cd330c Mon Sep 17 00:00:00 2001 From: Semyon Moroz Date: Wed, 22 Oct 2025 15:00:05 +0400 Subject: [PATCH 4/4] Update _regex_core.pyi Co-authored-by: Sebastian Rittau --- stubs/regex/regex/_regex_core.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/regex/regex/_regex_core.pyi b/stubs/regex/regex/_regex_core.pyi index db532208b11e..5778565d5fcc 100644 --- a/stubs/regex/regex/_regex_core.pyi +++ b/stubs/regex/regex/_regex_core.pyi @@ -119,7 +119,7 @@ W = RegexFlag.W X = RegexFlag.X T = RegexFlag.T -DEFAULT_VERSION = VERSION0 +DEFAULT_VERSION = VERSION1 _Lexicon: TypeAlias = list[tuple[AnyStr, Callable[[Scanner[AnyStr], AnyStr], Any]]]