Skip to content

Commit 26d25e9

Browse files
committed
Remove redundant examples
1 parent cc4c548 commit 26d25e9

3 files changed

Lines changed: 4 additions & 35 deletions

File tree

openfisca_core/periods/period_.py

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -121,42 +121,10 @@ class Period(tuple):
121121
122122
"""
123123

124-
def __repr__(self):
124+
def __repr__(self) -> str:
125125
return '{}({})'.format(self.__class__.__name__, super(Period, self).__repr__())
126126

127-
def __str__(self):
128-
"""Transform period to a string.
129-
130-
Examples:
131-
>>> str(Period(("year", Instant((2021, 1, 1)), 1)))
132-
'2021'
133-
134-
>>> str(Period(("year", Instant((2021, 2, 1)), 1)))
135-
'year:2021-02'
136-
137-
>>> str(Period(("month", Instant((2021, 2, 1)), 1)))
138-
'2021-02'
139-
140-
>>> str(Period(("year", Instant((2021, 1, 1)), 2)))
141-
'year:2021:2'
142-
143-
>>> str(Period(("month", Instant((2021, 1, 1)), 2)))
144-
'month:2021-01:2'
145-
146-
>>> str(Period(("month", Instant((2021, 1, 1)), 12)))
147-
'2021'
148-
149-
>>> str(Period(("year", Instant((2021, 3, 1)), 2)))
150-
'year:2021-03:2'
151-
152-
>>> str(Period(("month", Instant((2021, 3, 1)), 2)))
153-
'month:2021-03:2'
154-
155-
>>> str(Period(("month", Instant((2021, 3, 1)), 12)))
156-
'year:2021-03'
157-
158-
"""
159-
127+
def __str__(self) -> str:
160128
unit, start_instant, size = self
161129
if unit == config.ETERNITY:
162130
return 'ETERNITY'

openfisca_core/periods/tests/period/test_str.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ def test_str_with_months(date_unit, instant, size, expected):
3030
[DateUnit.DAY, Instant((2022, 3, 1)), 3, "day:2022-03-01:3"],
3131
])
3232
def test_str_with_days(date_unit, instant, size, expected):
33-
assert str(Period((date_unit, instant, size))) == expected
33+
assert str(Period((date_unit, instant, size))) == expected

tests/core/test_periods.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
# Years
1717

18+
1819
def test_parsing_year():
1920
assert period('2014') == Period((YEAR, first_jan, 1))
2021

0 commit comments

Comments
 (0)