Skip to content

Commit 29732a0

Browse files
Type change_value and time_object_info as int | float
A decimal value makes change_value a float, but its type was inferred from the int-only branch above and time_object_info was built with dict.fromkeys(..., 0), so mypy rejected both assignments.
1 parent 48ef7d5 commit 29732a0

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎arrow/arrow.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from typing import (
1818
Any,
1919
ClassVar,
20+
Dict,
2021
Final,
2122
Generator,
2223
Iterable,
@@ -1384,7 +1385,8 @@ def dehumanize(self, input_string: str, locale: str = "en_us") -> "Arrow":
13841385
current_time = self.fromdatetime(self._datetime)
13851386

13861387
# Create an object containing the relative time info
1387-
time_object_info = dict.fromkeys(
1388+
# float as well as int: a value may carry a decimal fraction
1389+
time_object_info: Dict[str, Union[int, float]] = dict.fromkeys(
13881390
["seconds", "minutes", "hours", "days", "weeks", "months", "years"], 0
13891391
)
13901392

@@ -1431,6 +1433,7 @@ def dehumanize(self, input_string: str, locale: str = "en_us") -> "Arrow":
14311433

14321434
# If no number matches
14331435
# Need for absolute value as some locales have signs included in their objects
1436+
change_value: Union[int, float]
14341437
if not num_match:
14351438
change_value = (
14361439
1 if not time_delta.isnumeric() else abs(int(time_delta))

0 commit comments

Comments
 (0)