From 80c488052b02d8c336a8d82978ba347687de3f59 Mon Sep 17 00:00:00 2001 From: Mauko Quiroga Date: Tue, 2 Aug 2022 12:48:57 +0200 Subject: [PATCH] Cleanup leftovers & typos --- openfisca_core/periods/helpers.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/openfisca_core/periods/helpers.py b/openfisca_core/periods/helpers.py index 43edaade5b..7e0d6a3cef 100644 --- a/openfisca_core/periods/helpers.py +++ b/openfisca_core/periods/helpers.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import datetime import os from typing import Dict, NoReturn, Optional @@ -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: @@ -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)) @@ -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))) @@ -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: @@ -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". @@ -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``.