Skip to content

Commit

Permalink
fix: | operator is not suported before Python 3.10
Browse files Browse the repository at this point in the history
  • Loading branch information
Guts committed Dec 16, 2023
1 parent 6da581e commit 9d7ba05
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# standard library
import logging
from pathlib import Path
from typing import Optional

# 3rd party
from mkdocs.config.config_options import Config
Expand Down Expand Up @@ -174,13 +175,13 @@ def get_social_cards_dir(self, mkdocs_config: Config) -> str:
return social_plugin_cfg.config.cards_dir

def get_social_card_build_path_for_page(
self, mkdocs_page: Page, mkdocs_site_dir: str | None = None
self, mkdocs_page: Page, mkdocs_site_dir: Optional[str] = None
) -> Path:
"""Get social card URL for a specific page in documentation.
Args:
mkdocs_page (Page): Mkdocs page object.
mkdocs_site_dir (str | None, optional): Mkdocs build site dir. If None, the
mkdocs_site_dir (Optional[str], optional): Mkdocs build site dir. If None, the
'class.mkdocs_site_build_dir' is used. is Defaults to None.
Returns:
Expand All @@ -197,13 +198,13 @@ def get_social_card_build_path_for_page(
def get_social_card_url_for_page(
self,
mkdocs_page: Page,
mkdocs_site_url: str | None = None,
mkdocs_site_url: Optional[str] = None,
) -> str:
"""Get social card URL for a specific page in documentation.
Args:
mkdocs_page (Page): Mkdocs page object.
mkdocs_site_url (str | None, optional): Mkdocs site URL. If None, the
mkdocs_site_url (Optional[str], optional): Mkdocs site URL. If None, the
'class.mkdocs_site_url' is used. is Defaults to None.
Returns:
Expand Down
10 changes: 6 additions & 4 deletions mkdocs_rss_plugin/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from email.utils import format_datetime
from mimetypes import guess_type
from pathlib import Path
from typing import Iterable, Tuple
from typing import Iterable, Optional, Tuple
from urllib import request
from urllib.error import HTTPError, URLError
from urllib.parse import urlencode, urlparse, urlunparse
Expand Down Expand Up @@ -58,7 +58,9 @@ def __init__(
self,
path: str = ".",
use_git: bool = True,
integration_material_social_cards: IntegrationMaterialSocialCards | None = None,
integration_material_social_cards: Optional[
IntegrationMaterialSocialCards
] = None,
):
"""Class hosting the plugin logic.
Expand Down Expand Up @@ -478,7 +480,7 @@ def get_description_or_abstract(
else:
return description if description else ""

def get_image(self, in_page: Page, base_url: str) -> tuple[str, str, int] | None:
def get_image(self, in_page: Page, base_url: str) -> Optional[tuple[str, str, int]]:
"""Get page's image from page meta or social cards and returns properties.
Args:
Expand All @@ -487,7 +489,7 @@ def get_image(self, in_page: Page, base_url: str) -> tuple[str, str, int] | None
with local path.
Returns:
tuple[str, str, int] | None: (image url, mime type, image length) or None if
Optional[tuple[str, str, int]]: (image url, mime type, image length) or None if
there is no image set
"""
if in_page.meta.get("image"):
Expand Down

0 comments on commit 9d7ba05

Please sign in to comment.