Skip to content

TYP: Annotate plotting stacker #36016

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

Merged

Conversation

jbrockmendel
Copy link
Member

In AreaPlot._plot we call ax.fill_between, which means ax must be an Axes object (and in particular, not an Axis object). This chases down all the other places we can infer Axes from that.

Then some edits in an __init__ to get mypy passing, and revert annotations of _plot in a few places because mypy complained about signature mismatch.

jbrockmendel and others added 30 commits August 20, 2020 21:19
@simonjayhawkins simonjayhawkins added the Typing type annotations, mypy/pyright type checking label Sep 1, 2020
@@ -150,7 +154,7 @@ def _make_plot(self):
labels = [pprint_thing(key) for key in range(len(labels))]
self._set_ticklabels(ax, labels)

def _set_ticklabels(self, ax, labels):
def _set_ticklabels(self, ax: "Axes", labels):
Copy link
Member

Choose a reason for hiding this comment

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

I've opened #36034 so that when reviewing we can just click on and get definition as doesn't work for string literals (in VS Code anyway)

@@ -667,10 +665,10 @@ def _plot(cls, ax, x, y, style=None, is_errorbar=False, **kwds):
if style is not None:
args = (x, y, style)
else:
args = (x, y)
args = (x, y) # type:ignore
Copy link
Member

Choose a reason for hiding this comment

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

if adding ignores can you add the mypy error code and the mypy error message as a comment.

In this case, it's a relative simple cleanup. add a variable type declaration for args?

@@ -916,15 +914,15 @@ def __init__(self, data, x, y, **kwargs):
self.y = y

@property
def nseries(self):
def nseries(self) -> int:
Copy link
Member

Choose a reason for hiding this comment

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

possibly a use of Literal after vendoring PR merged

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 @jbrockmendel lgtm except 'bare' #type: ignore

@simonjayhawkins simonjayhawkins added this to the 1.2 milestone Sep 1, 2020
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 @jbrockmendel lgtm pending green

@WillAyd
Copy link
Member

WillAyd commented Sep 1, 2020

/azp run

@azure-pipelines
Copy link
Contributor

Azure Pipelines successfully started running 1 pipeline(s).

@WillAyd
Copy link
Member

WillAyd commented Sep 1, 2020

yea also lgtm test failures seems unrelated so restarted. merge on green

@simonjayhawkins simonjayhawkins merged commit 6c3c695 into pandas-dev:master Sep 1, 2020
@simonjayhawkins
Copy link
Member

Thanks @jbrockmendel

@jbrockmendel jbrockmendel deleted the annotate-plotting-stacker branch September 1, 2020 17:41
kesmit13 pushed a commit to kesmit13/pandas that referenced this pull request Nov 2, 2020
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