Skip to content

TST, TYP: _use_dynamic_x #34487

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
12 changes: 7 additions & 5 deletions pandas/plotting/_matplotlib/timeseries.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# TODO: Use the fact that axis can have units to simplify the process

import functools
from typing import Optional
from typing import TYPE_CHECKING, Optional

import numpy as np

Expand All @@ -24,6 +24,10 @@
from pandas.tseries.frequencies import is_subperiod, is_superperiod
from pandas.tseries.offsets import DateOffset

if TYPE_CHECKING:
from pandas._typing import FrameOrSeries # noqa: F401


# ---------------------------------------------------------------------
# Plotting functions and monkey patches

Expand Down Expand Up @@ -188,7 +192,8 @@ def _get_freq(ax, series):
return freq, ax_freq


def _use_dynamic_x(ax, data):
def _use_dynamic_x(ax, data: "FrameOrSeries") -> bool:

freq = _get_index_freq(data)
ax_freq = _get_ax_freq(ax)

Expand All @@ -203,9 +208,6 @@ def _use_dynamic_x(ax, data):

freq = get_period_alias(freq)

if freq is None:
return False

# FIXME: hack this for 0.10.1, creating more technical debt...sigh
if isinstance(data.index, ABCDatetimeIndex):
base = get_freq_code(freq)[0]
Expand Down