From 0704046536d60a1dddae65b1dcf1075f8058e968 Mon Sep 17 00:00:00 2001 From: squidfunk Date: Tue, 22 Aug 2023 11:22:56 +0200 Subject: [PATCH] Fixed compatibility with Python < 3.10 --- material/plugins/blog/structure/__init__.py | 5 +++-- material/plugins/blog/templates/__init__.py | 2 +- src/plugins/blog/structure/__init__.py | 5 +++-- src/plugins/blog/templates/__init__.py | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/material/plugins/blog/structure/__init__.py b/material/plugins/blog/structure/__init__.py index 22348cf6c..b503a73ae 100644 --- a/material/plugins/blog/structure/__init__.py +++ b/material/plugins/blog/structure/__init__.py @@ -18,6 +18,8 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. +from __future__ import annotations + import logging import os import yaml @@ -33,7 +35,6 @@ from mkdocs.structure.pages import Page, _RelativePathTreeprocessor from mkdocs.structure.toc import get_toc from mkdocs.utils.meta import YAML_RE from re import Match -from typing import Union from yaml import SafeLoader from .config import PostConfig @@ -205,7 +206,7 @@ class View(Page): # Initialize view def __init__(self, title: str | None, file: File, config: MkDocsConfig): super().__init__(title, file, config) - self.parent: Union[View, Section] + self.parent: View | Section # Initialize posts and views self.posts: list[Post] = [] diff --git a/material/plugins/blog/templates/__init__.py b/material/plugins/blog/templates/__init__.py index ea7edee7f..9f7d794bb 100644 --- a/material/plugins/blog/templates/__init__.py +++ b/material/plugins/blog/templates/__init__.py @@ -29,7 +29,7 @@ from mkdocs.utils.templates import url_filter as _url_filter # Filter for normalizing URLs with support for paginated views @pass_context -def url_filter(context: Context, url: str | None): +def url_filter(context: Context, url: str): page = context["page"] # If the current page is a view, check if the URL links to the page diff --git a/src/plugins/blog/structure/__init__.py b/src/plugins/blog/structure/__init__.py index 22348cf6c..b503a73ae 100644 --- a/src/plugins/blog/structure/__init__.py +++ b/src/plugins/blog/structure/__init__.py @@ -18,6 +18,8 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS # IN THE SOFTWARE. +from __future__ import annotations + import logging import os import yaml @@ -33,7 +35,6 @@ from mkdocs.structure.pages import Page, _RelativePathTreeprocessor from mkdocs.structure.toc import get_toc from mkdocs.utils.meta import YAML_RE from re import Match -from typing import Union from yaml import SafeLoader from .config import PostConfig @@ -205,7 +206,7 @@ class View(Page): # Initialize view def __init__(self, title: str | None, file: File, config: MkDocsConfig): super().__init__(title, file, config) - self.parent: Union[View, Section] + self.parent: View | Section # Initialize posts and views self.posts: list[Post] = [] diff --git a/src/plugins/blog/templates/__init__.py b/src/plugins/blog/templates/__init__.py index ea7edee7f..9f7d794bb 100644 --- a/src/plugins/blog/templates/__init__.py +++ b/src/plugins/blog/templates/__init__.py @@ -29,7 +29,7 @@ from mkdocs.utils.templates import url_filter as _url_filter # Filter for normalizing URLs with support for paginated views @pass_context -def url_filter(context: Context, url: str | None): +def url_filter(context: Context, url: str): page = context["page"] # If the current page is a view, check if the URL links to the page