You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a well known and actually very tricky corner of type hinting matplotlib...
I am going to close this as a duplicate of #25676, where there is a significant amount of conversation on the subject and the reasons we chose to type hint the way we did/ideas for improvements. Feel free to add info there.
The short version is that units (including datetimes) are runtime-configurable dynamic behavior that simply can't be properly checked by static type checkers. (We can certainly do better, but we really will never be able to capture the full gamut of things without some additional info)
Bug summary
list of datetime passed to ax.plot results in a mypy error. The same error has been seen in ax.errorbar.
Code for reproduction
Actual outcome
Argument 1 to "plot" of "Axes" has incompatible type "list[datetime]"; expected "Union[float, Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]], str]" [arg-type]
Expected outcome
no mypy errors
Additional information
No response
Operating system
Windows 11
Matplotlib Version
3.8.0
Matplotlib Backend
TkAgg
Python version
Python 3.9.13
Jupyter version
NA
Installation
pip
The text was updated successfully, but these errors were encountered: