-
-
Notifications
You must be signed in to change notification settings - Fork 146
Fix annotations of str methods that accept regular expressions #1278
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,12 +83,17 @@ class StringMethods( | |
) -> _T_STR: ... | ||
@overload | ||
def split( | ||
self, pat: str = ..., *, n: int = ..., expand: Literal[True], regex: bool = ... | ||
self, | ||
pat: str | re.Pattern[str] = ..., | ||
*, | ||
n: int = ..., | ||
expand: Literal[True], | ||
regex: bool = ..., | ||
) -> _T_EXPANDING: ... | ||
@overload | ||
def split( | ||
self, | ||
pat: str = ..., | ||
pat: str | re.Pattern[str] = ..., | ||
*, | ||
n: int = ..., | ||
expand: Literal[False] = ..., | ||
|
@@ -133,11 +138,15 @@ class StringMethods( | |
regex: bool = ..., | ||
) -> _T_BOOL: ... | ||
def match( | ||
self, pat: str, case: bool = ..., flags: int = ..., na: Any = ... | ||
self, | ||
pat: str | re.Pattern[str], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the only one of the changed methods that is not documented as accepting a compiled regex but this is an oversight https://pandas.pydata.org/docs/reference/api/pandas.Series.str.match.html. See pandas-dev/pandas#61879 |
||
case: bool = ..., | ||
flags: int = ..., | ||
na: Any = ..., | ||
) -> _T_BOOL: ... | ||
def replace( | ||
self, | ||
pat: str, | ||
pat: str | re.Pattern[str], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
repl: str | Callable[[re.Match[str]], str], | ||
n: int = ..., | ||
case: bool | None = ..., | ||
|
@@ -180,18 +189,26 @@ class StringMethods( | |
def count(self, pat: str, flags: int = ...) -> _T_INT: ... | ||
def startswith(self, pat: str | tuple[str, ...], na: Any = ...) -> _T_BOOL: ... | ||
def endswith(self, pat: str | tuple[str, ...], na: Any = ...) -> _T_BOOL: ... | ||
def findall(self, pat: str, flags: int = ...) -> _T_LIST_STR: ... | ||
def findall(self, pat: str | re.Pattern[str], flags: int = ...) -> _T_LIST_STR: ... | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
@overload | ||
def extract( | ||
self, pat: str, flags: int = ..., *, expand: Literal[True] = ... | ||
self, | ||
pat: str | re.Pattern[str], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
flags: int = ..., | ||
*, | ||
expand: Literal[True] = ..., | ||
) -> pd.DataFrame: ... | ||
@overload | ||
def extract(self, pat: str, flags: int, expand: Literal[False]) -> _T_OBJECT: ... | ||
def extract( | ||
self, pat: str | re.Pattern[str], flags: int, expand: Literal[False] | ||
) -> _T_OBJECT: ... | ||
@overload | ||
def extract( | ||
self, pat: str, flags: int = ..., *, expand: Literal[False] | ||
self, pat: str | re.Pattern[str], flags: int = ..., *, expand: Literal[False] | ||
) -> _T_OBJECT: ... | ||
def extractall(self, pat: str, flags: int = ...) -> pd.DataFrame: ... | ||
def extractall( | ||
self, pat: str | re.Pattern[str], flags: int = ... | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
) -> pd.DataFrame: ... | ||
def find(self, sub: str, start: int = ..., end: int | None = ...) -> _T_INT: ... | ||
def rfind(self, sub: str, start: int = ..., end: int | None = ...) -> _T_INT: ... | ||
def normalize(self, form: Literal["NFC", "NFKC", "NFD", "NFKD"]) -> _T_STR: ... | ||
|
@@ -214,7 +231,11 @@ class StringMethods( | |
def isnumeric(self) -> _T_BOOL: ... | ||
def isdecimal(self) -> _T_BOOL: ... | ||
def fullmatch( | ||
self, pat: str, case: bool = ..., flags: int = ..., na: Any = ... | ||
self, | ||
pat: str | re.Pattern[str], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
case: bool = ..., | ||
flags: int = ..., | ||
na: Any = ..., | ||
) -> _T_BOOL: ... | ||
def removeprefix(self, prefix: str) -> _T_STR: ... | ||
def removesuffix(self, suffix: str) -> _T_STR: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://pandas.pydata.org/docs/reference/api/pandas.Series.str.rsplit.html#pandas.Series.str.rsplit