Fix add_vline and add_hline with datetime axes by mosh3eb · Pull Request #5508 · plotly/plotly.py

@mosh3eb

Instead of assuming input values are equal, _mean() now converts
datetime-like values (date strings and datetime objects) to
milliseconds-since-epoch, computes the actual arithmetic mean, and
converts back. This correctly handles annotation placement for ALL
shapes (vlines, hlines, vrects, hrects) with datetime axes.

The numeric fast path is unchanged — datetime handling only activates
when sum() raises TypeError on non-numeric types.

Added tests for datetime strings, datetime objects, and rects with
different x0/x1 values on datetime axes.

Fixes plotly#3065