Skip to content

Commit 0f7830b

Browse files
committed
update(chore): run pyupgrade with Python 3.10 as minimal version
1 parent 823cb9c commit 0f7830b

File tree

5 files changed

+15
-22
lines changed

5 files changed

+15
-22
lines changed

mkdocs_rss_plugin/integrations/theme_material_base.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
# ########## Libraries #############
55
# ##################################
66

7-
# standard library
8-
from typing import Optional
9-
107
# 3rd party
118
from mkdocs.config.defaults import MkDocsConfig
129
from mkdocs.plugins import get_plugin_logger
@@ -36,7 +33,7 @@
3633
class IntegrationMaterialThemeBase:
3734
# attributes
3835
IS_THEME_MATERIAL: bool = False
39-
IS_INSIDERS: Optional[bool] = False
36+
IS_INSIDERS: bool | None = False
4037

4138
def __init__(self, mkdocs_config: MkDocsConfig) -> None:
4239
"""Integration instantiation.
@@ -51,7 +48,7 @@ def __init__(self, mkdocs_config: MkDocsConfig) -> None:
5148
self.IS_INSIDERS = self.is_mkdocs_theme_material_insiders()
5249

5350
def is_mkdocs_theme_material(
54-
self, mkdocs_config: Optional[MkDocsConfig] = None
51+
self, mkdocs_config: MkDocsConfig | None = None
5552
) -> bool:
5653
"""Check if the theme set in mkdocs.yml is material or not.
5754
@@ -67,7 +64,7 @@ def is_mkdocs_theme_material(
6764
self.IS_THEME_MATERIAL = mkdocs_config.theme.name == "material"
6865
return self.IS_THEME_MATERIAL
6966

70-
def is_mkdocs_theme_material_insiders(self) -> Optional[bool]:
67+
def is_mkdocs_theme_material_insiders(self) -> bool | None:
7168
"""Check if the material theme is community or insiders edition.
7269
7370
Returns:

mkdocs_rss_plugin/integrations/theme_material_blog_plugin.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
# standard library
88
from functools import lru_cache
99
from pathlib import Path
10-
from typing import Optional
1110

1211
# 3rd party
1312
from mkdocs.config.defaults import MkDocsConfig
@@ -69,9 +68,7 @@ def __init__(self, mkdocs_config: MkDocsConfig, switch_force: bool = True) -> No
6968
"disabled in plugin's option in Mkdocs configuration."
7069
)
7170

72-
def is_blog_plugin_enabled_mkdocs(
73-
self, mkdocs_config: Optional[MkDocsConfig]
74-
) -> bool:
71+
def is_blog_plugin_enabled_mkdocs(self, mkdocs_config: MkDocsConfig | None) -> bool:
7572
"""Check if blog plugin is installed and enabled.
7673
7774
Args:

mkdocs_rss_plugin/integrations/theme_material_social_plugin.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import json
99
from hashlib import md5
1010
from pathlib import Path
11-
from typing import Optional
1211

1312
# 3rd party
1413
from mkdocs.config.defaults import MkDocsConfig
@@ -48,7 +47,7 @@ class IntegrationMaterialSocialCards(IntegrationMaterialThemeBase):
4847
IS_ENABLED: bool = True
4948
IS_SOCIAL_PLUGIN_ENABLED: bool = True
5049
IS_SOCIAL_PLUGIN_CARDS_ENABLED: bool = True
51-
CARDS_MANIFEST: Optional[dict] = None
50+
CARDS_MANIFEST: dict | None = None
5251

5352
def __init__(self, mkdocs_config: MkDocsConfig, switch_force: bool = True) -> None:
5453
"""Integration instantiation.
@@ -107,7 +106,7 @@ def __init__(self, mkdocs_config: MkDocsConfig, switch_force: bool = True) -> No
107106
self.site_description = mkdocs_config.site_description or ""
108107

109108
def is_social_plugin_enabled_mkdocs(
110-
self, mkdocs_config: Optional[MkDocsConfig] = None
109+
self, mkdocs_config: MkDocsConfig | None = None
111110
) -> bool:
112111
"""Check if social plugin is installed and enabled.
113112
@@ -184,7 +183,7 @@ def is_social_plugin_enabled_page(
184183
"cards", fallback_value
185184
)
186185

187-
def load_cache_cards_manifest(self) -> Optional[dict]:
186+
def load_cache_cards_manifest(self) -> dict | None:
188187
"""Load social cards manifest if the file exists.
189188
190189
Returns:
@@ -262,8 +261,8 @@ def get_social_cards_cache_dir(self, mkdocs_config: MkDocsConfig) -> Path:
262261
return self.social_cards_cache_dir
263262

264263
def get_social_card_build_path_for_page(
265-
self, mkdocs_page: MkdocsPageSubset, mkdocs_site_dir: Optional[str] = None
266-
) -> Optional[Path]:
264+
self, mkdocs_page: MkdocsPageSubset, mkdocs_site_dir: str | None = None
265+
) -> Path | None:
267266
"""Get social card path in Mkdocs build dir for a specific page.
268267
269268
Args:
@@ -305,7 +304,7 @@ def get_social_card_build_path_for_page(
305304

306305
def get_social_card_cache_path_for_page(
307306
self, mkdocs_page: MkdocsPageSubset
308-
) -> Optional[Path]:
307+
) -> Path | None:
309308
"""Get social card path in social plugin cache folder for a specific page.
310309
311310
Note:
@@ -377,7 +376,7 @@ def get_social_card_cache_path_for_page(
377376
def get_social_card_url_for_page(
378377
self,
379378
mkdocs_page: MkdocsPageSubset,
380-
mkdocs_site_url: Optional[str] = None,
379+
mkdocs_site_url: str | None = None,
381380
) -> str:
382381
"""Get social card URL for a specific page in documentation.
383382

mkdocs_rss_plugin/plugin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from email.utils import format_datetime, formatdate
1313
from pathlib import Path
1414
from re import compile as re_compile
15-
from typing import Literal, Optional
15+
from typing import Literal
1616

1717
# 3rd party
1818
from jinja2 import Environment, FileSystemLoader, select_autoescape
@@ -265,7 +265,7 @@ def on_config(self, config: MkDocsConfig) -> MkDocsConfig:
265265
@event_priority(priority=-75)
266266
def on_page_content(
267267
self, html: str, page: Page, config: MkDocsConfig, files: Files
268-
) -> Optional[str]:
268+
) -> str | None:
269269
"""The page_content event is called after the Markdown text is rendered to HTML
270270
(but before being passed to a template) and can be used to alter the HTML
271271
body of the page.

mkdocs_rss_plugin/util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from functools import lru_cache
1212
from mimetypes import guess_type
1313
from pathlib import Path
14-
from typing import Any, Literal, Union
14+
from typing import Any, Literal
1515
from urllib.parse import urlencode, urlparse, urlunparse
1616

1717
# 3rd party
@@ -172,7 +172,7 @@ def build_url(
172172
url_parts[4] = urlencode(args_dict)
173173
return urlunparse(url_parts)
174174

175-
def get_value_from_dot_key(self, data: dict, dot_key: Union[str, bool]) -> Any:
175+
def get_value_from_dot_key(self, data: dict, dot_key: str | bool) -> Any:
176176
"""Retrieves a value from a dictionary using a dot notation key.
177177
178178
Args:

0 commit comments

Comments
 (0)