autoimport: avoid changing variable type
authorHelmut Grohne <helmut@subdivi.de>
Wed, 29 Dec 2021 20:05:58 +0000 (21:05 +0100)
committerHelmut Grohne <helmut@subdivi.de>
Wed, 29 Dec 2021 20:05:58 +0000 (21:05 +0100)
knownpkgvers is a dict while knownpkgs is a set. Separating them helps
static type checkers.

autoimport.py

index d9ee0a3..eb610b4 100755 (executable)
@@ -104,14 +104,15 @@ def main():
 
     print("reading database")
     cur.execute("SELECT name, version FROM package;")
-    knownpkgs = dict((row[0], row[1]) for row in cur.fetchall())
+    knownpkgvers = dict((row[0], row[1]) for row in cur.fetchall())
     distpkgs = set(pkgs.keys())
     if args.new:
         for name in distpkgs:
-            if name in knownpkgs and version_compare(pkgs[name]["version"],
-                    knownpkgs[name]) <= 0:
+            if name in knownpkgvers and \
+               version_compare(pkgs[name]["version"], knownpkgvers[name]) <= 0:
                 del pkgs[name]
-    knownpkgs = set(knownpkgs)
+    knownpkgs = set(knownpkgvers)
+    del knownpkgvers
 
     with e:
         fs = {}