mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Merge pull request #3313 from boxydog/upgrade_ruff
This commit is contained in:
commit
425f302880
8 changed files with 25 additions and 32 deletions
|
|
@ -7,3 +7,5 @@ ecd598f293161a52564aa6e8dfdcc8284dc93970
|
||||||
db241feaa445375dc05e189e69287000ffe5fa8e
|
db241feaa445375dc05e189e69287000ffe5fa8e
|
||||||
# Change pre-commit to run ruff and ruff-format with fixes
|
# Change pre-commit to run ruff and ruff-format with fixes
|
||||||
6d8597addb17d5fa3027ead91427939e8e4e89ec
|
6d8597addb17d5fa3027ead91427939e8e4e89ec
|
||||||
|
# Upgrade Ruff from 0.1.x to 0.4.x
|
||||||
|
0bd02c00c078fe041b65fbf4eab13601bb42676d
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
# See https://pre-commit.com/hooks.html for info on hooks
|
# See https://pre-commit.com/hooks.html for info on hooks
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
rev: v4.5.0
|
rev: v4.6.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: check-added-large-files
|
- id: check-added-large-files
|
||||||
- id: check-ast
|
- id: check-ast
|
||||||
|
|
@ -14,7 +14,8 @@ repos:
|
||||||
- id: forbid-new-submodules
|
- id: forbid-new-submodules
|
||||||
- id: trailing-whitespace
|
- id: trailing-whitespace
|
||||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||||
rev: v0.1.15
|
# ruff version should match the one in pyproject.toml
|
||||||
|
rev: v0.4.6
|
||||||
hooks:
|
hooks:
|
||||||
- id: ruff
|
- id: ruff
|
||||||
args: [--fix, --exit-non-zero-on-fix]
|
args: [--fix, --exit-non-zero-on-fix]
|
||||||
|
|
|
||||||
|
|
@ -193,15 +193,7 @@ class Pelican:
|
||||||
)
|
)
|
||||||
|
|
||||||
console.print(
|
console.print(
|
||||||
"Done: Processed {}, {}, {}, {}, {} and {} in {:.2f} seconds.".format(
|
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."
|
||||||
pluralized_articles,
|
|
||||||
pluralized_drafts,
|
|
||||||
pluralized_hidden_articles,
|
|
||||||
pluralized_pages,
|
|
||||||
pluralized_hidden_pages,
|
|
||||||
pluralized_draft_pages,
|
|
||||||
time.time() - start_time,
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def _get_generator_classes(self):
|
def _get_generator_classes(self):
|
||||||
|
|
|
||||||
|
|
@ -322,10 +322,7 @@ def handle_deprecated_settings(settings: Settings) -> Settings:
|
||||||
"EXTRA_TEMPLATES_PATHS is deprecated use "
|
"EXTRA_TEMPLATES_PATHS is deprecated use "
|
||||||
"THEME_TEMPLATES_OVERRIDES instead."
|
"THEME_TEMPLATES_OVERRIDES instead."
|
||||||
)
|
)
|
||||||
if (
|
if settings.get("THEME_TEMPLATES_OVERRIDES"):
|
||||||
"THEME_TEMPLATES_OVERRIDES" in settings
|
|
||||||
and settings["THEME_TEMPLATES_OVERRIDES"]
|
|
||||||
):
|
|
||||||
raise Exception(
|
raise Exception(
|
||||||
"Setting both EXTRA_TEMPLATES_PATHS and "
|
"Setting both EXTRA_TEMPLATES_PATHS and "
|
||||||
"THEME_TEMPLATES_OVERRIDES is not permitted. Please move to "
|
"THEME_TEMPLATES_OVERRIDES is not permitted. Please move to "
|
||||||
|
|
|
||||||
|
|
@ -597,9 +597,9 @@ class TestArticlesGenerator(unittest.TestCase):
|
||||||
self.assertEqual(expected, abbreviated_archives)
|
self.assertEqual(expected, abbreviated_archives)
|
||||||
|
|
||||||
# Day archives enabled:
|
# Day archives enabled:
|
||||||
settings[
|
settings["DAY_ARCHIVE_SAVE_AS"] = (
|
||||||
"DAY_ARCHIVE_SAVE_AS"
|
"posts/{date:%Y}/{date:%b}/{date:%d}/index.html"
|
||||||
] = "posts/{date:%Y}/{date:%b}/{date:%d}/index.html"
|
)
|
||||||
settings["DAY_ARCHIVE_URL"] = "posts/{date:%Y}/{date:%b}/{date:%d}/"
|
settings["DAY_ARCHIVE_URL"] = "posts/{date:%Y}/{date:%b}/{date:%d}/"
|
||||||
context = get_context(settings)
|
context = get_context(settings)
|
||||||
generator = ArticlesGenerator(
|
generator = ArticlesGenerator(
|
||||||
|
|
@ -737,9 +737,9 @@ class TestArticlesGenerator(unittest.TestCase):
|
||||||
all_articles=generator.articles,
|
all_articles=generator.articles,
|
||||||
)
|
)
|
||||||
|
|
||||||
settings[
|
settings["DAY_ARCHIVE_SAVE_AS"] = (
|
||||||
"DAY_ARCHIVE_SAVE_AS"
|
"posts/{date:%Y}/{date:%b}/{date:%d}/index.html"
|
||||||
] = "posts/{date:%Y}/{date:%b}/{date:%d}/index.html"
|
)
|
||||||
settings["DAY_ARCHIVE_URL"] = "posts/{date:%Y}/{date:%b}/{date:%d}/"
|
settings["DAY_ARCHIVE_URL"] = "posts/{date:%Y}/{date:%b}/{date:%d}/"
|
||||||
context = get_context(settings)
|
context = get_context(settings)
|
||||||
generator = ArticlesGenerator(
|
generator = ArticlesGenerator(
|
||||||
|
|
|
||||||
|
|
@ -446,15 +446,15 @@ class _HTMLWordTruncator(HTMLParser):
|
||||||
r"{DBC}|(\w[\w'-]*)".format(
|
r"{DBC}|(\w[\w'-]*)".format(
|
||||||
# DBC means CJK-like characters. An character can stand for a word.
|
# DBC means CJK-like characters. An character can stand for a word.
|
||||||
DBC=(
|
DBC=(
|
||||||
"([\u4E00-\u9FFF])|" # CJK Unified Ideographs
|
"([\u4e00-\u9fff])|" # CJK Unified Ideographs
|
||||||
"([\u3400-\u4DBF])|" # CJK Unified Ideographs Extension A
|
"([\u3400-\u4dbf])|" # CJK Unified Ideographs Extension A
|
||||||
"([\uF900-\uFAFF])|" # CJK Compatibility Ideographs
|
"([\uf900-\ufaff])|" # CJK Compatibility Ideographs
|
||||||
"([\U00020000-\U0002A6DF])|" # CJK Unified Ideographs Extension B
|
"([\U00020000-\U0002a6df])|" # CJK Unified Ideographs Extension B
|
||||||
"([\U0002F800-\U0002FA1F])|" # CJK Compatibility Ideographs Supplement
|
"([\U0002f800-\U0002fa1f])|" # CJK Compatibility Ideographs Supplement
|
||||||
"([\u3040-\u30FF])|" # Hiragana and Katakana
|
"([\u3040-\u30ff])|" # Hiragana and Katakana
|
||||||
"([\u1100-\u11FF])|" # Hangul Jamo
|
"([\u1100-\u11ff])|" # Hangul Jamo
|
||||||
"([\uAC00-\uD7FF])|" # Hangul Compatibility Jamo
|
"([\uac00-\ud7ff])|" # Hangul Compatibility Jamo
|
||||||
"([\u3130-\u318F])" # Hangul Syllables
|
"([\u3130-\u318f])" # Hangul Syllables
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
re.UNICODE,
|
re.UNICODE,
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ class Writer:
|
||||||
self._overridden_files = set()
|
self._overridden_files = set()
|
||||||
|
|
||||||
# See Content._link_replacer for details
|
# 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
|
self.urljoiner = posix_join
|
||||||
else:
|
else:
|
||||||
self.urljoiner = lambda base, url: urljoin(
|
self.urljoiner = lambda base, url: urljoin(
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,8 @@ dev = [
|
||||||
"pytest-xdist>=3.4.0",
|
"pytest-xdist>=3.4.0",
|
||||||
"tox>=4.11.3",
|
"tox>=4.11.3",
|
||||||
"invoke>=2.2.0",
|
"invoke>=2.2.0",
|
||||||
"ruff>=0.1.15,<0.2.0",
|
# ruff version should match the one in .pre-commit-config.yaml
|
||||||
|
"ruff==0.4.6",
|
||||||
"tomli>=2.0.1; python_version < \"3.11\"",
|
"tomli>=2.0.1; python_version < \"3.11\"",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue