Skip to content

Commit

Permalink
Update tz info type hints
Browse files Browse the repository at this point in the history
  • Loading branch information
rnv812 committed May 27, 2024
1 parent 6c776cf commit 837b0ef
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 17 deletions.
4 changes: 2 additions & 2 deletions eventum_plugins/input/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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:
...


Expand Down
4 changes: 2 additions & 2 deletions eventum_plugins/input/cron.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions eventum_plugins/input/linspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions eventum_plugins/input/sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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

Expand Down
10 changes: 7 additions & 3 deletions eventum_plugins/input/time_patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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] = []

Expand Down
4 changes: 2 additions & 2 deletions eventum_plugins/input/timer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions eventum_plugins/input/timestamps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions eventum_plugins/utils/numpy_time.py
Original file line number Diff line number Diff line change
@@ -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))

Expand Down

0 comments on commit 837b0ef

Please sign in to comment.