matplotlib/matplotlib · error · TypeError
Unexpected type passed to {self!r}.
Error message
Unexpected type passed to {self!r}. What it means
Error "Unexpected type passed to {self!r}." thrown in matplotlib/matplotlib.
Source
Thrown at lib/matplotlib/dates.py:938
self._locator = locator
def __call__(self, x, pos=None):
try:
locator_unit_scale = float(self._locator._get_unit())
except AttributeError:
locator_unit_scale = 1
# Pick the first scale which is greater than the locator unit.
fmt = next((fmt for scale, fmt in sorted(self.scaled.items())
if scale >= locator_unit_scale),
self.defaultfmt)
if isinstance(fmt, str):
self._formatter = DateFormatter(fmt, self._tz, usetex=self._usetex)
result = self._formatter(x, pos)
elif callable(fmt):
result = fmt(x, pos)
else:
raise TypeError(f'Unexpected type passed to {self!r}.')
return result
class rrulewrapper:
"""
A simple wrapper around a `dateutil.rrule` allowing flexible
date tick specifications.
"""
def __init__(self, freq, tzinfo=None, **kwargs):
"""
Parameters
----------
freq : {YEARLY, MONTHLY, WEEKLY, DAILY, HOURLY, MINUTELY, SECONDLY}
Tick frequency. These constants are defined in `dateutil.rrule`,
but they are accessible from `matplotlib.dates` as well.
tzinfo : `datetime.tzinfo`, optional
Time zone information. The default is None.View on GitHub (pinned to b379c1b69e)
When it happens
Trigger: Thrown at lib/matplotlib/dates.py:938 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of matplotlib/matplotlib@b379c1b69e (2026-08-21).
Data as JSON: /api/errors/4537e6be14bdb829.
Report an issue: GitHub.