22
33import  calendar 
44
5- from  openfisca_core  import  periods 
5+ from  openfisca_core . periods  import  Instant 
66
77from  .date_unit  import  DateUnit 
88
@@ -15,20 +15,24 @@ class Period(tuple):
1515    (year, month, day) triple, and where size is an integer > 1. 
1616
1717    Since a period is a triple it can be used as a dictionary key. 
18+ 
19+     Examples: 
20+         >>> instant = Instant((2021, 9, 1)) 
21+         >>> period = Period((DateUnit.YEAR.value, instant, 3)) 
22+ 
23+         >>> repr(Period) 
24+         "<class 'openfisca_core.periods.period_.Period'>" 
25+ 
26+         >>> repr(period) 
27+         "<Period(('year', <Instant(2021, 9, 1)>, 3))>" 
28+ 
29+         >>> str(period) 
30+         'year:2021-09:3' 
31+ 
1832    """ 
1933
20-     def  __repr__ (self ):
21-         """ 
22-         Transform period to to its Python representation as a string. 
23- 
24-         >>> repr(period('year', 2014)) 
25-         "Period(('year', Instant((2014, 1, 1)), 1))" 
26-         >>> repr(period('month', '2014-2')) 
27-         "Period(('month', Instant((2014, 2, 1)), 1))" 
28-         >>> repr(period('day', '2014-2-3')) 
29-         "Period(('day', Instant((2014, 2, 3)), 1))" 
30-         """ 
31-         return  '{}({})' .format (self .__class__ .__name__ , super (Period , self ).__repr__ ())
34+     def  __repr__ (self ) ->  str :
35+         return  f"<{ self .__class__ .__name__ } { super ().__repr__ ()}  
3236
3337    def  __str__ (self ):
3438        """ 
0 commit comments