Skip to content

Commit

Permalink
Fixed compatibility with Python < 3.10
Browse files Browse the repository at this point in the history
  • Loading branch information
squidfunk committed Aug 22, 2023
1 parent 9f3efb8 commit 0704046
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
5 changes: 3 additions & 2 deletions material/plugins/blog/structure/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -33,7 +35,6 @@
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
Expand Down Expand Up @@ -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] = []
Expand Down
2 changes: 1 addition & 1 deletion material/plugins/blog/templates/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

# 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
Expand Down
5 changes: 3 additions & 2 deletions src/plugins/blog/structure/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -33,7 +35,6 @@
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
Expand Down Expand Up @@ -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] = []
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/blog/templates/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

# 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
Expand Down

0 comments on commit 0704046

Please sign in to comment.