Skip to content

Commit

Permalink
fix python 3.8 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
atimin committed Mar 6, 2024
1 parent 95ce8b8 commit 06ea18f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
10 changes: 5 additions & 5 deletions reduct/bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ async def remove_entry(self, entry_name: str):
async def read(
self,
entry_name: str,
timestamp: Optional[int | datetime | float | str] = None,
timestamp: Optional[Union[int, datetime, float, str]] = None,
head: bool = False,
) -> Record:
"""
Expand Down Expand Up @@ -209,7 +209,7 @@ async def write(
self,
entry_name: str,
data: Union[bytes, AsyncIterator[bytes]],
timestamp: Optional[int | datetime | float | str] = None,
timestamp: Optional[Union[int, datetime, float, str]] = None,
content_length: Optional[int] = None,
**kwargs,
):
Expand Down Expand Up @@ -306,8 +306,8 @@ async def iter_body():
async def query(
self,
entry_name: str,
start: Optional[int | datetime | float | str] = None,
stop: Optional[int | datetime | float | str] = None,
start: Optional[Union[int, datetime, float, str]] = None,
stop: Optional[Union[int, datetime, float, str]] = None,
ttl: Optional[int] = None,
**kwargs,
) -> AsyncIterator[Record]:
Expand Down Expand Up @@ -375,7 +375,7 @@ async def get_full_info(self) -> BucketFullInfo:
async def subscribe(
self,
entry_name: str,
start: Optional[int | datetime | float | str] = None,
start: Optional[Union[int, datetime, float, str]] = None,
poll_interval=1.0,
**kwargs,
) -> AsyncIterator[Record]:
Expand Down
13 changes: 11 additions & 2 deletions reduct/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,16 @@
from dataclasses import dataclass
from datetime import datetime
from functools import partial
from typing import Dict, Callable, AsyncIterator, Awaitable, Optional, List, Tuple
from typing import (
Dict,
Callable,
AsyncIterator,
Awaitable,
Optional,
List,
Tuple,
Union,
)

from aiohttp import ClientResponse

Expand Down Expand Up @@ -47,7 +56,7 @@ def __init__(self):

def add(
self,
timestamp: int | datetime | float | str,
timestamp: Union[int, datetime, float, str],
data: bytes,
content_type: Optional[str] = None,
labels: Optional[Dict[str, str]] = None,
Expand Down
3 changes: 2 additions & 1 deletion reduct/time.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
"""Helper functions for time-related operations."""

from datetime import datetime
from typing import Union

TIME_PRECISION = 1_000_000


def unix_timestamp_from_any(timestamp: int | datetime | float | str) -> int:
def unix_timestamp_from_any(timestamp: Union[int, datetime, float, str]) -> int:
"""Convert timestamp to UNIX timestamp in microseconds
Args:
timestamp (int | datetime | float | str): int (UNIX timestamp in microseconds),
Expand Down

0 comments on commit 06ea18f

Please sign in to comment.