Skip to content

Commit

Permalink
Cleanup leftovers & typos
Browse files Browse the repository at this point in the history
  • Loading branch information
bonjourmauko committed Aug 2, 2022
1 parent 44c7bba commit 80c4880
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions openfisca_core/periods/helpers.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import datetime
import os
from typing import Dict, NoReturn, Optional
Expand All @@ -11,7 +13,7 @@ def N_(message):
return message


def instant(instant) -> Optional[Instant]:
def instant(instant) -> Optional["Instant"]:
"""Build a new instant, aka a triple of integers (year, month, day).
Args:
Expand All @@ -22,7 +24,7 @@ def instant(instant) -> Optional[Instant]:
:obj:`.Instant`: Otherwise.
Raises:
:exc:`ValueError`: When the arguments were invalid, like "2021-32-13".
ValueError: When the arguments were invalid, like "2021-32-13".
Examples:
>>> instant(datetime.date(2021, 9, 16))
Expand Down Expand Up @@ -75,15 +77,16 @@ def instant(instant) -> Optional[Instant]:
return Instant(instant)


def instant_date(instant: Optional[Instant]) -> Optional[datetime.date]:
"""Returns the date representation of an :class:`.Instant`.
def instant_date(instant: Optional["Instant"]) -> Optional["datetime.date"]:
"""Returns the date representation of an ``Instant``.
Args:
instant (:obj:`.Instant`, optional):
An ``instant`` to get the date from.
Returns:
None: When ``instant`` is None.
:obj:`datetime.date`: Otherwise.
datetime.date: Otherwise.
Examples:
>>> instant_date(Instant((2021, 1, 1)))
Expand All @@ -99,7 +102,7 @@ def instant_date(instant: Optional[Instant]) -> Optional[datetime.date]:
return instant_date


def period(value) -> Period:
def period(value) -> "Period":
"""Build a new period, aka a triple (unit, start_instant, size).
Args:
Expand Down Expand Up @@ -200,7 +203,7 @@ def period(value) -> Period:
return Period((unit, base_period.start, size))


def _parse_simple_period(value: str) -> Optional[Period]:
def _parse_simple_period(value: str) -> Optional["Period"]:
"""Parse simple periods respecting the ISO format.
Such as "2012" or "2015-03".
Expand Down Expand Up @@ -253,7 +256,7 @@ def _raise_error(value: str) -> NoReturn:
raise ValueError(message)


def key_period_size(period: Period) -> str:
def key_period_size(period: "Period") -> str:
"""Define a key in order to sort periods by length.
It uses two aspects: first, ``unit``, then, ``size``.
Expand Down

0 comments on commit 80c4880

Please sign in to comment.