diff --git a/docs/conf.py b/docs/conf.py
index 283562b9..4c15bc62 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -34,7 +34,7 @@ project = project_data.get("name").upper()
year = datetime.datetime.fromtimestamp(
int(os.environ.get("SOURCE_DATE_EPOCH", time.time())), datetime.timezone.utc
).year
-copyright = f"2010–{year}" # noqa: RUF001
+project_copyright = f"2010–{year}" # noqa: RUF001
exclude_patterns = ["_build"]
release = project_data.get("version")
version = ".".join(release.split(".")[:1])
diff --git a/pelican/server.py b/pelican/server.py
index ebf13677..c4607e21 100644
--- a/pelican/server.py
+++ b/pelican/server.py
@@ -122,8 +122,8 @@ class ComplexHTTPRequestHandler(server.SimpleHTTPRequestHandler):
return mimetype
- def log_message(self, format, *args):
- logger.info(format, *args)
+ def log_message(self, msg_format, *args):
+ logger.info(msg_format, *args)
class RootedHTTPServer(server.HTTPServer):
diff --git a/pelican/tests/test_plugins.py b/pelican/tests/test_plugins.py
index 69a0384c..42bb2ca6 100644
--- a/pelican/tests/test_plugins.py
+++ b/pelican/tests/test_plugins.py
@@ -273,14 +273,14 @@ class PluginTest(unittest.TestCase):
expected = []
for i in range(50):
# function appends value of i to a list
- def func(input, i=i):
- input.append(i)
+ def func(dummy_input, i=i):
+ dummy_input.append(i)
functions.append(func)
# we expect functions to be run in the connection order
dummy_signal.connect(func)
expected.append(i)
- input = []
- dummy_signal.send(input)
- self.assertEqual(input, expected)
+ dummy_input = []
+ dummy_signal.send(dummy_input)
+ self.assertEqual(dummy_input, expected)
diff --git a/pelican/tests/test_utils.py b/pelican/tests/test_utils.py
index 01ad1c58..95bf197a 100644
--- a/pelican/tests/test_utils.py
+++ b/pelican/tests/test_utils.py
@@ -998,28 +998,32 @@ class TestFileChangeFilter(unittest.TestCase):
ignore_file_patterns = DEFAULT_CONFIG["IGNORE_FILES"]
def test_regular_files_not_filtered(self):
- filter = utils.FileChangeFilter(ignore_file_patterns=self.ignore_file_patterns)
+ file_change_filter = utils.FileChangeFilter(
+ ignore_file_patterns=self.ignore_file_patterns
+ )
basename = "article.rst"
full_path = os.path.join(os.path.dirname(__file__), "content", basename)
for change in watchfiles.Change:
- self.assertTrue(filter(change=change, path=basename))
- self.assertTrue(filter(change=change, path=full_path))
+ self.assertTrue(file_change_filter(change=change, path=basename))
+ self.assertTrue(file_change_filter(change=change, path=full_path))
def test_dotfiles_filtered(self):
- filter = utils.FileChangeFilter(ignore_file_patterns=self.ignore_file_patterns)
+ file_change_filter = utils.FileChangeFilter(
+ ignore_file_patterns=self.ignore_file_patterns
+ )
basename = ".config"
full_path = os.path.join(os.path.dirname(__file__), "content", basename)
# Testing with just the hidden file name and the full file path to the hidden file
for change in watchfiles.Change:
- self.assertFalse(filter(change=change, path=basename))
- self.assertFalse(filter(change=change, path=full_path))
+ self.assertFalse(file_change_filter(change=change, path=basename))
+ self.assertFalse(file_change_filter(change=change, path=full_path))
def test_default_filters(self):
# Testing a subset of the default filters
# For reference: https://watchfiles.helpmanual.io/api/filters/#watchfiles.DefaultFilter.ignore_dirs
- filter = utils.FileChangeFilter(ignore_file_patterns=[])
+ file_change_filter = utils.FileChangeFilter(ignore_file_patterns=[])
test_basenames = [
"__pycache__",
".git",
@@ -1040,20 +1044,20 @@ class TestFileChangeFilter(unittest.TestCase):
for basename in test_basenames:
full_path = os.path.join(os.path.dirname(__file__), basename)
for change in watchfiles.Change:
- self.assertFalse(filter(change=change, path=basename))
- self.assertFalse(filter(change=change, path=full_path))
+ self.assertFalse(file_change_filter(change=change, path=basename))
+ self.assertFalse(file_change_filter(change=change, path=full_path))
def test_custom_ignore_pattern(self):
- filter = utils.FileChangeFilter(ignore_file_patterns=["*.rst"])
+ file_change_filter = utils.FileChangeFilter(ignore_file_patterns=["*.rst"])
basename = "article.rst"
full_path = os.path.join(os.path.dirname(__file__), basename)
for change in watchfiles.Change:
- self.assertFalse(filter(change=change, path=basename))
- self.assertFalse(filter(change=change, path=full_path))
+ self.assertFalse(file_change_filter(change=change, path=basename))
+ self.assertFalse(file_change_filter(change=change, path=full_path))
# If the user changes `IGNORE_FILES` to only contain ['*.rst'], then dotfiles would not be filtered anymore
basename = ".config"
full_path = os.path.join(os.path.dirname(__file__), basename)
for change in watchfiles.Change:
- self.assertTrue(filter(change=change, path=basename))
- self.assertTrue(filter(change=change, path=full_path))
+ self.assertTrue(file_change_filter(change=change, path=basename))
+ self.assertTrue(file_change_filter(change=change, path=full_path))
diff --git a/pelican/tools/pelican_import.py b/pelican/tools/pelican_import.py
index 7270488e..8bcae51f 100755
--- a/pelican/tools/pelican_import.py
+++ b/pelican/tools/pelican_import.py
@@ -320,7 +320,7 @@ def dc2fields(file):
# post_id = fields[0][1:]
# blog_id = fields[1]
# user_id = fields[2]
- cat_id = fields[3]
+ cat_ids = fields[3]
# post_dt = fields[4]
# post_tz = fields[5]
post_creadt = fields[6]
@@ -354,8 +354,10 @@ def dc2fields(file):
categories = []
tags = []
- if cat_id:
- categories = [category_list[id].strip() for id in cat_id.split(",")]
+ if cat_ids:
+ categories = [
+ category_list[cat_id].strip() for cat_id in cat_ids.split(",")
+ ]
# Get tags related to a post
tag = (
@@ -453,11 +455,11 @@ def tumblr2fields(api_key, blogname):
).strftime("%Y-%m-%d-")
+ slug
)
- format = post.get("format")
+ post_format = post.get("format")
content = post.get("body")
- type = post.get("type")
- if type == "photo":
- if format == "markdown":
+ post_type = post.get("type")
+ if post_type == "photo":
+ if post_format == "markdown":
fmtstr = ""
else:
fmtstr = ''
@@ -466,20 +468,20 @@ def tumblr2fields(api_key, blogname):
% (photo.get("caption"), photo.get("original_size").get("url"))
for photo in post.get("photos")
)
- elif type == "quote":
- if format == "markdown":
+ elif post_type == "quote":
+ if post_format == "markdown":
fmtstr = "\n\n— %s"
else:
fmtstr = "
— %s
" content = post.get("text") + fmtstr % post.get("source") - elif type == "link": - if format == "markdown": + elif post_type == "link": + if post_format == "markdown": fmtstr = "[via](%s)\n\n" else: fmtstr = '\n' content = fmtstr % post.get("url") + post.get("description") - elif type == "audio": - if format == "markdown": + elif post_type == "audio": + if post_format == "markdown": fmtstr = "[via](%s)\n\n" else: fmtstr = '\n' @@ -488,8 +490,8 @@ def tumblr2fields(api_key, blogname): + post.get("caption") + post.get("player") ) - elif type == "video": - if format == "markdown": + elif post_type == "video": + if post_format == "markdown": fmtstr = "[via](%s)\n\n" else: fmtstr = '\n' @@ -506,7 +508,7 @@ def tumblr2fields(api_key, blogname): else: players = "\n".join(players) content = source + caption + players - elif type == "answer": + elif post_type == "answer": title = post.get("question") content = ( "" @@ -531,11 +533,11 @@ def tumblr2fields(api_key, blogname): slug, date, post.get("blog_name"), - [type], + [post_type], tags, status, kind, - format, + post_format, ) offset += len(posts) diff --git a/pyproject.toml b/pyproject.toml index 9684d6df..7af9366c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -125,7 +125,7 @@ select = [ "F", # pyflakes # the rest in alphabetical order: - # TODO: "A", # flake8-builtins + "A", # flake8-builtins # TODO: "ARG", # flake8-unused-arguments "B", # flake8-bugbear # TODO: "BLE", # flake8-blind-except diff --git a/tasks.py b/tasks.py index cf9851ed..f5a02a35 100644 --- a/tasks.py +++ b/tasks.py @@ -56,7 +56,7 @@ def coverage(c): @task -def format(c, check=False, diff=False): +def formatcode(c, check=False, diff=False): """Run Ruff's auto-formatter, optionally with --check or --diff""" check_flag, diff_flag = "", "" if check: @@ -83,7 +83,7 @@ def ruff(c, fix=False, diff=False): def lint(c, fix=False, diff=False): """Check code style via linting tools.""" ruff(c, fix=fix, diff=diff) - format(c, check=not fix, diff=diff) + formatcode(c, check=not fix, diff=diff) @task