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

TYP: annotation of __init__ return type (PEP 484) (pandas/plotting) #46283

Merged
merged 2 commits into from
Mar 16, 2022

Conversation

nafarya
Copy link
Contributor

@nafarya nafarya commented Mar 8, 2022

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 in pandas/plotting module.
Thanks!

@@ -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:
Copy link
Member

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

Copy link
Contributor Author

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

Copy link
Member

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))

@jreback jreback added this to the 1.5 milestone Mar 9, 2022
@jreback jreback added the Typing type annotations, mypy/pyright type checking label Mar 9, 2022
@@ -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:
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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

Copy link
Member

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)

Copy link
Member

@simonjayhawkins simonjayhawkins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @nafarya lgtm pending outcome of discussion in #46337

@jreback jreback merged commit c0d746f into pandas-dev:main Mar 16, 2022
@jreback
Copy link
Contributor

jreback commented Mar 16, 2022

thanks @nafarya FYI we are going to do these in a few PRs that cover most of the codebase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Typing type annotations, mypy/pyright type checking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants