Skip to content

Commit

Permalink
Fixed blog plugin compatibility with Python < 3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
squidfunk committed Aug 30, 2023
1 parent 4c6b004 commit f2512de
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
14 changes: 7 additions & 7 deletions material/plugins/blog/structure/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,28 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.

from collections import UserDict
from datetime import date, datetime, time
from mkdocs.config.base import BaseConfigOption, Config, ValidationError
from typing import Dict

# -----------------------------------------------------------------------------
# Classes
# -----------------------------------------------------------------------------

# Date dictionary
class DateDict(UserDict[str, datetime]):
class DateDict(Dict[str, datetime]):

# Initialize date dictionary
def __init__(self, data: dict):
super().__init__(data)

# Initialize date of creation
if "created" in data:
self.created: datetime = data["created"]
# Ensure presence of `date.created`
self.created: datetime = data["created"]

# Allow attribute access
def __getattr__(self, name: str):
if name in self.data:
return self.data[name]
if name in self:
return self[name]

# -----------------------------------------------------------------------------

Expand Down
14 changes: 7 additions & 7 deletions src/plugins/blog/structure/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,28 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.

from collections import UserDict
from datetime import date, datetime, time
from mkdocs.config.base import BaseConfigOption, Config, ValidationError
from typing import Dict

# -----------------------------------------------------------------------------
# Classes
# -----------------------------------------------------------------------------

# Date dictionary
class DateDict(UserDict[str, datetime]):
class DateDict(Dict[str, datetime]):

# Initialize date dictionary
def __init__(self, data: dict):
super().__init__(data)

# Initialize date of creation
if "created" in data:
self.created: datetime = data["created"]
# Ensure presence of `date.created`
self.created: datetime = data["created"]

# Allow attribute access
def __getattr__(self, name: str):
if name in self.data:
return self.data[name]
if name in self:
return self[name]

# -----------------------------------------------------------------------------

Expand Down

0 comments on commit f2512de

Please sign in to comment.