Fixed compatibility with Python < 3.10

This commit is contained in:
squidfunk 2023-08-22 11:22:56 +02:00
parent 9f3efb8a59
commit 0704046536
No known key found for this signature in database
GPG Key ID: 5ED40BC4F9C436DF
4 changed files with 8 additions and 6 deletions

View File

@ -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] = []

View File

@ -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

View File

@ -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] = []

View File

@ -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