Skip to content

Commit 864241f

Browse files
author
Mauko Quiroga
committed
Fix casting
1 parent b893dda commit 864241f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

openfisca_core/periods/instant_.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,10 @@ def period(self, unit: DateUnit, size: int = 1) -> Timeable:
199199
f"Invalid size: {size} of type {type(size)}. Expecting any " \
200200
"int >= 1."
201201

202-
return periods.period(f"{DateUnit[unit].value}:{str(self)}:{size}")
202+
if isinstance(unit, str):
203+
unit = DateUnit[unit]
204+
205+
return periods.period(f"{unit.value}:{str(self)}:{size}")
203206

204207
@functools.lru_cache(maxsize = None)
205208
def offset(self, offset: OffsetBy, unit: DateUnit) -> Instant:

0 commit comments

Comments
 (0)