Skip to content

Commit c2737c7

Browse files
committed
Fix typing for substract params
1 parent 41dfe7c commit c2737c7

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

infrahub_sdk/timestamp.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import re
44
import warnings
55
from datetime import datetime, timezone
6-
from typing import Literal
6+
from typing import Literal, NotRequired, TypedDict
77

88
from whenever import Date, Instant, LocalDateTime, OffsetDateTime, Time, ZonedDateTime
99

@@ -18,6 +18,12 @@
1818
}
1919

2020

21+
class SubstractParams(TypedDict):
22+
seconds: NotRequired[int]
23+
minutes: NotRequired[int]
24+
hours: NotRequired[int]
25+
26+
2127
class Timestamp:
2228
_obj: ZonedDateTime
2329

@@ -73,14 +79,14 @@ def _parse_string(cls, value: str) -> ZonedDateTime:
7379
except ValueError:
7480
pass
7581

76-
params: dict[str, float] = {}
82+
params: SubstractParams = {}
7783
for key, regex in REGEX_MAPPING.items():
7884
match = re.search(regex, value)
7985
if match:
8086
params[key] = float(match.group(1))
8187

8288
if params:
83-
return ZonedDateTime.now("UTC").subtract(**params) # type: ignore[call-overload]
89+
return ZonedDateTime.now("UTC").subtract(**params)
8490

8591
raise TimestampFormatError(f"Invalid time format for {value}")
8692

0 commit comments

Comments
 (0)