Skip to content

Commit

Permalink
Remove normalize method from TemporalType
Browse files Browse the repository at this point in the history
  • Loading branch information
hovaesco committed Jul 16, 2024
1 parent 169226e commit 332c1dc
Showing 1 changed file with 0 additions and 21 deletions.
21 changes: 0 additions & 21 deletions trino/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
from decimal import Decimal
from typing import Any, Dict, Generic, List, Optional, Tuple, TypeVar, Union, cast

from dateutil import tz

PythonTemporalType = TypeVar("PythonTemporalType", bound=Union[time, datetime])
POWERS_OF_TEN: Dict[int, Decimal] = {i: Decimal(10**i) for i in range(0, 13)}
MAX_PYTHON_TEMPORAL_PRECISION_POWER = 6
Expand Down Expand Up @@ -39,11 +37,6 @@ def round_to(self, precision: int) -> TemporalType[PythonTemporalType]:
if digits > precision:
rounding_factor = POWERS_OF_TEN[precision]
rounded = remaining_fractional_seconds.quantize(Decimal(1 / rounding_factor))
if rounded == rounding_factor:
return self.new_instance(
self.normalize(self.add_time_delta(timedelta(seconds=1))),
Decimal(0)
)
return self.new_instance(self._whole_python_temporal_value, rounded)
return self

Expand All @@ -54,13 +47,6 @@ def add_time_delta(self, time_delta: timedelta) -> PythonTemporalType:
"""
pass

def normalize(self, value: PythonTemporalType) -> PythonTemporalType:
"""
If `add_time_delta` results in value crossing DST boundaries, this method should
return a normalized version of the value to account for it.
"""
return value


class Time(TemporalType[time]):
def new_instance(self, value: time, fraction: Decimal) -> TemporalType[time]:
Expand Down Expand Up @@ -100,13 +86,6 @@ class TimestampWithTimeZone(Timestamp, TemporalType[datetime]):
def new_instance(self, value: datetime, fraction: Decimal) -> TimestampWithTimeZone:
return TimestampWithTimeZone(value, fraction)

def normalize(self, value: datetime) -> datetime:
if tz.datetime_ambiguous(value):
# This appears to be dead code since tzinfo doesn't actually have a `normalize` method.
# TODO: Fix this or remove. (https://github.com/trinodb/trino-python-client/issues/449)
return self._whole_python_temporal_value.tzinfo.normalize(value) # type: ignore
return value


class NamedRowTuple(Tuple[Any, ...]):
"""Custom tuple class as namedtuple doesn't support missing or duplicate names"""
Expand Down

0 comments on commit 332c1dc

Please sign in to comment.