7
7
from datetime import date , datetime , time , timedelta , timezone , tzinfo
8
8
from functools import lru_cache
9
9
import re
10
- from typing import Any
11
10
12
11
from ._types import ParseFloat
13
12
49
48
)
50
49
51
50
52
- def match_to_datetime (match : re . Match ) -> datetime | date :
51
+ def match_to_datetime (match ) :
53
52
"""Convert a `RE_DATETIME` match to `datetime.datetime` or `datetime.date`.
54
53
55
54
Raises ValueError if the match does not correspond to a valid date
@@ -85,7 +84,7 @@ def match_to_datetime(match: re.Match) -> datetime | date:
85
84
86
85
87
86
@lru_cache (maxsize = None )
88
- def cached_tz (hour_str : str , minute_str : str , sign_str : str ) -> timezone :
87
+ def cached_tz (hour_str , minute_str , sign_str ) :
89
88
sign = 1 if sign_str == "+" else - 1
90
89
return timezone (
91
90
timedelta (
@@ -95,13 +94,13 @@ def cached_tz(hour_str: str, minute_str: str, sign_str: str) -> timezone:
95
94
)
96
95
97
96
98
- def match_to_localtime (match : re . Match ) -> time :
97
+ def match_to_localtime (match ) :
99
98
hour_str , minute_str , sec_str , micros_str = match .groups ()
100
99
micros = int (micros_str .ljust (6 , "0" )) if micros_str else 0
101
100
return time (int (hour_str ), int (minute_str ), int (sec_str ), micros )
102
101
103
102
104
- def match_to_number (match : re . Match , parse_float : ParseFloat ) -> Any :
103
+ def match_to_number (match , parse_float ) :
105
104
if match .group ("floatpart" ):
106
105
return parse_float (match .group ())
107
106
return int (match .group (), 0 )
0 commit comments