diff --git a/openfisca_core/periods/period_.py b/openfisca_core/periods/period_.py index a55d6635b..87e8465d3 100644 --- a/openfisca_core/periods/period_.py +++ b/openfisca_core/periods/period_.py @@ -117,6 +117,8 @@ class Period(tuple[t.DateUnit, t.Instant, int]): """ + __slots__ = () + def __repr__(self) -> str: return f"{self.__class__.__name__}({super().__repr__()})" @@ -466,11 +468,11 @@ def get_subperiods(self, unit: t.DateUnit) -> Sequence[t.Period]: Examples: >>> period = Period((DateUnit.YEAR, Instant((2021, 1, 1)), 1)) >>> period.get_subperiods(DateUnit.MONTH) - [Period((, Instant((2021, 1, 1)), 1)),...2021, 12, 1)), 1))] + [Period((, Instant((2021, 1, 1)), 1)),...] >>> period = Period((DateUnit.YEAR, Instant((2021, 1, 1)), 2)) >>> period.get_subperiods(DateUnit.YEAR) - [Period((, Instant((2021, 1, 1)), 1)),...((2022, 1, 1)), 1))] + [Period((, Instant((2021, 1, 1)), 1)), P...] """ if helpers.unit_weight(self.unit) < helpers.unit_weight(unit): @@ -513,19 +515,27 @@ def offset(self, offset: str | int, unit: t.DateUnit | None = None) -> t.Period: >>> Period((DateUnit.DAY, Instant((2021, 1, 1)), 365)).offset(1) Period((, Instant((2021, 1, 2)), 365)) - >>> Period((DateUnit.DAY, Instant((2021, 1, 1)), 365)).offset(1, DateUnit.DAY) + >>> Period((DateUnit.DAY, Instant((2021, 1, 1)), 365)).offset( + ... 1, DateUnit.DAY + ... ) Period((, Instant((2021, 1, 2)), 365)) - >>> Period((DateUnit.DAY, Instant((2021, 1, 1)), 365)).offset(1, DateUnit.MONTH) + >>> Period((DateUnit.DAY, Instant((2021, 1, 1)), 365)).offset( + ... 1, DateUnit.MONTH + ... ) Period((, Instant((2021, 2, 1)), 365)) - >>> Period((DateUnit.DAY, Instant((2021, 1, 1)), 365)).offset(1, DateUnit.YEAR) + >>> Period((DateUnit.DAY, Instant((2021, 1, 1)), 365)).offset( + ... 1, DateUnit.YEAR + ... ) Period((, Instant((2022, 1, 1)), 365)) >>> Period((DateUnit.MONTH, Instant((2021, 1, 1)), 12)).offset(1) Period((, Instant((2021, 2, 1)), 12)) - >>> Period((DateUnit.MONTH, Instant((2021, 1, 1)), 12)).offset(1, DateUnit.DAY) + >>> Period((DateUnit.MONTH, Instant((2021, 1, 1)), 12)).offset( + ... 1, DateUnit.DAY + ... ) Period((, Instant((2021, 1, 2)), 12)) >>> Period((DateUnit.MONTH, Instant((2021, 1, 1)), 12)).offset( @@ -533,19 +543,27 @@ def offset(self, offset: str | int, unit: t.DateUnit | None = None) -> t.Period: ... ) Period((, Instant((2021, 2, 1)), 12)) - >>> Period((DateUnit.MONTH, Instant((2021, 1, 1)), 12)).offset(1, DateUnit.YEAR) + >>> Period((DateUnit.MONTH, Instant((2021, 1, 1)), 12)).offset( + ... 1, DateUnit.YEAR + ... ) Period((, Instant((2022, 1, 1)), 12)) >>> Period((DateUnit.YEAR, Instant((2021, 1, 1)), 1)).offset(1) Period((, Instant((2022, 1, 1)), 1)) - >>> Period((DateUnit.YEAR, Instant((2021, 1, 1)), 1)).offset(1, DateUnit.DAY) + >>> Period((DateUnit.YEAR, Instant((2021, 1, 1)), 1)).offset( + ... 1, DateUnit.DAY + ... ) Period((, Instant((2021, 1, 2)), 1)) - >>> Period((DateUnit.YEAR, Instant((2021, 1, 1)), 1)).offset(1, DateUnit.MONTH) + >>> Period((DateUnit.YEAR, Instant((2021, 1, 1)), 1)).offset( + ... 1, DateUnit.MONTH + ... ) Period((, Instant((2021, 2, 1)), 1)) - >>> Period((DateUnit.YEAR, Instant((2021, 1, 1)), 1)).offset(1, DateUnit.YEAR) + >>> Period((DateUnit.YEAR, Instant((2021, 1, 1)), 1)).offset( + ... 1, DateUnit.YEAR + ... ) Period((, Instant((2022, 1, 1)), 1)) >>> Period((DateUnit.DAY, Instant((2011, 2, 28)), 1)).offset(1)