Skip to content

Commit dcdeaf3

Browse files
committed
fix(integration): imports from Material for Mkdocs blog plugin for type hint was breaking the build when using another theme
closes #408
1 parent 35f61f1 commit dcdeaf3

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

mkdocs_rss_plugin/integrations/theme_material_blog_plugin.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# standard library
88
from functools import lru_cache
99
from pathlib import Path
10+
from typing import Union
1011

1112
# 3rd party
1213
from mkdocs.config.defaults import MkDocsConfig
@@ -26,7 +27,7 @@
2627
from material.plugins.blog.structure import Post
2728

2829
except ImportError:
29-
material_version = None
30+
material_version = BlogPlugin = Post = None
3031

3132

3233
# ############################################################################
@@ -132,16 +133,16 @@ def author_name_from_id(self, author_id: str) -> str:
132133
)
133134
return author_id
134135

135-
def is_page_a_blog_post(self, mkdocs_page: Post | MkdocsPageSubset) -> bool:
136+
def is_page_a_blog_post(self, mkdocs_page: Union["Post", MkdocsPageSubset]) -> bool:
136137
"""Identifies if the given page is part of Material Blog.
137138
138139
Args:
139-
mkdocs_page (Page): page to identify
140+
mkdocs_page: page to identify
140141
141142
Returns:
142-
bool: True if the given page is a Material Blog post.
143+
True if the given page is a Material Blog post.
143144
"""
144-
if self.IS_ENABLED and isinstance(mkdocs_page, Post):
145+
if self.IS_ENABLED and Post is not None and isinstance(mkdocs_page, Post):
145146
logger.debug(
146147
f"page '{mkdocs_page.file.src_uri}' identified as Material Blog post."
147148
)

0 commit comments

Comments
 (0)