-
-
Notifications
You must be signed in to change notification settings - Fork 18k
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
TYP: annotation of __init__ return type (PEP 484) (pandas/plotting) #46283
Conversation
@@ -521,7 +521,7 @@ class _Options(dict): | |||
_ALIASES = {"x_compat": "xaxis.compat"} | |||
_DEFAULT_KEYS = ["xaxis.compat"] | |||
|
|||
def __init__(self, deprecated=False): | |||
def __init__(self, deprecated=False) -> None: |
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.
as long as you're doing these can you try to annotate other things in these signatures
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.
No problem, I think I can do it in separate PR as long as these are for fixing __init__
return type annotation
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.
yeah, let's maybe keep the scope here limited to the return type of __init__ since if there is consensus on #46337, there will be quite a bit to do (if not done in one big PR, #46337 (comment))
@@ -783,7 +783,7 @@ class PlotAccessor(PandasObject): | |||
_kind_aliases = {"density": "kde"} | |||
_all_kinds = _common_kinds + _series_kinds + _dataframe_kinds | |||
|
|||
def __init__(self, data): | |||
def __init__(self, data) -> None: |
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.
I am pretty sure that not annotating this was a deliberate decision in the past.
cc @simonjayhawkins did this change over the last few weeks?
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.
I am pretty sure that not annotating this was a deliberate decision in the past.
cc @simonjayhawkins did this change over the last few weeks?
As far as I can see, this line was added on 03/07/2019(#27009) without any additional comments. And this line also has not changed since those times.
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.
I am talking about init returning None in general
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.
Simon mentioned this in #44677 (comment)
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.
thanks @nafarya FYI we are going to do these in a few PRs that cover most of the codebase |
According to documentation pandas uses PEP484 for type hints.
PEP484 states that
__init__
function should have-> None
return type annotation.In this PR I added return type annotation to
__init__
functions inpandas/plotting
module.Thanks!