diff --git a/.ruff.toml b/.ruff.toml index a4bafb967..4977df4a2 100644 --- a/.ruff.toml +++ b/.ruff.toml @@ -22,6 +22,7 @@ ignore = [ 'D401', 'F501', 'PTH123', + 'SIM103', ] [lint.per-file-ignores] diff --git a/betty/tests/extension/cotton_candy/test_search.py b/betty/tests/extension/cotton_candy/test_search.py index 623276da5..7fdb5c8ba 100644 --- a/betty/tests/extension/cotton_candy/test_search.py +++ b/betty/tests/extension/cotton_candy/test_search.py @@ -28,7 +28,7 @@ async def test_build_empty(self, new_temporary_app: App) -> None: async for item in Index(project, Context(), DEFAULT_LOCALIZER).build() ] - assert [] == indexed + assert indexed == [] async def test_build_person_without_names(self, new_temporary_app: App) -> None: person_id = "P1" @@ -50,7 +50,7 @@ async def test_build_person_without_names(self, new_temporary_app: App) -> None: async for item in Index(project, Context(), DEFAULT_LOCALIZER).build() ] - assert [] == indexed + assert indexed == [] async def test_build_private_person(self, new_temporary_app: App) -> None: person_id = "P1" @@ -80,7 +80,7 @@ async def test_build_private_person(self, new_temporary_app: App) -> None: async for item in Index(project, Context(), DEFAULT_LOCALIZER).build() ] - assert [] == indexed + assert indexed == [] @pytest.mark.parametrize( ("expected", "locale"), @@ -270,7 +270,7 @@ async def test_build_private_place(self, new_temporary_app: App) -> None: async for item in Index(project, Context(), DEFAULT_LOCALIZER).build() ] - assert [] == indexed + assert indexed == [] async def test_build_file_without_description(self, new_temporary_app: App) -> None: file_id = "F1" @@ -295,7 +295,7 @@ async def test_build_file_without_description(self, new_temporary_app: App) -> N async for item in Index(project, Context(), DEFAULT_LOCALIZER).build() ] - assert [] == indexed + assert indexed == [] @pytest.mark.parametrize( ("expected", "locale"), @@ -354,4 +354,4 @@ async def test_build_private_file(self, new_temporary_app: App) -> None: async for item in Index(project, Context(), DEFAULT_LOCALIZER).build() ] - assert [] == indexed + assert indexed == [] diff --git a/betty/tests/extension/gramps/test_gui.py b/betty/tests/extension/gramps/test_gui.py index 2ad94109c..f03bb5c1b 100644 --- a/betty/tests/extension/gramps/test_gui.py +++ b/betty/tests/extension/gramps/test_gui.py @@ -97,4 +97,4 @@ async def test_remove_family_tree( betty_qtbot.mouse_click(widget._family_trees._family_trees_remove_buttons[0]) assert len(sut.configuration.family_trees) == 0 - assert [] == widget._family_trees._family_trees_remove_buttons + assert widget._family_trees._family_trees_remove_buttons == [] diff --git a/betty/tests/model/test___init__.py b/betty/tests/model/test___init__.py index 3dcb80e8c..1dd7d500c 100644 --- a/betty/tests/model/test___init__.py +++ b/betty/tests/model/test___init__.py @@ -231,7 +231,7 @@ async def test_clear(self) -> None: entity3 = SingleTypeEntityCollectionTestEntity() sut.add(entity1, entity2, entity3) sut.clear() - assert [] == list(sut) + assert list(sut) == [] async def test_list(self) -> None: sut = SingleTypeEntityCollection[Entity](Entity) @@ -423,7 +423,7 @@ async def test_remove(self) -> None: sut.remove(entity_one) assert [entity_other] == list(sut) sut.remove(entity_other) - assert [] == list(sut) + assert list(sut) == [] async def test_getitem_by_index(self) -> None: sut = MultipleTypesEntityCollection[Entity]() @@ -451,7 +451,7 @@ async def test_getitem_by_entity_type(self) -> None: assert [entity_one] == list(sut[MultipleTypesEntityCollectionTestEntityOne]) assert [entity_other] == list(sut[MultipleTypesEntityCollectionTestEntityOther]) # Ensure that getting previously unseen entity types automatically creates and returns a new collection. - assert [] == list(sut[Entity]) + assert list(sut[Entity]) == [] async def test_getitem_by_entity_type_name(self) -> None: sut = MultipleTypesEntityCollection[Entity]() @@ -1151,7 +1151,7 @@ async def test(self) -> None: del entity_many.one assert entity_many.one is None - assert [] == list(entity_one.many) # type: ignore[unreachable] + assert list(entity_one.many) == [] # type: ignore[unreachable] @to_many( @@ -1182,7 +1182,7 @@ async def test(self) -> None: assert [entity_many] == list(entity_one.many) entity_one.many.remove(entity_many) - assert [] == list(entity_one.many) + assert list(entity_one.many) == [] @one_to_many( @@ -1220,7 +1220,7 @@ async def test(self) -> None: assert entity_one is entity_many.one entity_one.many.remove(entity_many) - assert [] == list(entity_one.many) + assert list(entity_one.many) == [] assert entity_many.one is None @@ -1259,8 +1259,8 @@ async def test(self) -> None: assert [entity_many] == list(entity_other_many.many) entity_many.other_many.remove(entity_other_many) - assert [] == list(entity_many.other_many) - assert [] == list(entity_other_many.many) + assert list(entity_many.other_many) == [] + assert list(entity_other_many.many) == [] @many_to_one_to_many( diff --git a/betty/tests/model/test_ancestry.py b/betty/tests/model/test_ancestry.py index 02e6c9735..f433999e2 100644 --- a/betty/tests/model/test_ancestry.py +++ b/betty/tests/model/test_ancestry.py @@ -311,7 +311,7 @@ class HasNotesTestEntity(HasNotes, Entity): class TestHasNotes: async def test_notes(self) -> None: sut = HasNotesTestEntity() - assert [] == list(sut.notes) + assert list(sut.notes) == [] class TestDescribed: @@ -401,7 +401,7 @@ class _HasLinks(HasLinks): pass sut = _HasLinks() - assert [] == sut.links + assert sut.links == [] class _HasFiles(HasFiles, Entity): @@ -487,7 +487,7 @@ async def test_notes(self) -> None: id=file_id, path=file_path, ) - assert [] == list(sut.notes) + assert list(sut.notes) == [] notes = [Note(text=""), Note(text="")] sut.notes = notes # type: ignore[assignment] assert notes == list(sut.notes) @@ -499,7 +499,7 @@ async def test_entities(self) -> None: id=file_id, path=file_path, ) - assert [] == list(sut.entities) + assert list(sut.entities) == [] entities = [_HasFiles(), _HasFiles()] sut.entities = entities # type: ignore[assignment] @@ -512,7 +512,7 @@ async def test_citations(self) -> None: id=file_id, path=file_path, ) - assert [] == list(sut.citations) + assert list(sut.citations) == [] async def test_dump_linked_data_should_dump_minimal(self) -> None: with NamedTemporaryFile() as f: @@ -672,7 +672,7 @@ async def test_dump_linked_data_should_dump_private(self) -> None: class TestHasFiles: async def test_files(self) -> None: sut = _HasFiles() - assert [] == list(sut.files) + assert list(sut.files) == [] files = [File(path=Path()), File(path=Path())] sut.files = files # type: ignore[assignment] assert files == list(sut.files) @@ -699,13 +699,13 @@ async def test_contained_by(self) -> None: async def test_contains(self) -> None: contains_source = Source() sut = Source() - assert [] == list(sut.contains) + assert list(sut.contains) == [] sut.contains = [contains_source] # type: ignore[assignment] assert [contains_source] == list(sut.contains) async def test_walk_contains_without_contains(self) -> None: sut = Source() - assert [] == list(sut.walk_contains) + assert list(sut.walk_contains) == [] async def test_walk_contains_with_contains(self) -> None: sut = Source() @@ -715,7 +715,7 @@ async def test_walk_contains_with_contains(self) -> None: async def test_citations(self) -> None: sut = Source() - assert [] == list(sut.citations) + assert list(sut.citations) == [] async def test_author(self) -> None: sut = Source() @@ -737,11 +737,11 @@ async def test_date(self) -> None: async def test_files(self) -> None: sut = Source() - assert [] == list(sut.files) + assert list(sut.files) == [] async def test_links(self) -> None: sut = Source() - assert [] == list(sut.links) + assert list(sut.links) == [] async def test_private(self) -> None: sut = Source() @@ -976,7 +976,7 @@ async def test_id(self) -> None: async def test_facts(self) -> None: fact = _HasCitations() sut = Citation(source=Source()) - assert [] == list(sut.facts) + assert list(sut.facts) == [] sut.facts = [fact] # type: ignore[assignment] assert [fact] == list(sut.facts) @@ -998,7 +998,7 @@ async def test_date(self) -> None: async def test_files(self) -> None: sut = Citation(source=Source()) - assert [] == list(sut.files) + assert list(sut.files) == [] async def test_private(self) -> None: sut = Citation(source=Source()) @@ -1131,7 +1131,7 @@ async def test_dump_linked_data_should_dump_private(self) -> None: class TestHasCitations: async def test_citations(self) -> None: sut = _HasCitations() - assert [] == list(sut.citations) + assert list(sut.citations) == [] citation = Citation(source=Source()) sut.citations = [citation] # type: ignore[assignment] assert [citation] == list(sut.citations) @@ -1250,7 +1250,7 @@ async def test_events(self) -> None: assert event in sut.events assert sut == event.place sut.events.remove(event) - assert [] == list(sut.events) + assert list(sut.events) == [] assert event.place is None async def test_enclosed_by(self) -> None: @@ -1258,7 +1258,7 @@ async def test_enclosed_by(self) -> None: id="P1", names=[PlaceName(name="The Place")], ) - assert [] == list(sut.enclosed_by) + assert list(sut.enclosed_by) == [] enclosing_place = Place( id="P2", names=[PlaceName(name="The Other Place")], @@ -1267,7 +1267,7 @@ async def test_enclosed_by(self) -> None: assert enclosure in sut.enclosed_by assert sut == enclosure.encloses sut.enclosed_by.remove(enclosure) - assert [] == list(sut.enclosed_by) + assert list(sut.enclosed_by) == [] assert enclosure.encloses is None async def test_encloses(self) -> None: @@ -1275,7 +1275,7 @@ async def test_encloses(self) -> None: id="P1", names=[PlaceName(name="The Place")], ) - assert [] == list(sut.encloses) + assert list(sut.encloses) == [] enclosed_place = Place( id="P2", names=[PlaceName(name="The Other Place")], @@ -1284,7 +1284,7 @@ async def test_encloses(self) -> None: assert enclosure in sut.encloses assert sut == enclosure.enclosed_by sut.encloses.remove(enclosure) - assert [] == list(sut.encloses) + assert list(sut.encloses) == [] assert enclosure.enclosed_by is None async def test_walk_encloses_without_encloses(self) -> None: @@ -1292,7 +1292,7 @@ async def test_walk_encloses_without_encloses(self) -> None: id="P1", names=[PlaceName(name="The Place")], ) - assert [] == list(sut.walk_encloses) + assert list(sut.walk_encloses) == [] async def test_walk_encloses_with_encloses(self) -> None: sut = Place( @@ -1324,7 +1324,7 @@ async def test_links(self) -> None: id="P1", names=[PlaceName(name="The Place")], ) - assert [] == list(sut.links) + assert list(sut.links) == [] async def test_names(self) -> None: name = PlaceName(name="The Place") @@ -1565,7 +1565,7 @@ async def test_presences(self) -> None: assert [presence] == list(sut.presences) assert sut == presence.event sut.presences.remove(presence) - assert [] == list(sut.presences) + assert list(sut.presences) == [] assert presence.event is None async def test_date(self) -> None: @@ -1577,11 +1577,11 @@ async def test_date(self) -> None: async def test_files(self) -> None: sut = Event(event_type=UnknownEventType) - assert [] == list(sut.files) + assert list(sut.files) == [] async def test_citations(self) -> None: sut = Event(event_type=UnknownEventType) - assert [] == list(sut.citations) + assert list(sut.citations) == [] async def test_description(self) -> None: sut = Event(event_type=UnknownEventType) @@ -1830,7 +1830,7 @@ async def test_citations(self) -> None: individual="Janet", affiliation="Not a Girl", ) - assert [] == list(sut.citations) + assert list(sut.citations) == [] async def test_individual(self) -> None: person = Person(id="1") @@ -1861,8 +1861,8 @@ async def test_parents(self) -> None: assert [parent] == list(sut.parents) assert [sut] == list(parent.children) sut.parents.remove(parent) - assert [] == list(sut.parents) - assert [] == list(parent.children) + assert list(sut.parents) == [] + assert list(parent.children) == [] async def test_children(self) -> None: sut = Person(id="1") @@ -1871,8 +1871,8 @@ async def test_children(self) -> None: assert [child] == list(sut.children) assert [sut] == list(child.parents) sut.children.remove(child) - assert [] == list(sut.children) - assert [] == list(child.parents) + assert list(sut.children) == [] + assert list(child.parents) == [] async def test_presences(self) -> None: event = Event(event_type=Birth) @@ -1882,7 +1882,7 @@ async def test_presences(self) -> None: assert [presence] == list(sut.presences) assert sut == presence.person sut.presences.remove(presence) - assert [] == list(sut.presences) + assert list(sut.presences) == [] assert presence.person is None async def test_names(self) -> None: @@ -1895,7 +1895,7 @@ async def test_names(self) -> None: assert [name] == list(sut.names) assert sut == name.person sut.names.remove(name) - assert [] == list(sut.names) + assert list(sut.names) == [] assert name.person is None async def test_id(self) -> None: @@ -1905,15 +1905,15 @@ async def test_id(self) -> None: async def test_files(self) -> None: sut = Person(id="1") - assert [] == list(sut.files) + assert list(sut.files) == [] async def test_citations(self) -> None: sut = Person(id="1") - assert [] == list(sut.citations) + assert list(sut.citations) == [] async def test_links(self) -> None: sut = Person(id="1") - assert [] == list(sut.links) + assert list(sut.links) == [] async def test_private(self) -> None: sut = Person(id="1") @@ -1921,7 +1921,7 @@ async def test_private(self) -> None: async def test_siblings_without_parents(self) -> None: sut = Person(id="person") - assert [] == list(sut.siblings) + assert list(sut.siblings) == [] async def test_siblings_with_one_common_parent(self) -> None: sut = Person(id="1") @@ -1939,7 +1939,7 @@ async def test_siblings_with_multiple_common_parents(self) -> None: async def test_ancestors_without_parents(self) -> None: sut = Person(id="person") - assert [] == list(sut.ancestors) + assert list(sut.ancestors) == [] async def test_ancestors_with_parent(self) -> None: sut = Person(id="1") @@ -1951,7 +1951,7 @@ async def test_ancestors_with_parent(self) -> None: async def test_descendants_without_parents(self) -> None: sut = Person(id="person") - assert [] == list(sut.descendants) + assert list(sut.descendants) == [] async def test_descendants_with_parent(self) -> None: sut = Person(id="1") diff --git a/betty/tests/project/test___init__.py b/betty/tests/project/test___init__.py index 645d08044..d3021802a 100644 --- a/betty/tests/project/test___init__.py +++ b/betty/tests/project/test___init__.py @@ -1036,9 +1036,9 @@ async def test_dump_should_dump_locale_locale(self) -> None: sut.locales.append(locale_configuration) sut.locales.remove("en-US") dump: Any = sut.dump() - assert { + assert dump["locales"] == { locale: {}, - } == dump["locales"] + } async def test_dump_should_dump_locale_alias(self) -> None: locale = "nl-NL" @@ -1051,11 +1051,11 @@ async def test_dump_should_dump_locale_alias(self) -> None: sut.locales.append(locale_configuration) sut.locales.remove("en-US") dump: Any = sut.dump() - assert { + assert dump["locales"] == { locale: { "alias": alias, }, - } == dump["locales"] + } async def test_dump_should_dump_root_path(self) -> None: root_path = "betty" diff --git a/betty/tests/project/test_extension.py b/betty/tests/project/test_extension.py index e329bc520..5ebc4b5f9 100644 --- a/betty/tests/project/test_extension.py +++ b/betty/tests/project/test_extension.py @@ -58,7 +58,7 @@ async def test(self, new_temporary_app: App) -> None: class TestBuildExtensionTypeGraph: async def test_without_extension_types(self) -> None: - assert {} == build_extension_type_graph(set()) + assert build_extension_type_graph(set()) == {} async def test_with_isolated_extension_types(self) -> None: class IsolatedExtensionOne(Extension): diff --git a/betty/tests/serde/test_error.py b/betty/tests/serde/test_error.py index 353ec4726..cad1cb4ef 100644 --- a/betty/tests/serde/test_error.py +++ b/betty/tests/serde/test_error.py @@ -22,9 +22,9 @@ async def test_with_context(self) -> None: sut = SerdeError(Str.plain("Something went wrong!")) sut_with_context = sut.with_context(Str.plain("Somewhere, at some point...")) assert sut != sut_with_context - assert ["Somewhere, at some point..."] == [ + assert [ context.localize(DEFAULT_LOCALIZER) for context in sut_with_context.contexts - ] + ] == ["Somewhere, at some point..."] class TestSerdeErrorCollection: @@ -80,9 +80,9 @@ async def test_with_context(self) -> None: sut = SerdeErrorCollection() sut_with_context = sut.with_context(Str.plain("Somewhere, at some point...")) assert sut is not sut_with_context - assert ["Somewhere, at some point..."] == [ + assert [ context.localize(DEFAULT_LOCALIZER) for context in sut_with_context.contexts - ] + ] == ["Somewhere, at some point..."] async def test_catch_without_contexts(self) -> None: sut = SerdeErrorCollection() diff --git a/betty/tests/test_config.py b/betty/tests/test_config.py index 1ce338465..0375e949b 100644 --- a/betty/tests/test_config.py +++ b/betty/tests/test_config.py @@ -133,13 +133,13 @@ async def test_delitem(self) -> None: configuration = self.get_configurations()[0] sut = self.get_sut([configuration]) del sut[self.get_configuration_keys()[0]] - assert [] == list(sut.values()) + assert list(sut.values()) == [] async def test_iter(self) -> None: configurations = self.get_configurations() sut = self.get_sut(configurations) assert tuple(iter(sut)) == configurations - assert [] == list(sut.values()) + assert list(sut.values()) == [] async def test_len(self) -> None: configurations = self.get_configurations() diff --git a/betty/tests/test_wikipedia.py b/betty/tests/test_wikipedia.py index 8288989c7..23638711b 100644 --- a/betty/tests/test_wikipedia.py +++ b/betty/tests/test_wikipedia.py @@ -246,7 +246,7 @@ async def test_get_translations_with_invalid_json_response_should_return_none( } ) actual = await _Retriever(fetcher).get_translations(page_language, page_name) - assert {} == actual + assert actual == {} @pytest.mark.parametrize( "response_json", @@ -271,7 +271,7 @@ async def test_get_translations_with_unexpected_json_response_should_return_none fetch_map={fetch_url: _new_json_fetch_response(response_json)} ) actual = await _Retriever(fetcher).get_translations(page_language, page_name) - assert {} == actual + assert actual == {} @pytest.mark.parametrize( ("expected", "fetch_json"), @@ -836,7 +836,7 @@ async def test_populate_should_ignore_resource_without_links( async with project: sut = _Populator(project, m_retriever) await sut.populate() - assert [] == resource.links + assert resource.links == [] async def test_populate_should_ignore_non_wikipedia_links( self, mocker: MockerFixture, new_temporary_app: App diff --git a/pyproject.toml b/pyproject.toml index 88cc0049d..81c31313c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -123,7 +123,7 @@ test = [ 'pytest-mock ~= 3.10, >= 3.10.0', 'pytest-qt ~= 4.2, >= 4.2.0', 'pytest-xvfb ~= 3.0, >= 3.0.0', - 'ruff ~= 0.4.4', + 'ruff ~= 0.5', 'types-aiofiles ~= 24.1', 'types-babel ~= 2.11, >= 2.11.0.15', 'types-click ~= 7.1, >= 7.1.8',