Update new code for style compliance

This commit is contained in:
Justin Mayer 2024-04-16 16:33:40 +02:00
commit a65c85300c
2 changed files with 14 additions and 18 deletions

View file

@ -19,12 +19,12 @@ from pelican.tools.pelican_import import (
download_attachments,
fields2pelican,
get_attachments,
tumblr2fields,
wp2fields,
medium_slug,
mediumpost2fields,
mediumposts2fields,
strip_medium_post_content,
medium_slug,
tumblr2fields,
wp2fields,
)
from pelican.utils import path_to_file_url, slugify

View file

@ -23,14 +23,10 @@ from typing import (
Any,
Callable,
Collection,
Dict,
Generator,
Iterable,
List,
Optional,
Sequence,
Tuple,
Type,
Union,
)
@ -153,7 +149,7 @@ class memoized:
def __init__(self, func: Callable) -> None:
self.func = func
self.cache: Dict[Any, Any] = {}
self.cache: dict[Any, Any] = {}
def __call__(self, *args) -> Any:
if not isinstance(args, Hashable):
@ -180,8 +176,8 @@ class memoized:
def deprecated_attribute(
old: str,
new: str,
since: Tuple[int, ...],
remove: Optional[Tuple[int, ...]] = None,
since: tuple[int, ...],
remove: Optional[tuple[int, ...]] = None,
doc: Optional[str] = None,
):
"""Attribute deprecation decorator for gentle upgrades
@ -251,7 +247,7 @@ def pelican_open(
def slugify(
value: str,
regex_subs: Iterable[Tuple[str, str]] = (),
regex_subs: Iterable[tuple[str, str]] = (),
preserve_case: bool = False,
use_unicode: bool = False,
) -> str:
@ -637,9 +633,9 @@ def truncate_html_words(s: str, num: int, end_text: str = "…") -> str:
def process_translations(
content_list: List[Content],
content_list: list[Content],
translation_id: Optional[Union[str, Collection[str]]] = None,
) -> Tuple[List[Content], List[Content]]:
) -> tuple[list[Content], list[Content]]:
"""Finds translations and returns them.
For each content_list item, populates the 'translations' attribute, and
@ -697,7 +693,7 @@ def process_translations(
return index, translations
def get_original_items(items: List[Content], with_str: str) -> List[Content]:
def get_original_items(items: list[Content], with_str: str) -> list[Content]:
def _warn_source_paths(msg, items, *extra):
args = [len(items)]
args.extend(extra)
@ -738,9 +734,9 @@ def get_original_items(items: List[Content], with_str: str) -> List[Content]:
def order_content(
content_list: List[Content],
content_list: list[Content],
order_by: Union[str, Callable[[Content], Any], None] = "slug",
) -> List[Content]:
) -> list[Content]:
"""Sorts content.
order_by can be a string of an attribute or sorting function. If order_by
@ -802,8 +798,8 @@ def order_content(
def wait_for_changes(
settings_file: str,
reader_class: Type["Readers"],
settings: "Settings",
reader_class: type[Readers],
settings: Settings,
):
content_path = settings.get("PATH", "")
theme_path = settings.get("THEME", "")