Skip to content

move re.error into re.pyi #11188

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 4 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 10 additions & 1 deletion stdlib/re.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import sre_constants
import sys
from _typeshed import ReadableBuffer
from collections.abc import Callable, Iterator, Mapping
from sre_constants import error as error
from typing import Any, AnyStr, Generic, Literal, TypeVar, final, overload
from typing_extensions import TypeAlias

Expand Down Expand Up @@ -54,6 +53,16 @@ if sys.version_info >= (3, 13):

_T = TypeVar("_T")

# The implementation defines this in re._constants (version_info >= 3, 11) or
# sre_constants. Typeshed has it here because its __module__ attribute is set to "re".
class error(Exception):
msg: str
pattern: str | bytes | None
pos: int | None
lineno: int
colno: int
def __init__(self, msg: str, pattern: str | bytes | None = None, pos: int | None = None) -> None: ...

@final
class Match(Generic[AnyStr]):
@property
Expand Down
9 changes: 1 addition & 8 deletions stdlib/sre_constants.pyi
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
import sys
from re import error as error
from typing import Any
from typing_extensions import Self

MAXGROUPS: int

MAGIC: int

class error(Exception):
msg: str
pattern: str | bytes | None
pos: int | None
lineno: int
colno: int
def __init__(self, msg: str, pattern: str | bytes | None = None, pos: int | None = None) -> None: ...

class _NamedIntConstant(int):
name: Any
def __new__(cls, value: int, name: str) -> Self: ...
Expand Down