Merge pull request #3491 from clockback/enable-flake8-unused-arguments

This commit is contained in:
Justin Mayer 2025-07-22 19:18:09 +02:00 committed by GitHub
commit b7408cbfe9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 23 additions and 17 deletions

View file

@ -252,6 +252,7 @@ class Pelican:
class PrintSettings(argparse.Action):
def __call__(self, parser, namespace, values, option_string):
del option_string # Unused argument
init_logging(name=__name__)
try:
@ -287,6 +288,7 @@ class PrintSettings(argparse.Action):
class ParseOverrides(argparse.Action):
def __call__(self, parser, namespace, values, option_string=None):
del parser, option_string # Unused arguments
overrides = {}
for item in values:
try:

View file

@ -431,7 +431,7 @@ class Content:
return self.get_content(self.get_siteurl())
@memoized
def get_summary(self, siteurl: str) -> str:
def get_summary(self, _siteurl: str) -> str:
"""Returns the summary of an article.
This is based on the summary metadata if set, otherwise truncate the
@ -552,6 +552,7 @@ class SkipStub(Content):
def __init__(
self, content, metadata=None, settings=None, source_path=None, context=None
):
del content, metadata, settings, context # Unused arguments
self.source_path = source_path
def is_valid(self):

View file

@ -296,6 +296,7 @@ class _FileLoader(BaseLoader):
self.fullpath = os.path.join(basedir, path)
def get_source(self, environment, template):
del environment # Unused argument
if template != self.path or not os.path.exists(self.fullpath):
raise TemplateNotFound(template)
mtime = os.path.getmtime(self.fullpath)
@ -1022,6 +1023,7 @@ class StaticGenerator(Generator):
signals.static_generator_finalized.send(self)
def generate_output(self, writer):
del writer # Unused argument
self._copy_paths(
self.settings["THEME_STATIC_PATHS"],
self.theme,
@ -1131,6 +1133,7 @@ class SourceFileGenerator(Generator):
copy(obj.source_path, dest)
def generate_output(self, writer=None):
del writer # Unused argument
logger.info("Generating source files...")
for obj in chain(self.context["articles"], self.context["pages"]):
self._create_source(obj)

View file

@ -45,15 +45,15 @@ DUPLICATES_DEFINITIONS_ALLOWED = {
METADATA_PROCESSORS = {
"tags": lambda x, y: ([Tag(tag, y) for tag in ensure_metadata_list(x)] or _DISCARD),
"date": lambda x, y: get_date(x.replace("_", " ")),
"modified": lambda x, y: get_date(x),
"status": lambda x, y: x.strip() or _DISCARD,
"date": lambda x, _y: get_date(x.replace("_", " ")),
"modified": lambda x, _y: get_date(x),
"status": lambda x, _y: x.strip() or _DISCARD,
"category": lambda x, y: _process_if_nonempty(Category, x, y),
"author": lambda x, y: _process_if_nonempty(Author, x, y),
"authors": lambda x, y: (
[Author(author, y) for author in ensure_metadata_list(x)] or _DISCARD
),
"slug": lambda x, y: x.strip() or _DISCARD,
"slug": lambda x, _y: x.strip() or _DISCARD,
}
logger = logging.getLogger(__name__)
@ -121,6 +121,7 @@ class BaseReader:
def read(self, source_path):
"No-op parser"
del source_path # Unused argument
content = None
metadata = {}
return content, metadata
@ -165,6 +166,7 @@ class PelicanHTMLTranslator(HTMLTranslator):
self.body.append(self.starttag(node, "abbr", "", **attrs))
def depart_abbreviation(self, node):
del node # Unused argument
self.body.append("</abbr>")
def visit_image(self, node):

View file

@ -79,6 +79,7 @@ class abbreviation(nodes.Inline, nodes.TextElement):
def abbr_role(typ, rawtext, text, lineno, inliner, options=None, content=None):
del typ, rawtext, lineno, inliner, options, content # Unused arguments
text = utils.unescape(text)
m = _abbr_re.search(text)
if m is None:

View file

@ -333,7 +333,7 @@ class TestPage(TestBase):
self.assertEqual("custom", custom_page.template)
def test_signal(self):
def receiver_test_function(sender):
def receiver_test_function(_sender):
receiver_test_function.has_been_called = True
receiver_test_function.has_been_called = False

View file

@ -552,7 +552,7 @@ class TestWordpressXMLAttachements(TestCaseWithCLocale):
class TestTumblrImporter(TestCaseWithCLocale):
@patch("pelican.tools.pelican_import._get_tumblr_posts")
def test_posts(self, get):
def get_posts(api_key, blogname, offset=0):
def get_posts(_api_key, _blogname, offset=0):
if offset > 0:
return []
@ -603,7 +603,7 @@ class TestTumblrImporter(TestCaseWithCLocale):
@patch("pelican.tools.pelican_import._get_tumblr_posts")
def test_video_embed(self, get):
def get_posts(api_key, blogname, offset=0):
def get_posts(_api_key, _blogname, offset=0):
if offset > 0:
return []
@ -657,7 +657,7 @@ class TestTumblrImporter(TestCaseWithCLocale):
@patch("pelican.tools.pelican_import._get_tumblr_posts")
def test_broken_video_embed(self, get):
def get_posts(api_key, blogname, offset=0):
def get_posts(_api_key, _blogname, offset=0):
if offset > 0:
return []

View file

@ -8,7 +8,7 @@ from pelican.tests.support import unittest
class MockRequest:
def makefile(self, *args, **kwargs):
def makefile(self, *_args, **_kwargs):
return BytesIO(b"")

View file

@ -941,7 +941,6 @@ def fields2pelican(
strip_raw=False,
disable_slugs=False,
dirpage=False,
filename_template=None,
filter_author=None,
wp_custpost=False,
wp_attach=False,

View file

@ -8,7 +8,6 @@ import os
import pathlib
import re
import shutil
import sys
import traceback
import unicodedata
import urllib
@ -215,7 +214,7 @@ def deprecated_attribute(
_warn()
setattr(self, new, value)
def decorator(dummy):
def decorator(_dummy):
return property(fget=fget, fset=fset, doc=doc)
return decorator
@ -235,9 +234,7 @@ def get_date(string: str) -> datetime.datetime:
@contextmanager
def pelican_open(
filename: str, mode: str = "r", strip_crs: bool = (sys.platform == "win32")
) -> Generator[str, None, None]:
def pelican_open(filename: str, mode: str = "r") -> Generator[str, None, None]:
"""Open a file and return its content"""
# utf-8-sig will clear any BOM if present
@ -493,6 +490,7 @@ class _HTMLWordTruncator(HTMLParser):
self.add_word(self.last_word_end)
def handle_starttag(self, tag: str, attrs: Any) -> None:
del attrs # Unused argument
self.add_last_word()
if tag not in self._singlets:
self.open_tags.insert(0, tag)

View file

@ -125,7 +125,7 @@ select = [
# the rest in alphabetical order:
"A", # flake8-builtins
# TODO: "ARG", # flake8-unused-arguments
"ARG", # flake8-unused-arguments
"B", # flake8-bugbear
# TODO: "BLE", # flake8-blind-except
# TODO: Do I want "COM", # flake8-commas