diff --git a/lektor_index_pages/__init__.py b/lektor_index_pages/__init__.py index f50d4f7..b782ca3 100644 --- a/lektor_index_pages/__init__.py +++ b/lektor_index_pages/__init__.py @@ -1,4 +1,3 @@ -""" Index pages for Lektor -""" +"""Index pages for Lektor""" from .plugin import IndexPagesPlugin # noqa: F401 diff --git a/lektor_index_pages/buildprog.py b/lektor_index_pages/buildprog.py index 16ae297..9287c9a 100644 --- a/lektor_index_pages/buildprog.py +++ b/lektor_index_pages/buildprog.py @@ -1,5 +1,4 @@ -""" Build program for the index pages. -""" +"""Build program for the index pages.""" from __future__ import annotations diff --git a/lektor_index_pages/config.py b/lektor_index_pages/config.py index 82810cd..5eb7e1a 100644 --- a/lektor_index_pages/config.py +++ b/lektor_index_pages/config.py @@ -1,6 +1,4 @@ -""" Configuration and config-related logic. - -""" +"""Configuration and config-related logic.""" from __future__ import annotations diff --git a/lektor_index_pages/indexmodel.py b/lektor_index_pages/indexmodel.py index 9de14c3..c6b4086 100644 --- a/lektor_index_pages/indexmodel.py +++ b/lektor_index_pages/indexmodel.py @@ -1,6 +1,4 @@ -""" Configurable logic that controls how indexes work - -""" +"""Configurable logic that controls how indexes work""" from __future__ import annotations @@ -19,10 +17,11 @@ if TYPE_CHECKING: from _typeshed import StrPath from inifile import IniFile - from lektor.environment import Environment from lektor.db import Query from lektor.db import Record + from lektor.environment import Environment from lektor.sourceobj import SourceObject + from .sourceobj import IndexBase from .sourceobj import IndexRoot from .sourceobj import IndexSource @@ -154,7 +153,7 @@ def __init__( self.key_expr = expr("key", key) self.slug_expr = expr("slug_format", slug_format) if slug_format else None - fields_section = "%s.fields" % index_name + fields_section = f"{index_name}.fields" field = ExpressionCompiler( env, section=fields_section, filename=config_filename ) @@ -231,7 +230,7 @@ def __call__(self, name: str, expr: str) -> FieldDescriptor: f"Jinja expression syntax error in config file: {exc}\n" f" in expression {expr!r}\n" f" for name {name!r}{self.location}" - ) + ) from exc class FieldDescriptor: diff --git a/lektor_index_pages/plugin.py b/lektor_index_pages/plugin.py index 5d5e36d..6b0a045 100644 --- a/lektor_index_pages/plugin.py +++ b/lektor_index_pages/plugin.py @@ -142,7 +142,7 @@ def index_pages( try: index_root = config.get_index_root(index_name, pad, alt) except NoSuchIndex as exc: - return jinja_ctx.environment.undefined("index_pages: %s" % exc) + return jinja_ctx.environment.undefined(f"index_pages: {exc}") return IndexPages(index_root) env.jinja_env.globals["index_pages"] = index_pages diff --git a/lektor_index_pages/sourceobj.py b/lektor_index_pages/sourceobj.py index 58c8eb1..25caadc 100644 --- a/lektor_index_pages/sourceobj.py +++ b/lektor_index_pages/sourceobj.py @@ -1,6 +1,4 @@ -""" Virtual source objects for the indexes. - -""" +"""Virtual source objects for the indexes.""" from __future__ import annotations @@ -33,6 +31,7 @@ from lektor.builder import PathCache from lektor.db import Record from lektor.pagination import Pagination + from .indexmodel import IndexModel from .indexmodel import IndexRootModel from .plugin import Cache diff --git a/pdm_build.py b/pdm_build.py index 8c7fd5a..bcc92ad 100644 --- a/pdm_build.py +++ b/pdm_build.py @@ -1,5 +1,4 @@ -"""PDM build hook to generate dynamic README. -""" +"""PDM build hook to generate dynamic README.""" from __future__ import annotations diff --git a/tests/conftest.py b/tests/conftest.py index 6642730..638a889 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -103,7 +103,7 @@ def junk_ini(tmp_path_factory): @pytest.fixture def inifile(site_path, junk_ini, my_plugin_id, pagination_enabled, month_index_enabled): # Make a temporary copy of our .ini file - config_name = "%s.ini" % my_plugin_id + config_name = f"{my_plugin_id}.ini" orig_ini = site_path / "configs" / config_name inifile = IniFile(str(orig_ini)) inifile.filename = str(junk_ini) diff --git a/tests/test_indexmodel.py b/tests/test_indexmodel.py index 075c98d..19a20c1 100644 --- a/tests/test_indexmodel.py +++ b/tests/test_indexmodel.py @@ -260,10 +260,10 @@ def compiler(self, lektor_env, filename, section): @pytest.mark.parametrize("section", ["section", None]) def test_location(self, compiler, filename, section): if filename: - expect = r"in .*\b%s\b" % re.escape(filename) + expect = rf"in .*\b{re.escape(filename)}\b" assert re.search(expect, compiler.location) if section: - expect = r"\[%s\]" % re.escape(section) + expect = rf"\[{re.escape(section)}\]" assert re.search(expect, compiler.location) def test_error_report(self, compiler): diff --git a/tests/test_sourceobj.py b/tests/test_sourceobj.py index c80c447..579ef27 100644 --- a/tests/test_sourceobj.py +++ b/tests/test_sourceobj.py @@ -125,7 +125,7 @@ def test_pagination(self, year_index, blog_record, pagination_enabled): assert year_index.pagination.total == blog_record.children.count() else: with pytest.raises(RuntimeError): - year_index.pagination + _ = year_index.pagination def test_subindexes(self, index, index_root): if index is index_root: @@ -140,7 +140,7 @@ def test__subindex_ids_missing_if_no_subindex(self, year_index): assert not hasattr(year_index, "_subindex_ids") def test_path(self, index_root): - assert index_root.path == "/blog@%s/year-index" % VIRTUAL_PATH_PREFIX + assert index_root.path == f"/blog@{VIRTUAL_PATH_PREFIX}/year-index" def test__gid(self, index_root): # md5("/blog@index-pages/year-index")