diff --git a/CHANGELOG.md b/CHANGELOG.md index d02f0609..898fa82e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Latest +## What's Changed +* :bug: drop the unused `pytz` import, so `import plotly_resampler` works with pandas>=3 without `pytz` (#365) by @hdh7485 in https://github.com/predict-idlab/plotly-resampler/pull/366 + # v0.10.0 ## New Features diff --git a/plotly_resampler/aggregation/plotly_aggregator_parser.py b/plotly_resampler/aggregation/plotly_aggregator_parser.py index 74f4dc8b..982725eb 100644 --- a/plotly_resampler/aggregation/plotly_aggregator_parser.py +++ b/plotly_resampler/aggregation/plotly_aggregator_parser.py @@ -1,11 +1,11 @@ from __future__ import annotations import bisect +from datetime import tzinfo from typing import Tuple, Union import numpy as np import pandas as pd -import pytz from .aggregation_interface import DataAggregator, DataPointSelector from .gap_handler_interface import AbstractGapHandler @@ -31,7 +31,7 @@ def parse_hf_data( @staticmethod def to_same_tz( - ts: Union[pd.Timestamp, None], reference_tz: Union[pytz.BaseTzInfo, None] + ts: Union[pd.Timestamp, None], reference_tz: Union[tzinfo, None] ) -> Union[pd.Timestamp, None]: """Adjust `ts` its timezone to the `reference_tz`.""" if ts is None: diff --git a/tests/test_utils.py b/tests/test_utils.py index f1abd530..b6900c65 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -1,3 +1,6 @@ +import subprocess +import sys + import pandas as pd import plotly.graph_objects as go import pytest @@ -137,3 +140,9 @@ def test_round_int_str(): # negative case assert round_number_str(-0.951) == "-1" assert round_number_str(-0.95) == "-0.9" + + +def test_import_without_pytz(): + # pandas>=3 no longer depends on pytz, so we must not import it (#365) + code = "import sys, pandas; sys.modules['pytz'] = None; import plotly_resampler" + subprocess.run([sys.executable, "-c", code], check=True)