Skip to content

Commit d7d723d

Browse files
hovaescohashhar
authored andcommitted
Remove normalize method from TemporalType
This code has been dead/broken since 2b9ca0c
1 parent 505989a commit d7d723d

File tree

1 file changed

+0
-21
lines changed

1 file changed

+0
-21
lines changed

trino/types.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
from decimal import Decimal
66
from typing import Any, Dict, Generic, List, Optional, Tuple, TypeVar, Union, cast
77

8-
from dateutil import tz
9-
108
PythonTemporalType = TypeVar("PythonTemporalType", bound=Union[time, datetime])
119
POWERS_OF_TEN: Dict[int, Decimal] = {i: Decimal(10**i) for i in range(0, 13)}
1210
MAX_PYTHON_TEMPORAL_PRECISION_POWER = 6
@@ -39,11 +37,6 @@ def round_to(self, precision: int) -> TemporalType[PythonTemporalType]:
3937
if digits > precision:
4038
rounding_factor = POWERS_OF_TEN[precision]
4139
rounded = remaining_fractional_seconds.quantize(Decimal(1 / rounding_factor))
42-
if rounded == rounding_factor:
43-
return self.new_instance(
44-
self.normalize(self.add_time_delta(timedelta(seconds=1))),
45-
Decimal(0)
46-
)
4740
return self.new_instance(self._whole_python_temporal_value, rounded)
4841
return self
4942

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

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

6551
class Time(TemporalType[time]):
6652
def new_instance(self, value: time, fraction: Decimal) -> TemporalType[time]:
@@ -100,13 +86,6 @@ class TimestampWithTimeZone(Timestamp, TemporalType[datetime]):
10086
def new_instance(self, value: datetime, fraction: Decimal) -> TimestampWithTimeZone:
10187
return TimestampWithTimeZone(value, fraction)
10288

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

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

0 commit comments

Comments
 (0)