Skip to content
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

fix: add missing overload for sub #4

Closed
wants to merge 3 commits into from
Closed
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.venv/
.idea/
18 changes: 13 additions & 5 deletions src/re2-stubs/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import AnyStr, Generic, Iterator, Literal, TypeVar, overload
from typing import AnyStr, Generic, Iterator, Literal, TypeVar, overload, Callable

# References:

Check failure on line 3 in src/re2-stubs/__init__.pyi

View workflow job for this annotation

GitHub Actions / test

Ruff (I001)

src/re2-stubs/__init__.pyi:1:1: I001 Import block is un-sorted or un-formatted
# - https://github.com/google/re2/blob/main/re2/re2.h and
# - https://github.com/python/typeshed/blob/main/stdlib/re.pyi
# - and re2 implementation
Expand Down Expand Up @@ -99,15 +99,15 @@
@overload
def sub(
pattern: _Regexp[str] | str,
repl: str,
repl: str | Callable[[_Match[str]], str],
text: str,
count: int = 0,
options: Options | None = None,
) -> str: ...
@overload
def sub(
pattern: _Regexp[bytes] | bytes,
repl: bytes,
repl: bytes | Callable[[_Match[bytes]], bytes],
text: bytes,
count: int = 0,
options: Options | None = None,
Expand Down Expand Up @@ -185,10 +185,18 @@
self: _Regexp[bytes], repl: bytes, text: bytes, count: int = 0
) -> tuple[bytes, int]: ...
@overload
def sub(self: _Regexp[str], repl: str, text: str, count: int = 0) -> str: ...
def sub(
self: _Regexp[str],
repl: str | Callable[[_Match[str]], str],
text: str,
count: int = 0,
) -> str: ...
@overload
def sub(
self: _Regexp[bytes], repl: bytes, text: bytes, count: int = 0
self: _Regexp[bytes],
repl: bytes | Callable[[_Match[bytes]], bytes],
text: bytes,
count: int = 0,
) -> bytes: ...
@property
def pattern(self) -> AnyStr: ...
Expand Down
Loading