Skip to content

#26020 Fixed type annotations for pandas.plotting._core #26021

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
merged 3 commits into from
Apr 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,6 @@ ignore_errors=True
[mypy-pandas.io.stata]
ignore_errors=True

[mypy-pandas.plotting._core]
ignore_errors=True

[mypy-pandas.util._doctools]
ignore_errors=True

Expand Down
6 changes: 4 additions & 2 deletions pandas/plotting/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# pylint: disable=E1101
from collections import namedtuple
import re
from typing import List, Optional, Type
import warnings

import numpy as np
Expand Down Expand Up @@ -78,7 +79,7 @@ def _kind(self):

_layout_type = 'vertical'
_default_rot = 0
orientation = None
orientation = None # type: Optional[str]
_pop_attributes = ['label', 'style', 'logy', 'logx', 'loglog',
'mark_right', 'stacked']
_attr_defaults = {'logy': False, 'logx': False, 'loglog': False,
Expand Down Expand Up @@ -1723,7 +1724,8 @@ def result(self):
_all_kinds = _common_kinds + _dataframe_kinds + _series_kinds

_klasses = [LinePlot, BarPlot, BarhPlot, KdePlot, HistPlot, BoxPlot,
ScatterPlot, HexBinPlot, AreaPlot, PiePlot]
ScatterPlot, HexBinPlot, AreaPlot, PiePlot] \
# type: List[Type[MPLPlot]]
Copy link
Member

Choose a reason for hiding this comment

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

Should just be List[MPLPlot] I think - does that give you some kind of error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, _klasses contains the classes/types themselves, not instances of those types, so using List[MPLPlot] errors out with lines like error: List item 0 has incompatible type "Type[LinePlot]"; expected "MPLPlot".


_plot_klass = {klass._kind: klass for klass in _klasses}

Expand Down