From 0bd02c00c078fe041b65fbf4eab13601bb42676d Mon Sep 17 00:00:00 2001 From: boxydog Date: Thu, 30 May 2024 10:53:38 -0500 Subject: [PATCH] Ruff v0.4.6 auto-fixes --- pelican/__init__.py | 10 +--------- pelican/settings.py | 5 +---- pelican/tests/test_generators.py | 12 ++++++------ pelican/utils.py | 18 +++++++++--------- pelican/writers.py | 2 +- 5 files changed, 18 insertions(+), 29 deletions(-) diff --git a/pelican/__init__.py b/pelican/__init__.py index 8a880584..d63f88c3 100644 --- a/pelican/__init__.py +++ b/pelican/__init__.py @@ -193,15 +193,7 @@ class Pelican: ) console.print( - "Done: Processed {}, {}, {}, {}, {} and {} in {:.2f} seconds.".format( - pluralized_articles, - pluralized_drafts, - pluralized_hidden_articles, - pluralized_pages, - pluralized_hidden_pages, - pluralized_draft_pages, - time.time() - start_time, - ) + f"Done: Processed {pluralized_articles}, {pluralized_drafts}, {pluralized_hidden_articles}, {pluralized_pages}, {pluralized_hidden_pages} and {pluralized_draft_pages} in {time.time() - start_time:.2f} seconds." ) def _get_generator_classes(self): diff --git a/pelican/settings.py b/pelican/settings.py index 2cd6fb00..0585b3be 100644 --- a/pelican/settings.py +++ b/pelican/settings.py @@ -322,10 +322,7 @@ def handle_deprecated_settings(settings: Settings) -> Settings: "EXTRA_TEMPLATES_PATHS is deprecated use " "THEME_TEMPLATES_OVERRIDES instead." ) - if ( - "THEME_TEMPLATES_OVERRIDES" in settings - and settings["THEME_TEMPLATES_OVERRIDES"] - ): + if settings.get("THEME_TEMPLATES_OVERRIDES"): raise Exception( "Setting both EXTRA_TEMPLATES_PATHS and " "THEME_TEMPLATES_OVERRIDES is not permitted. Please move to " diff --git a/pelican/tests/test_generators.py b/pelican/tests/test_generators.py index 920d9061..e739e180 100644 --- a/pelican/tests/test_generators.py +++ b/pelican/tests/test_generators.py @@ -597,9 +597,9 @@ class TestArticlesGenerator(unittest.TestCase): self.assertEqual(expected, abbreviated_archives) # Day archives enabled: - settings[ - "DAY_ARCHIVE_SAVE_AS" - ] = "posts/{date:%Y}/{date:%b}/{date:%d}/index.html" + settings["DAY_ARCHIVE_SAVE_AS"] = ( + "posts/{date:%Y}/{date:%b}/{date:%d}/index.html" + ) settings["DAY_ARCHIVE_URL"] = "posts/{date:%Y}/{date:%b}/{date:%d}/" context = get_context(settings) generator = ArticlesGenerator( @@ -737,9 +737,9 @@ class TestArticlesGenerator(unittest.TestCase): all_articles=generator.articles, ) - settings[ - "DAY_ARCHIVE_SAVE_AS" - ] = "posts/{date:%Y}/{date:%b}/{date:%d}/index.html" + settings["DAY_ARCHIVE_SAVE_AS"] = ( + "posts/{date:%Y}/{date:%b}/{date:%d}/index.html" + ) settings["DAY_ARCHIVE_URL"] = "posts/{date:%Y}/{date:%b}/{date:%d}/" context = get_context(settings) generator = ArticlesGenerator( diff --git a/pelican/utils.py b/pelican/utils.py index 7017c458..78e3e807 100644 --- a/pelican/utils.py +++ b/pelican/utils.py @@ -446,15 +446,15 @@ class _HTMLWordTruncator(HTMLParser): r"{DBC}|(\w[\w'-]*)".format( # DBC means CJK-like characters. An character can stand for a word. DBC=( - "([\u4E00-\u9FFF])|" # CJK Unified Ideographs - "([\u3400-\u4DBF])|" # CJK Unified Ideographs Extension A - "([\uF900-\uFAFF])|" # CJK Compatibility Ideographs - "([\U00020000-\U0002A6DF])|" # CJK Unified Ideographs Extension B - "([\U0002F800-\U0002FA1F])|" # CJK Compatibility Ideographs Supplement - "([\u3040-\u30FF])|" # Hiragana and Katakana - "([\u1100-\u11FF])|" # Hangul Jamo - "([\uAC00-\uD7FF])|" # Hangul Compatibility Jamo - "([\u3130-\u318F])" # Hangul Syllables + "([\u4e00-\u9fff])|" # CJK Unified Ideographs + "([\u3400-\u4dbf])|" # CJK Unified Ideographs Extension A + "([\uf900-\ufaff])|" # CJK Compatibility Ideographs + "([\U00020000-\U0002a6df])|" # CJK Unified Ideographs Extension B + "([\U0002f800-\U0002fa1f])|" # CJK Compatibility Ideographs Supplement + "([\u3040-\u30ff])|" # Hiragana and Katakana + "([\u1100-\u11ff])|" # Hangul Jamo + "([\uac00-\ud7ff])|" # Hangul Compatibility Jamo + "([\u3130-\u318f])" # Hangul Syllables ) ), re.UNICODE, diff --git a/pelican/writers.py b/pelican/writers.py index 746811e1..cce01b58 100644 --- a/pelican/writers.py +++ b/pelican/writers.py @@ -27,7 +27,7 @@ class Writer: self._overridden_files = set() # See Content._link_replacer for details - if "RELATIVE_URLS" in self.settings and self.settings["RELATIVE_URLS"]: + if self.settings.get("RELATIVE_URLS"): self.urljoiner = posix_join else: self.urljoiner = lambda base, url: urljoin(