-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
TYP: Add cast to ABC classes. #37902
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
Changes from all commits
8a466ac
99c9e6b
f8a76bc
c9a31a4
1ac7c9e
2ba5fbe
bcd0257
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 |
---|---|---|
|
@@ -8,6 +8,8 @@ | |
import tokenize | ||
from typing import Iterator, Tuple | ||
|
||
from pandas._typing import Label | ||
|
||
# A token value Python's tokenizer probably will never use. | ||
BACKTICK_QUOTED_STRING = 100 | ||
|
||
|
@@ -91,7 +93,7 @@ def clean_backtick_quoted_toks(tok: Tuple[int, str]) -> Tuple[int, str]: | |
return toknum, tokval | ||
|
||
|
||
def clean_column_name(name: str) -> str: | ||
def clean_column_name(name: "Label") -> "Label": | ||
rhshadrach marked this conversation as resolved.
Show resolved
Hide resolved
|
||
""" | ||
Function to emulate the cleaning of a backtick quoted name. | ||
|
||
|
@@ -102,12 +104,12 @@ def clean_column_name(name: str) -> str: | |
|
||
Parameters | ||
---------- | ||
name : str | ||
name : hashable | ||
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. shouldn't this be Label (or is this consistent with how we do elsewhere?) 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. A quick search reveals 6 counts of "Label", 2 counts of "hashable" (other than the 2 added in this PR). @simonjayhawkins requested hashable over Label, and I like the idea of staying away from pandas-defined types for readability. This is an internal function, so that reasoning doesn't directly apply, but it seems best to me to not have a conditional when deciding on typing in docstrings (e.g. hashable when function is public, Label otherwise). 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. kk that's fine, just worried that we are inconsistent generally. i am not sure this is actually easy to check, but we should try to be as consisten as possible. |
||
Name to be cleaned. | ||
|
||
Returns | ||
------- | ||
name : str | ||
name : hashable | ||
Returns the name after tokenizing and cleaning. | ||
|
||
Notes | ||
|
Uh oh!
There was an error while loading. Please reload this page.