From b2ff630c9bb0e00d1a21b8e95f48b49b46f58614 Mon Sep 17 00:00:00 2001 From: Nicolas Dandrimont Date: Wed, 21 Jun 2023 13:57:27 +0200 Subject: [PATCH] debian: refactor inner loop slightly to help mypy mypy doesn't catch that multiple uses of `self.listed_origins[origin_url]` in the same statement should be identical. Using a temporary local variable for it seems to help. --- swh/lister/debian/lister.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/swh/lister/debian/lister.py b/swh/lister/debian/lister.py index 23d520a..4a6271e 100644 --- a/swh/lister/debian/lister.py +++ b/swh/lister/debian/lister.py @@ -232,11 +232,13 @@ class DebianLister(Lister[DebianListerState, DebianPageType]): self.package_versions[package_name] = set() # origin will be yielded at the end of that method - origins_to_send[origin_url] = self.listed_origins[origin_url] + current_origin = origins_to_send[origin_url] = self.listed_origins[ + origin_url + ] # update package versions data in parameter that will be provided # to the debian loader - self.listed_origins[origin_url].extra_loader_arguments["packages"].update( + current_origin.extra_loader_arguments["packages"].update( { package_version_key: { "name": package_name, @@ -246,14 +248,13 @@ class DebianLister(Lister[DebianListerState, DebianPageType]): } ) - if self.listed_origins[origin_url].last_update is None or ( + if current_origin.last_update is None or ( self.last_sources_update is not None - and self.last_sources_update # type: ignore - > self.listed_origins[origin_url].last_update + and self.last_sources_update > current_origin.last_update ): # update debian package last update if current processed sources index # has a greater modification date - self.listed_origins[origin_url].last_update = self.last_sources_update + current_origin.last_update = self.last_sources_update # add package version key to the set of found versions self.package_versions[package_name].add(package_version_key)