Skip to content

Commit

Permalink
Fix types in holders
Browse files Browse the repository at this point in the history
  • Loading branch information
bonjourmauko committed Dec 19, 2022
1 parent a9e41a6 commit 9ee7eea
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions openfisca_core/holders/holder.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def get_memory_usage(self) -> MemoryUsage:
>>> entity = entities.Entity("", "", "", "")
>>> class MyVariable(variables.Variable):
... definition_period = "year"
... definition_period = periods.DateUnit.YEAR
... entity = entity
... value_type = int
Expand Down Expand Up @@ -188,7 +188,7 @@ def set_input(
>>> entity = entities.Entity("", "", "", "")
>>> class MyVariable(variables.Variable):
... definition_period = "year"
... definition_period = periods.DateUnit.YEAR
... entity = entity
... value_type = int
Expand Down
Empty file.
4 changes: 3 additions & 1 deletion openfisca_core/periods/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,9 @@ def _raise_error(value: str) -> NoReturn:
Examples:
>>> _raise_error("Oi mate!")
Traceback (most recent call last):
ValueError: Expected a period (eg. '2017', ...); got: 'Oi mate!'.
ValueError: Expected a period (eg. '2017', '2017-01', '2017-01-01', ...
Learn more about legal period formats in OpenFisca:
<https://openfisca.org/doc/coding-the-legislation/35_periods.html#pe...
"""

Expand Down
2 changes: 1 addition & 1 deletion openfisca_core/periods/period_.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def date(self) -> "Date":
>>> period = Period((DateUnit.YEAR, instant, 3))
>>> period.date
Traceback (most recent call last):
ValueError: "date" is undefined for a period of size > 1: year:2021-09:3.
ValueError: "date" is undefined for a period of size > 1: year:2021-10:3.
"""

Expand Down
2 changes: 1 addition & 1 deletion openfisca_core/taxbenefitsystems/tax_benefit_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ def get_parameters_at_instant(
"""

key: Instant
key: Optional[Instant]
msg: str

if isinstance(instant, Instant):
Expand Down
5 changes: 5 additions & 0 deletions openfisca_core/variables/variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,8 @@ def get_formula(
"""

instant: Optional[Instant]

if not self.formulas:
return None

Expand All @@ -340,6 +342,9 @@ def get_formula(
except ValueError:
instant = periods.instant(period)

if instant is None:
return None

if self.end and instant.date > self.end:
return None

Expand Down

0 comments on commit 9ee7eea

Please sign in to comment.