mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Merge pull request #3312 from boxydog/more_ruff_fixes
This commit is contained in:
commit
880e9769e8
7 changed files with 21 additions and 30 deletions
|
|
@ -9,3 +9,5 @@ db241feaa445375dc05e189e69287000ffe5fa8e
|
||||||
6d8597addb17d5fa3027ead91427939e8e4e89ec
|
6d8597addb17d5fa3027ead91427939e8e4e89ec
|
||||||
# Upgrade Ruff from 0.1.x to 0.4.x
|
# Upgrade Ruff from 0.1.x to 0.4.x
|
||||||
0bd02c00c078fe041b65fbf4eab13601bb42676d
|
0bd02c00c078fe041b65fbf4eab13601bb42676d
|
||||||
|
# Apply more Ruff checks to code
|
||||||
|
9d30c5608a58d202b1c02d55651e6ac746bfb173
|
||||||
|
|
|
||||||
|
|
@ -32,19 +32,18 @@ def parse_arguments():
|
||||||
"--cert",
|
"--cert",
|
||||||
default="./cert.pem",
|
default="./cert.pem",
|
||||||
nargs="?",
|
nargs="?",
|
||||||
help="Path to certificate file. " + "Relative to current directory",
|
help="Path to certificate file. Relative to current directory",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--key",
|
"--key",
|
||||||
default="./key.pem",
|
default="./key.pem",
|
||||||
nargs="?",
|
nargs="?",
|
||||||
help="Path to certificate key file. " + "Relative to current directory",
|
help="Path to certificate key file. Relative to current directory",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--path",
|
"--path",
|
||||||
default=".",
|
default=".",
|
||||||
help="Path to pelican source directory to serve. "
|
help="Path to pelican source directory to serve. Relative to current directory",
|
||||||
+ "Relative to current directory",
|
|
||||||
)
|
)
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -223,7 +223,7 @@ def read_settings(
|
||||||
# parameters to docutils directive handlers, so we have to have a
|
# parameters to docutils directive handlers, so we have to have a
|
||||||
# variable here that we'll import from within Pygments.run (see
|
# variable here that we'll import from within Pygments.run (see
|
||||||
# rstdirectives.py) to see what the user defaults were.
|
# rstdirectives.py) to see what the user defaults were.
|
||||||
global PYGMENTS_RST_OPTIONS
|
global PYGMENTS_RST_OPTIONS # noqa: PLW0603
|
||||||
PYGMENTS_RST_OPTIONS = settings.get("PYGMENTS_RST_OPTIONS", None)
|
PYGMENTS_RST_OPTIONS = settings.get("PYGMENTS_RST_OPTIONS", None)
|
||||||
return settings
|
return settings
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -152,11 +152,12 @@ class TestWordpressXmlImporter(TestCaseWithCLocale):
|
||||||
|
|
||||||
def test_dircat(self):
|
def test_dircat(self):
|
||||||
silent_f2p = mute(True)(fields2pelican)
|
silent_f2p = mute(True)(fields2pelican)
|
||||||
test_posts = []
|
test_posts = [
|
||||||
for post in self.posts:
|
post
|
||||||
# check post kind
|
for post in self.posts
|
||||||
if len(post[5]) > 0: # Has a category
|
# check post has a category
|
||||||
test_posts.append(post)
|
if len(post[5]) > 0
|
||||||
|
]
|
||||||
with temporary_folder() as temp:
|
with temporary_folder() as temp:
|
||||||
fnames = list(silent_f2p(test_posts, "markdown", temp, dircat=True))
|
fnames = list(silent_f2p(test_posts, "markdown", temp, dircat=True))
|
||||||
subs = DEFAULT_CONFIG["SLUG_REGEX_SUBSTITUTIONS"]
|
subs = DEFAULT_CONFIG["SLUG_REGEX_SUBSTITUTIONS"]
|
||||||
|
|
@ -185,7 +186,7 @@ class TestWordpressXmlImporter(TestCaseWithCLocale):
|
||||||
kind,
|
kind,
|
||||||
format,
|
format,
|
||||||
) in self.posts:
|
) in self.posts:
|
||||||
if kind == "page" or kind == "article":
|
if kind in {"page", "article"}:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
pages_data.append((title, fname))
|
pages_data.append((title, fname))
|
||||||
|
|
@ -206,7 +207,7 @@ class TestWordpressXmlImporter(TestCaseWithCLocale):
|
||||||
kind,
|
kind,
|
||||||
format,
|
format,
|
||||||
) in self.custposts:
|
) in self.custposts:
|
||||||
if kind == "article" or kind == "page":
|
if kind in {"page", "article"}:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
cust_data.append((title, kind))
|
cust_data.append((title, kind))
|
||||||
|
|
@ -266,11 +267,12 @@ class TestWordpressXmlImporter(TestCaseWithCLocale):
|
||||||
def test_wp_custpost_true_dirpage_false(self):
|
def test_wp_custpost_true_dirpage_false(self):
|
||||||
# pages should only be put in their own directory when dirpage = True
|
# pages should only be put in their own directory when dirpage = True
|
||||||
silent_f2p = mute(True)(fields2pelican)
|
silent_f2p = mute(True)(fields2pelican)
|
||||||
test_posts = []
|
test_posts = [
|
||||||
for post in self.custposts:
|
post
|
||||||
|
for post in self.custposts
|
||||||
# check post kind
|
# check post kind
|
||||||
if post[8] == "page":
|
if post[8] == "page"
|
||||||
test_posts.append(post)
|
]
|
||||||
with temporary_folder() as temp:
|
with temporary_folder() as temp:
|
||||||
fnames = list(
|
fnames = list(
|
||||||
silent_f2p(
|
silent_f2p(
|
||||||
|
|
@ -748,10 +750,7 @@ class TestMediumImporter(TestCaseWithCLocale):
|
||||||
|
|
||||||
def test_mediumposts2field(self):
|
def test_mediumposts2field(self):
|
||||||
"""Parse all posts in an export directory"""
|
"""Parse all posts in an export directory"""
|
||||||
posts = [
|
posts = list(mediumposts2fields(f"{self.test_content_root}/medium_posts"))
|
||||||
fields
|
|
||||||
for fields in mediumposts2fields(f"{self.test_content_root}/medium_posts")
|
|
||||||
]
|
|
||||||
self.assertEqual(1, len(posts))
|
self.assertEqual(1, len(posts))
|
||||||
self.assertEqual(self.post_tuple, posts[0])
|
self.assertEqual(self.post_tuple, posts[0])
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,4 +6,4 @@ from pelican.tests.support import unittest
|
||||||
class TestSuiteTest(unittest.TestCase):
|
class TestSuiteTest(unittest.TestCase):
|
||||||
def test_error_on_warning(self):
|
def test_error_on_warning(self):
|
||||||
with self.assertRaises(UserWarning):
|
with self.assertRaises(UserWarning):
|
||||||
warnings.warn("test warning")
|
warnings.warn("test warning") # noqa: B028
|
||||||
|
|
|
||||||
|
|
@ -190,19 +190,10 @@ ignore = [
|
||||||
"PLR5501", # collapsible-else-if
|
"PLR5501", # collapsible-else-if
|
||||||
"PERF203", # try-except-in-loop
|
"PERF203", # try-except-in-loop
|
||||||
"B006", # mutable-argument-default
|
"B006", # mutable-argument-default
|
||||||
"PLR1714", # repeated-equality-comparison
|
|
||||||
"PERF401", # manual-list-comprehension
|
|
||||||
# TODO: these only have one violation each in Dec 2023:
|
# TODO: these only have one violation each in Dec 2023:
|
||||||
"SLOT000", # no-slots-in-str-subclass
|
"SLOT000", # no-slots-in-str-subclass
|
||||||
"PYI024", # collections-named-tuple
|
"PYI024", # collections-named-tuple
|
||||||
"PLW0603", # global-statement
|
|
||||||
"PIE800", # unnecessary-spread
|
"PIE800", # unnecessary-spread
|
||||||
"ISC003", # explicit-string-concatenation
|
|
||||||
"EXE002", # shebang-missing-executable-file
|
|
||||||
"C401", # unnecessary-generator-set
|
|
||||||
"C416", # unnecessary `list` comprehension
|
|
||||||
"B028", # no-explicit-stacklevel
|
|
||||||
"B008", # function-call-in-default-argument
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[tool.ruff.lint.extend-per-file-ignores]
|
[tool.ruff.lint.extend-per-file-ignores]
|
||||||
|
|
|
||||||
0
samples/pelican.conf.py
vendored
Executable file → Normal file
0
samples/pelican.conf.py
vendored
Executable file → Normal file
Loading…
Add table
Add a link
Reference in a new issue