From 837b0efdeaeaa4103d297c013df4df697c7fb77f Mon Sep 17 00:00:00 2001 From: Nikita Reznikov Date: Mon, 27 May 2024 20:30:32 +0300 Subject: [PATCH] Update tz info type hints --- eventum_plugins/input/base.py | 4 ++-- eventum_plugins/input/cron.py | 4 ++-- eventum_plugins/input/linspace.py | 4 ++-- eventum_plugins/input/sample.py | 4 ++-- eventum_plugins/input/time_patterns.py | 10 +++++++--- eventum_plugins/input/timer.py | 4 ++-- eventum_plugins/input/timestamps.py | 4 ++-- eventum_plugins/utils/numpy_time.py | 4 ++-- 8 files changed, 21 insertions(+), 17 deletions(-) diff --git a/eventum_plugins/input/base.py b/eventum_plugins/input/base.py index 1172506..4ae0775 100644 --- a/eventum_plugins/input/base.py +++ b/eventum_plugins/input/base.py @@ -3,7 +3,7 @@ from numpy import datetime64 from pydantic import BaseModel -from pytz.tzinfo import DstTzInfo +from pytz.tzinfo import BaseTzInfo class InputPluginError(Exception): @@ -32,7 +32,7 @@ class BaseInputPlugin(ABC): """Base class for all input plugins.""" @abstractmethod - def __init__(self, config: Any, tz: DstTzInfo) -> None: + def __init__(self, config: Any, tz: BaseTzInfo) -> None: ... diff --git a/eventum_plugins/input/cron.py b/eventum_plugins/input/cron.py index 6fd1bd5..b4be963 100644 --- a/eventum_plugins/input/cron.py +++ b/eventum_plugins/input/cron.py @@ -5,7 +5,7 @@ from croniter import croniter from numpy import datetime64 from pydantic import Field, field_validator -from pytz.tzinfo import DstTzInfo +from pytz.tzinfo import BaseTzInfo from eventum_plugins.input.base import InputPluginBaseConfig, LiveInputPlugin @@ -26,7 +26,7 @@ class CronInputPlugin(LiveInputPlugin): expression. """ - def __init__(self, config: CronInputConfig, tz: DstTzInfo) -> None: + def __init__(self, config: CronInputConfig, tz: BaseTzInfo) -> None: self._expression = config.expression self._count = config.count self._tz = tz diff --git a/eventum_plugins/input/linspace.py b/eventum_plugins/input/linspace.py index 465c4d5..276d9a8 100644 --- a/eventum_plugins/input/linspace.py +++ b/eventum_plugins/input/linspace.py @@ -3,7 +3,7 @@ from numpy import datetime64, linspace, timedelta64 from pydantic import Field, model_validator -from pytz.tzinfo import DstTzInfo +from pytz.tzinfo import BaseTzInfo from eventum_plugins.input.base import InputPluginBaseConfig, SampleInputPlugin @@ -26,7 +26,7 @@ class LinspaceInputPlugin(SampleInputPlugin): spaced in time. """ - def __init__(self, config: LinspaceInputConfig, tz: DstTzInfo) -> None: + def __init__(self, config: LinspaceInputConfig, tz: BaseTzInfo) -> None: self._start = config.start self._end = config.end self._count = config.count diff --git a/eventum_plugins/input/sample.py b/eventum_plugins/input/sample.py index b0f1688..ac918b3 100644 --- a/eventum_plugins/input/sample.py +++ b/eventum_plugins/input/sample.py @@ -2,7 +2,7 @@ from numpy import datetime64 from pydantic import Field -from pytz.tzinfo import DstTzInfo +from pytz.tzinfo import BaseTzInfo from eventum_plugins.input.base import InputPluginBaseConfig from eventum_plugins.input.base import \ @@ -21,7 +21,7 @@ class SampleInputPlugin(BaseSampleInputPlugin): of time when sample generating process was started. """ - def __init__(self, config: SampleInputConfig, tz: DstTzInfo) -> None: + def __init__(self, config: SampleInputConfig, tz: BaseTzInfo) -> None: self._count = config.count self._tz = tz diff --git a/eventum_plugins/input/time_patterns.py b/eventum_plugins/input/time_patterns.py index a769593..91d1c2c 100644 --- a/eventum_plugins/input/time_patterns.py +++ b/eventum_plugins/input/time_patterns.py @@ -12,7 +12,7 @@ load_time_pattern) from numpy.typing import NDArray from pydantic import AfterValidator, Field, ValidationError, model_validator -from pytz.tzinfo import DstTzInfo +from pytz.tzinfo import BaseTzInfo from eventum_plugins.input.base import (InputPluginBaseConfig, InputPluginConfigurationError, @@ -167,7 +167,7 @@ class EndTimeReaching(Exception): _REQUIRED_EPS_RESERVE_RATIO = 1.15 PUBLISH_PRECISION_SECONDS = 0.01 - def __init__(self, config: TimePatternConfig, tz: DstTzInfo) -> None: + def __init__(self, config: TimePatternConfig, tz: BaseTzInfo) -> None: self._config = config self._tz = tz self._randomizer_factors = self._generate_randomizer_factors() @@ -463,7 +463,11 @@ class TimePatternPoolInputPlugin(LiveInputPlugin, SampleInputPlugin): plugins. """ - def __init__(self, config: TimePatternsInputConfig, tz: DstTzInfo) -> None: + def __init__( + self, + config: TimePatternsInputConfig, + tz: BaseTzInfo + ) -> None: self._tz = tz time_patterns: list[TimePatternInputPlugin] = [] diff --git a/eventum_plugins/input/timer.py b/eventum_plugins/input/timer.py index fe5626a..bd218db 100644 --- a/eventum_plugins/input/timer.py +++ b/eventum_plugins/input/timer.py @@ -3,7 +3,7 @@ from numpy import datetime64, timedelta64 from pydantic import Field -from pytz.tzinfo import DstTzInfo +from pytz.tzinfo import BaseTzInfo from eventum_plugins.input.base import InputPluginBaseConfig, LiveInputPlugin from eventum_plugins.utils.numpy_time import get_now, timedelta_to_seconds @@ -20,7 +20,7 @@ class TimerInputPlugin(LiveInputPlugin): seconds. """ - def __init__(self, config: TimerInputConfig, tz: DstTzInfo) -> None: + def __init__(self, config: TimerInputConfig, tz: BaseTzInfo) -> None: self._seconds = config.seconds self._count = config.count self._repeat = config.repeat diff --git a/eventum_plugins/input/timestamps.py b/eventum_plugins/input/timestamps.py index 20f0194..128192a 100644 --- a/eventum_plugins/input/timestamps.py +++ b/eventum_plugins/input/timestamps.py @@ -5,7 +5,7 @@ from numpy import array, datetime64 from numpy.typing import NDArray from pydantic import Field -from pytz.tzinfo import DstTzInfo +from pytz.tzinfo import BaseTzInfo from eventum_plugins.input.base import (InputPluginBaseConfig, LiveInputPlugin, SampleInputPlugin) @@ -20,7 +20,7 @@ class TimestampsInputConfig(InputPluginBaseConfig, frozen=True): class TimestampsInputPlugin(LiveInputPlugin, SampleInputPlugin): """Input plugin for generating events in specified timestamps.""" - def __init__(self, config: TimestampsInputConfig, tz: DstTzInfo) -> None: + def __init__(self, config: TimestampsInputConfig, tz: BaseTzInfo) -> None: self._timestamps: NDArray[datetime64] = array( [ ts.astimezone(tz=tz).replace(tzinfo=None) diff --git a/eventum_plugins/utils/numpy_time.py b/eventum_plugins/utils/numpy_time.py index d3b3a85..de9fd24 100644 --- a/eventum_plugins/utils/numpy_time.py +++ b/eventum_plugins/utils/numpy_time.py @@ -1,10 +1,10 @@ from datetime import datetime from numpy import datetime64, float64, timedelta64 -from pytz.tzinfo import DstTzInfo +from pytz.tzinfo import BaseTzInfo -def get_now(tz: DstTzInfo) -> datetime64: +def get_now(tz: BaseTzInfo) -> datetime64: """Get current time in UTC timezone.""" return datetime64(datetime.now(tz).replace(tzinfo=None))