5
5
from decimal import Decimal
6
6
from typing import Any , Dict , Generic , List , Optional , Tuple , TypeVar , Union , cast
7
7
8
- from dateutil import tz
9
-
10
8
PythonTemporalType = TypeVar ("PythonTemporalType" , bound = Union [time , datetime ])
11
9
POWERS_OF_TEN : Dict [int , Decimal ] = {i : Decimal (10 ** i ) for i in range (0 , 13 )}
12
10
MAX_PYTHON_TEMPORAL_PRECISION_POWER = 6
@@ -39,11 +37,6 @@ def round_to(self, precision: int) -> TemporalType[PythonTemporalType]:
39
37
if digits > precision :
40
38
rounding_factor = POWERS_OF_TEN [precision ]
41
39
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
- )
47
40
return self .new_instance (self ._whole_python_temporal_value , rounded )
48
41
return self
49
42
@@ -54,13 +47,6 @@ def add_time_delta(self, time_delta: timedelta) -> PythonTemporalType:
54
47
"""
55
48
pass
56
49
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
-
64
50
65
51
class Time (TemporalType [time ]):
66
52
def new_instance (self , value : time , fraction : Decimal ) -> TemporalType [time ]:
@@ -100,13 +86,6 @@ class TimestampWithTimeZone(Timestamp, TemporalType[datetime]):
100
86
def new_instance (self , value : datetime , fraction : Decimal ) -> TimestampWithTimeZone :
101
87
return TimestampWithTimeZone (value , fraction )
102
88
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
-
110
89
111
90
class NamedRowTuple (Tuple [Any , ...]):
112
91
"""Custom tuple class as namedtuple doesn't support missing or duplicate names"""
0 commit comments