mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Enable flake8-unused-arguments Ruff rule.
This commit is contained in:
parent
162d2b8318
commit
6df3cfc6e3
11 changed files with 23 additions and 17 deletions
|
|
@ -252,6 +252,7 @@ class Pelican:
|
||||||
|
|
||||||
class PrintSettings(argparse.Action):
|
class PrintSettings(argparse.Action):
|
||||||
def __call__(self, parser, namespace, values, option_string):
|
def __call__(self, parser, namespace, values, option_string):
|
||||||
|
del option_string # Unused argument
|
||||||
init_logging(name=__name__)
|
init_logging(name=__name__)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
@ -287,6 +288,7 @@ class PrintSettings(argparse.Action):
|
||||||
|
|
||||||
class ParseOverrides(argparse.Action):
|
class ParseOverrides(argparse.Action):
|
||||||
def __call__(self, parser, namespace, values, option_string=None):
|
def __call__(self, parser, namespace, values, option_string=None):
|
||||||
|
del parser, option_string # Unused arguments
|
||||||
overrides = {}
|
overrides = {}
|
||||||
for item in values:
|
for item in values:
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
|
|
@ -431,7 +431,7 @@ class Content:
|
||||||
return self.get_content(self.get_siteurl())
|
return self.get_content(self.get_siteurl())
|
||||||
|
|
||||||
@memoized
|
@memoized
|
||||||
def get_summary(self, siteurl: str) -> str:
|
def get_summary(self, _siteurl: str) -> str:
|
||||||
"""Returns the summary of an article.
|
"""Returns the summary of an article.
|
||||||
|
|
||||||
This is based on the summary metadata if set, otherwise truncate the
|
This is based on the summary metadata if set, otherwise truncate the
|
||||||
|
|
@ -552,6 +552,7 @@ class SkipStub(Content):
|
||||||
def __init__(
|
def __init__(
|
||||||
self, content, metadata=None, settings=None, source_path=None, context=None
|
self, content, metadata=None, settings=None, source_path=None, context=None
|
||||||
):
|
):
|
||||||
|
del content, metadata, settings, context # Unused arguments
|
||||||
self.source_path = source_path
|
self.source_path = source_path
|
||||||
|
|
||||||
def is_valid(self):
|
def is_valid(self):
|
||||||
|
|
|
||||||
|
|
@ -296,6 +296,7 @@ class _FileLoader(BaseLoader):
|
||||||
self.fullpath = os.path.join(basedir, path)
|
self.fullpath = os.path.join(basedir, path)
|
||||||
|
|
||||||
def get_source(self, environment, template):
|
def get_source(self, environment, template):
|
||||||
|
del environment # Unused argument
|
||||||
if template != self.path or not os.path.exists(self.fullpath):
|
if template != self.path or not os.path.exists(self.fullpath):
|
||||||
raise TemplateNotFound(template)
|
raise TemplateNotFound(template)
|
||||||
mtime = os.path.getmtime(self.fullpath)
|
mtime = os.path.getmtime(self.fullpath)
|
||||||
|
|
@ -1022,6 +1023,7 @@ class StaticGenerator(Generator):
|
||||||
signals.static_generator_finalized.send(self)
|
signals.static_generator_finalized.send(self)
|
||||||
|
|
||||||
def generate_output(self, writer):
|
def generate_output(self, writer):
|
||||||
|
del writer # Unused argument
|
||||||
self._copy_paths(
|
self._copy_paths(
|
||||||
self.settings["THEME_STATIC_PATHS"],
|
self.settings["THEME_STATIC_PATHS"],
|
||||||
self.theme,
|
self.theme,
|
||||||
|
|
@ -1131,6 +1133,7 @@ class SourceFileGenerator(Generator):
|
||||||
copy(obj.source_path, dest)
|
copy(obj.source_path, dest)
|
||||||
|
|
||||||
def generate_output(self, writer=None):
|
def generate_output(self, writer=None):
|
||||||
|
del writer # Unused argument
|
||||||
logger.info("Generating source files...")
|
logger.info("Generating source files...")
|
||||||
for obj in chain(self.context["articles"], self.context["pages"]):
|
for obj in chain(self.context["articles"], self.context["pages"]):
|
||||||
self._create_source(obj)
|
self._create_source(obj)
|
||||||
|
|
|
||||||
|
|
@ -45,15 +45,15 @@ DUPLICATES_DEFINITIONS_ALLOWED = {
|
||||||
|
|
||||||
METADATA_PROCESSORS = {
|
METADATA_PROCESSORS = {
|
||||||
"tags": lambda x, y: ([Tag(tag, y) for tag in ensure_metadata_list(x)] or _DISCARD),
|
"tags": lambda x, y: ([Tag(tag, y) for tag in ensure_metadata_list(x)] or _DISCARD),
|
||||||
"date": lambda x, y: get_date(x.replace("_", " ")),
|
"date": lambda x, _y: get_date(x.replace("_", " ")),
|
||||||
"modified": lambda x, y: get_date(x),
|
"modified": lambda x, _y: get_date(x),
|
||||||
"status": lambda x, y: x.strip() or _DISCARD,
|
"status": lambda x, _y: x.strip() or _DISCARD,
|
||||||
"category": lambda x, y: _process_if_nonempty(Category, x, y),
|
"category": lambda x, y: _process_if_nonempty(Category, x, y),
|
||||||
"author": lambda x, y: _process_if_nonempty(Author, x, y),
|
"author": lambda x, y: _process_if_nonempty(Author, x, y),
|
||||||
"authors": lambda x, y: (
|
"authors": lambda x, y: (
|
||||||
[Author(author, y) for author in ensure_metadata_list(x)] or _DISCARD
|
[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__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
@ -121,6 +121,7 @@ class BaseReader:
|
||||||
|
|
||||||
def read(self, source_path):
|
def read(self, source_path):
|
||||||
"No-op parser"
|
"No-op parser"
|
||||||
|
del source_path # Unused argument
|
||||||
content = None
|
content = None
|
||||||
metadata = {}
|
metadata = {}
|
||||||
return content, metadata
|
return content, metadata
|
||||||
|
|
@ -165,6 +166,7 @@ class PelicanHTMLTranslator(HTMLTranslator):
|
||||||
self.body.append(self.starttag(node, "abbr", "", **attrs))
|
self.body.append(self.starttag(node, "abbr", "", **attrs))
|
||||||
|
|
||||||
def depart_abbreviation(self, node):
|
def depart_abbreviation(self, node):
|
||||||
|
del node # Unused argument
|
||||||
self.body.append("</abbr>")
|
self.body.append("</abbr>")
|
||||||
|
|
||||||
def visit_image(self, node):
|
def visit_image(self, node):
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,7 @@ class abbreviation(nodes.Inline, nodes.TextElement):
|
||||||
|
|
||||||
|
|
||||||
def abbr_role(typ, rawtext, text, lineno, inliner, options=None, content=None):
|
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)
|
text = utils.unescape(text)
|
||||||
m = _abbr_re.search(text)
|
m = _abbr_re.search(text)
|
||||||
if m is None:
|
if m is None:
|
||||||
|
|
|
||||||
|
|
@ -333,7 +333,7 @@ class TestPage(TestBase):
|
||||||
self.assertEqual("custom", custom_page.template)
|
self.assertEqual("custom", custom_page.template)
|
||||||
|
|
||||||
def test_signal(self):
|
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 = True
|
||||||
|
|
||||||
receiver_test_function.has_been_called = False
|
receiver_test_function.has_been_called = False
|
||||||
|
|
|
||||||
|
|
@ -552,7 +552,7 @@ class TestWordpressXMLAttachements(TestCaseWithCLocale):
|
||||||
class TestTumblrImporter(TestCaseWithCLocale):
|
class TestTumblrImporter(TestCaseWithCLocale):
|
||||||
@patch("pelican.tools.pelican_import._get_tumblr_posts")
|
@patch("pelican.tools.pelican_import._get_tumblr_posts")
|
||||||
def test_posts(self, get):
|
def test_posts(self, get):
|
||||||
def get_posts(api_key, blogname, offset=0):
|
def get_posts(_api_key, _blogname, offset=0):
|
||||||
if offset > 0:
|
if offset > 0:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
|
@ -603,7 +603,7 @@ class TestTumblrImporter(TestCaseWithCLocale):
|
||||||
|
|
||||||
@patch("pelican.tools.pelican_import._get_tumblr_posts")
|
@patch("pelican.tools.pelican_import._get_tumblr_posts")
|
||||||
def test_video_embed(self, get):
|
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:
|
if offset > 0:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
|
@ -657,7 +657,7 @@ class TestTumblrImporter(TestCaseWithCLocale):
|
||||||
|
|
||||||
@patch("pelican.tools.pelican_import._get_tumblr_posts")
|
@patch("pelican.tools.pelican_import._get_tumblr_posts")
|
||||||
def test_broken_video_embed(self, get):
|
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:
|
if offset > 0:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ from pelican.tests.support import unittest
|
||||||
|
|
||||||
|
|
||||||
class MockRequest:
|
class MockRequest:
|
||||||
def makefile(self, *args, **kwargs):
|
def makefile(self, *_args, **_kwargs):
|
||||||
return BytesIO(b"")
|
return BytesIO(b"")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -941,7 +941,6 @@ def fields2pelican(
|
||||||
strip_raw=False,
|
strip_raw=False,
|
||||||
disable_slugs=False,
|
disable_slugs=False,
|
||||||
dirpage=False,
|
dirpage=False,
|
||||||
filename_template=None,
|
|
||||||
filter_author=None,
|
filter_author=None,
|
||||||
wp_custpost=False,
|
wp_custpost=False,
|
||||||
wp_attach=False,
|
wp_attach=False,
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ import os
|
||||||
import pathlib
|
import pathlib
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
import sys
|
|
||||||
import traceback
|
import traceback
|
||||||
import unicodedata
|
import unicodedata
|
||||||
import urllib
|
import urllib
|
||||||
|
|
@ -215,7 +214,7 @@ def deprecated_attribute(
|
||||||
_warn()
|
_warn()
|
||||||
setattr(self, new, value)
|
setattr(self, new, value)
|
||||||
|
|
||||||
def decorator(dummy):
|
def decorator(_dummy):
|
||||||
return property(fget=fget, fset=fset, doc=doc)
|
return property(fget=fget, fset=fset, doc=doc)
|
||||||
|
|
||||||
return decorator
|
return decorator
|
||||||
|
|
@ -235,9 +234,7 @@ def get_date(string: str) -> datetime.datetime:
|
||||||
|
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def pelican_open(
|
def pelican_open(filename: str, mode: str = "r") -> Generator[str, None, None]:
|
||||||
filename: str, mode: str = "r", strip_crs: bool = (sys.platform == "win32")
|
|
||||||
) -> Generator[str, None, None]:
|
|
||||||
"""Open a file and return its content"""
|
"""Open a file and return its content"""
|
||||||
|
|
||||||
# utf-8-sig will clear any BOM if present
|
# utf-8-sig will clear any BOM if present
|
||||||
|
|
@ -493,6 +490,7 @@ class _HTMLWordTruncator(HTMLParser):
|
||||||
self.add_word(self.last_word_end)
|
self.add_word(self.last_word_end)
|
||||||
|
|
||||||
def handle_starttag(self, tag: str, attrs: Any) -> None:
|
def handle_starttag(self, tag: str, attrs: Any) -> None:
|
||||||
|
del attrs # Unused argument
|
||||||
self.add_last_word()
|
self.add_last_word()
|
||||||
if tag not in self._singlets:
|
if tag not in self._singlets:
|
||||||
self.open_tags.insert(0, tag)
|
self.open_tags.insert(0, tag)
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,7 @@ select = [
|
||||||
|
|
||||||
# the rest in alphabetical order:
|
# the rest in alphabetical order:
|
||||||
"A", # flake8-builtins
|
"A", # flake8-builtins
|
||||||
# TODO: "ARG", # flake8-unused-arguments
|
"ARG", # flake8-unused-arguments
|
||||||
"B", # flake8-bugbear
|
"B", # flake8-bugbear
|
||||||
# TODO: "BLE", # flake8-blind-except
|
# TODO: "BLE", # flake8-blind-except
|
||||||
# TODO: Do I want "COM", # flake8-commas
|
# TODO: Do I want "COM", # flake8-commas
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue