File tree 2 files changed +14
-14
lines changed
material/plugins/blog/structure
src/plugins/blog/structure
2 files changed +14
-14
lines changed Original file line number Diff line number Diff line change 18
18
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19
19
# IN THE SOFTWARE.
20
20
21
- from collections import UserDict
22
21
from datetime import date , datetime , time
23
22
from mkdocs .config .base import BaseConfigOption , Config , ValidationError
23
+ from typing import Dict
24
24
25
25
# -----------------------------------------------------------------------------
26
26
# Classes
27
27
# -----------------------------------------------------------------------------
28
28
29
29
# Date dictionary
30
- class DateDict (UserDict [str , datetime ]):
30
+ class DateDict (Dict [str , datetime ]):
31
31
32
32
# Initialize date dictionary
33
33
def __init__ (self , data : dict ):
34
34
super ().__init__ (data )
35
35
36
- # Initialize date of creation
37
- if "created" in data :
38
- self .created : datetime = data ["created" ]
36
+ # Ensure presence of `date.created`
37
+ self .created : datetime = data ["created" ]
39
38
39
+ # Allow attribute access
40
40
def __getattr__ (self , name : str ):
41
- if name in self . data :
42
- return self . data [name ]
41
+ if name in self :
42
+ return self [name ]
43
43
44
44
# -----------------------------------------------------------------------------
45
45
Original file line number Diff line number Diff line change 18
18
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
19
19
# IN THE SOFTWARE.
20
20
21
- from collections import UserDict
22
21
from datetime import date , datetime , time
23
22
from mkdocs .config .base import BaseConfigOption , Config , ValidationError
23
+ from typing import Dict
24
24
25
25
# -----------------------------------------------------------------------------
26
26
# Classes
27
27
# -----------------------------------------------------------------------------
28
28
29
29
# Date dictionary
30
- class DateDict (UserDict [str , datetime ]):
30
+ class DateDict (Dict [str , datetime ]):
31
31
32
32
# Initialize date dictionary
33
33
def __init__ (self , data : dict ):
34
34
super ().__init__ (data )
35
35
36
- # Initialize date of creation
37
- if "created" in data :
38
- self .created : datetime = data ["created" ]
36
+ # Ensure presence of `date.created`
37
+ self .created : datetime = data ["created" ]
39
38
39
+ # Allow attribute access
40
40
def __getattr__ (self , name : str ):
41
- if name in self . data :
42
- return self . data [name ]
41
+ if name in self :
42
+ return self [name ]
43
43
44
44
# -----------------------------------------------------------------------------
45
45
You can’t perform that action at this time.
0 commit comments