#107 Fix redundant type changes.
Merged 4 years ago by pingou. Opened 4 years ago by qulogic.
qulogic/mdapi iterables  into  master

file modified
+5 -7
@@ -213,15 +213,13 @@ 

          query = queries.get(table, default_query).format(table=table)

          for i, row in enumerate(conn.execute(query)):

              if table in cache_dependant_tables:

-                 row = list(row)  # lists support item assignment

                  if row[0] in cache:

-                     row[0] = cache[row[0]]

-                     yield tuple(row)

+                     yield (cache[row[0]], *row[1:])

                  else:

                      print(f"{name.ljust(padding)} ! {row[0]!r} does not appear in the "

                            f"{table!r} cache for {uri}. Dropping from comparison.")

              else:

-                 yield tuple(row)

+                 yield row

          conn.close()

  

      def build_cache(uri, cache):
@@ -278,10 +276,10 @@ 

          if table in cache_producing_tables:

              build_cache(db1, cache1)

              build_cache(db2, cache2)

-         rows1 = set(list(get_all_rows(db1, table, cache1)))

-         rows2 = set(list(get_all_rows(db2, table, cache2)))

+         rows1 = set(get_all_rows(db1, table, cache1))

+         rows2 = set(get_all_rows(db2, table, cache2))

          changed = rows1.symmetric_difference(rows2)

-         results.update(set([row_to_package(row) for row in changed]))

+         results.update({row_to_package(row) for row in changed})

  

      return results

  

file modified
+1 -3
@@ -152,9 +152,7 @@ 

              if pkg.rpm_sourcerpm:

                  async with db.execute(GET_CO_PACKAGE, (pkg.rpm_sourcerpm,)) as cursor:

                      copkgs = await cursor.fetchall()

-                 out['co-packages'] = list(set([

-                     cpkg[2] for cpkg in copkgs

-                 ]))

+                 out['co-packages'] = list({cpkg[2] for cpkg in copkgs})

              else:

                  out['co-packages'] = []

              out['repo'] = repotype if repotype else 'release'

file modified
+2 -2
@@ -64,13 +64,13 @@ 

      ''' Return the list of all branches currently supported by mdapi

      '''

      _log.info(f'list_branches: {request}')

-     output = sorted(list(set([

+     output = sorted({

          # Remove the front part `mdapi-` and the end part -<type>.sqlite

          filename.replace('mdapi-', '').rsplit('-', 2)[0].replace(

              '-updates', '')

          for filename in os.listdir(CONFIG['DB_FOLDER'])

          if filename.startswith('mdapi') and filename.endswith('.sqlite')

-     ])))

+     })

  

      return web.json_response(output)

  

Most of these accept iterables, so there's no need to make them into a list first.

rebased onto 03321dd

4 years ago

rebased onto 7556e31

4 years ago

Pull-Request has been merged by pingou

4 years ago