diff --git a/betty/extension/nginx/serve.py b/betty/extension/nginx/serve.py index 8fa555d23..a26e7f86c 100644 --- a/betty/extension/nginx/serve.py +++ b/betty/extension/nginx/serve.py @@ -93,7 +93,7 @@ async def stop(self) -> None: @property def public_url(self) -> str: if self._container is not None: - return "http://%s" % self._container.ip + return f"http://{self._container.ip}" raise NoPublicUrlBecauseServerNotStartedError() @classmethod diff --git a/betty/gramps/loader.py b/betty/gramps/loader.py index 5deafca2e..dbb71f9da 100644 --- a/betty/gramps/loader.py +++ b/betty/gramps/loader.py @@ -540,7 +540,7 @@ def _load_person(self, element: ElementTree.Element) -> None: affiliation_name = surname_element.text surname_prefix = surname_element.get("prefix") if surname_prefix is not None: - affiliation_name = "%s %s" % (surname_prefix, affiliation_name) + affiliation_name = f"{surname_prefix} {affiliation_name}" person_name = PersonName( individual=individual_name, affiliation=affiliation_name, diff --git a/betty/locale/date.py b/betty/locale/date.py index e5c0171b5..6033589df 100644 --- a/betty/locale/date.py +++ b/betty/locale/date.py @@ -51,13 +51,7 @@ def __init__( @override def __repr__(self) -> str: - return "<%s.%s(%s, %s, %s)>" % ( - self.__class__.__module__, - self.__class__.__name__, - self.year, - self.month, - self.day, - ) + return f"<{self.__class__.__module__}.{self.__class__.__name__}({self.year}, {self.month}, {self.day})>" @property def comparable(self) -> bool: @@ -86,7 +80,7 @@ def to_range(self) -> DateRange: """ if not self.comparable: raise ValueError( - "Cannot convert non-comparable date %s to a date range." % self + f"Cannot convert non-comparable date {self} to a date range." ) if self.month is None: month_start = 1 @@ -124,9 +118,7 @@ def __contains__(self, other: Any) -> bool: return self == other if isinstance(other, DateRange): return self in other - raise TypeError( - "Expected to check a %s, but a %s was given" % (type(Datey), type(other)) - ) + raise TypeError(f"Expected to check a {Datey}, but a {type(other)} was given") def __lt__(self, other: Any) -> bool: return self._compare(other, operator.lt) @@ -244,14 +236,7 @@ def __init__( @override def __repr__(self) -> str: - return "%s.%s(%s, %s, start_is_boundary=%s, end_is_boundary=%s)" % ( - self.__class__.__module__, - self.__class__.__name__, - repr(self.start), - repr(self.end), - repr(self.start_is_boundary), - repr(self.end_is_boundary), - ) + return f"{self.__class__.__module__}.{self.__class__.__name__}({repr(self.start)}, {repr(self.end)}, start_is_boundary={repr(self.start_is_boundary)}, end_is_boundary={repr(self.end_is_boundary)})" @property def comparable(self) -> bool: @@ -281,8 +266,7 @@ def __contains__(self, other: Any) -> bool: others.append(other.end) else: raise TypeError( - "Expected to check a %s, but a %s was given" - % (type(Datey), type(other)) + f"Expected to check a {Datey}, but a {type(other)} was given" ) if self.start is not None and self.end is not None: diff --git a/betty/tests/_package/test_license_compatibility.py b/betty/tests/_package/test_license_compatibility.py index b1a313d09..6e4bea961 100644 --- a/betty/tests/_package/test_license_compatibility.py +++ b/betty/tests/_package/test_license_compatibility.py @@ -37,11 +37,7 @@ def assert_is_compatible(self, package_license: dict[str, Any]) -> None: if compatible_license in package_license["License"]: return raise AssertionError( - "%s is released under the %s, which is not known to be compatible with Betty's own license" - % ( - package_license["Name"], - package_license["License"], - ) + f"{package_license['Name']} is released under the {package_license['License']}, which is not known to be compatible with Betty's own license" ) async def test_runtime_dependency_license_compatibility(self) -> None: diff --git a/betty/tests/gramps/test_loader.py b/betty/tests/gramps/test_loader.py index 28d50dde4..85e3c3f85 100644 --- a/betty/tests/gramps/test_loader.py +++ b/betty/tests/gramps/test_loader.py @@ -608,15 +608,14 @@ async def test_date_should_load_parts( self, expected: Date, dateval_val: str ) -> None: ancestry = await self._load_partial( - """ + f""" Birth - + """ - % dateval_val ) assert expected == ancestry[Event]["E0000"].date @@ -1128,15 +1127,14 @@ async def test_event_should_include_privacy_from_attribute( self, expected: Privacy, attribute_value: str ) -> None: ancestry = await self._load_partial( - """ + f""" Birth - + """ - % attribute_value ) event = ancestry[Event]["E0000"] assert expected == event.privacy @@ -1154,15 +1152,14 @@ async def test_file_should_include_privacy_from_attribute( self, expected: Privacy, attribute_value: str ) -> None: ancestry = await self._load_partial( - """ + f""" - + """ - % attribute_value ) file = ancestry[File]["O0000"] assert expected == file.privacy @@ -1201,15 +1198,14 @@ async def test_source_from_source_should_include_privacy_from_attribute( self, expected: Privacy, attribute_value: str ) -> None: ancestry = await self._load_partial( - """ + f""" A Whisper - + """ - % attribute_value ) source = ancestry[Source]["S0000"] assert expected == source.privacy @@ -1227,12 +1223,12 @@ async def test_citation_should_include_privacy_from_attribute( self, expected: Privacy, attribute_value: str ) -> None: ancestry = await self._load_partial( - """ + f""" 2 - + @@ -1241,7 +1237,6 @@ async def test_citation_should_include_privacy_from_attribute( """ - % attribute_value ) source = ancestry[Source]["S0000"] source.public = True diff --git a/betty/tests/locale/test_localized.py b/betty/tests/locale/test_localized.py index 2d45767b2..9c481a180 100644 --- a/betty/tests/locale/test_localized.py +++ b/betty/tests/locale/test_localized.py @@ -15,7 +15,7 @@ def __eq__(self, other: Any) -> bool: return self.locale == other.locale def __repr__(self) -> str: - return "%s(%s)" % (self.__class__.__name__, self.locale) + return f"{self.__class__.__name__}({self.locale})" @pytest.mark.parametrize( ("expected", "preferred_locale", "localizeds"), diff --git a/betty/tests/project/test___init__.py b/betty/tests/project/test___init__.py index 802a1ce1d..314207984 100644 --- a/betty/tests/project/test___init__.py +++ b/betty/tests/project/test___init__.py @@ -1035,7 +1035,7 @@ async def test_load_not_an_extension_type_name_should_error( ) -> None: dump: Any = ProjectConfiguration(tmp_path / "betty.json").dump() dump["extensions"] = { - "%s.%s" % (self.__class__.__module__, self.__class__.__name__): {}, + f"{self.__class__.__module__}.{self.__class__.__name__}": {} } sut = ProjectConfiguration(tmp_path / "betty.json") with raises_error(error_type=AssertionFailed): diff --git a/betty/tests/test_generate.py b/betty/tests/test_generate.py index ba8df2767..66da09efd 100644 --- a/betty/tests/test_generate.py +++ b/betty/tests/test_generate.py @@ -243,8 +243,8 @@ async def test_file(self) -> None: project.ancestry.add(file) async with project: await generate(project) - await assert_betty_html(project, "/file/%s/index.html" % file.id) - await assert_betty_json(project, "/file/%s/index.json" % file.id) + await assert_betty_html(project, f"/file/{file.id}/index.html") + await assert_betty_json(project, f"/file/{file.id}/index.json") async def test_places(self) -> None: async with App.new_temporary() as app, app, Project.new_temporary( @@ -265,8 +265,8 @@ async def test_place(self) -> None: project.ancestry.add(place) async with project: await generate(project) - await assert_betty_html(project, "/place/%s/index.html" % place.id) - await assert_betty_json(project, "/place/%s/index.json" % place.id) + await assert_betty_html(project, f"/place/{place.id}/index.html") + await assert_betty_json(project, f"/place/{place.id}/index.json") async def test_people(self) -> None: async with App.new_temporary() as app, app, Project.new_temporary( @@ -309,9 +309,9 @@ async def test_event(self) -> None: project.ancestry.add(event) async with project: await generate(project) - await assert_betty_html(project, "/event/%s/index.html" % event.id) + await assert_betty_html(project, f"/event/{event.id}/index.html") await assert_betty_json( - project, "/event/%s/index.json" % event.id, "event" + project, f"/event/{event.id}/index.json", "event" ) async def test_citation(self) -> None: @@ -326,12 +326,8 @@ async def test_citation(self) -> None: project.ancestry.add(citation, source) async with project: await generate(project) - await assert_betty_html( - project, "/citation/%s/index.html" % citation.id - ) - await assert_betty_json( - project, "/citation/%s/index.json" % citation.id - ) + await assert_betty_html(project, f"/citation/{citation.id}/index.html") + await assert_betty_json(project, f"/citation/{citation.id}/index.json") async def test_sources(self) -> None: async with App.new_temporary() as app, app, Project.new_temporary( @@ -352,8 +348,8 @@ async def test_source(self) -> None: project.ancestry.add(source) async with project: await generate(project) - await assert_betty_html(project, "/source/%s/index.html" % source.id) - await assert_betty_json(project, "/source/%s/index.json" % source.id) + await assert_betty_html(project, f"/source/{source.id}/index.html") + await assert_betty_json(project, f"/source/{source.id}/index.json") class TestResourceOverride: diff --git a/betty/tests/test_wikipedia.py b/betty/tests/test_wikipedia.py index 7315dd329..d0188f546 100644 --- a/betty/tests/test_wikipedia.py +++ b/betty/tests/test_wikipedia.py @@ -715,7 +715,7 @@ async def test_populate_link_should_set_locale( new_temporary_app: App, ) -> None: m_retriever = mocker.patch("betty.wikipedia._Retriever") - link = Link("http://%s.wikipedia.org/wiki/Amsterdam" % page_language) + link = Link(f"http://{page_language}.wikipedia.org/wiki/Amsterdam") link.locale = locale async with Project.new_temporary(new_temporary_app) as project, project: sut = _Populator(project, m_retriever) diff --git a/betty/wikipedia.py b/betty/wikipedia.py index f7ea094b0..e2a023fe3 100644 --- a/betty/wikipedia.py +++ b/betty/wikipedia.py @@ -103,7 +103,7 @@ def url(self) -> str: """ The URL to the web page. """ - return "https://%s.wikipedia.org/wiki/%s" % (self.locale, self._name) + return f"https://{self.locale}.wikipedia.org/wiki/{self._name}" @property def title(self) -> str: