From fea4e333be7c4baa4e46149aed4e408760b1b3f8 Mon Sep 17 00:00:00 2001 From: Matthieu Caneill Date: Wed, 17 Apr 2024 23:37:40 +0200 Subject: [PATCH] Run latest black improvements on Python files --- lib/debsources/archiver.py | 2 +- lib/debsources/db_storage.py | 2 +- lib/debsources/mainlib.py | 4 ++-- lib/debsources/plugins/hook_checksums.py | 2 +- lib/debsources/plugins/hook_copyright.py | 2 +- lib/debsources/plugins/hook_sloccount.py | 2 +- lib/debsources/query.py | 7 +++---- lib/debsources/tests/test_archiver.py | 1 - lib/debsources/tests/test_paths.py | 2 +- lib/debsources/tests/test_queries.py | 12 ++++++------ lib/debsources/updater.py | 10 +++++----- 11 files changed, 22 insertions(+), 24 deletions(-) diff --git a/lib/debsources/archiver.py b/lib/debsources/archiver.py index 079f968d..0834061f 100644 --- a/lib/debsources/archiver.py +++ b/lib/debsources/archiver.py @@ -102,7 +102,7 @@ def add_suite(conf, session, suite, archive): if updater.STAGE_SUITES in conf["stages"]: suitemap_q = sql.insert(Suite.__table__) suitemaps = [] - for (pkg, version) in archive.suites[suite]: + for pkg, version in archive.suites[suite]: db_package = db_storage.lookup_package(session, pkg, version) if not db_package: logging.warn( diff --git a/lib/debsources/db_storage.py b/lib/debsources/db_storage.py index 00eb22c7..c52b0ac7 100644 --- a/lib/debsources/db_storage.py +++ b/lib/debsources/db_storage.py @@ -57,7 +57,7 @@ def add_package(session, pkg, pkgdir, sticky=False): # add individual source files to the File table file_table = {} - for (relpath, _abspath) in fs_storage.walk_pkg_files(pkgdir): + for relpath, _abspath in fs_storage.walk_pkg_files(pkgdir): file = File(db_package, relpath) session.add(file) session.flush() diff --git a/lib/debsources/mainlib.py b/lib/debsources/mainlib.py index 2e78d4c5..602424d6 100644 --- a/lib/debsources/mainlib.py +++ b/lib/debsources/mainlib.py @@ -97,7 +97,7 @@ def _to_path(key, value): def parse_conf_infra(items): """returns correct typing for the [infra] section""" typed = {} - for (key, value) in items: + for key, value in items: if key == "expire_days": value = int(value) elif key == "dry_run": @@ -123,7 +123,7 @@ def parse_conf_infra(items): def parse_conf_webapp(items): """returns correct typing for the [webapp] section""" typed = {} - for (key, value) in items: + for key, value in items: if value.lower() == "false": value = False elif value.lower() == "true": diff --git a/lib/debsources/plugins/hook_checksums.py b/lib/debsources/plugins/hook_checksums.py index 4662314f..8809105a 100644 --- a/lib/debsources/plugins/hook_checksums.py +++ b/lib/debsources/plugins/hook_checksums.py @@ -82,7 +82,7 @@ def emit_checksum(out, relpath, abspath): # ASSUMPTION: if *a* checksum of this package has already # been added to the db in the past, then *all* of them have, # as additions are part of the same transaction - for (sha256, relpath) in parse_checksums(sumsfile): + for sha256, relpath in parse_checksums(sumsfile): params = {"package_id": db_package.id, "sha256": sha256} if file_table: try: diff --git a/lib/debsources/plugins/hook_copyright.py b/lib/debsources/plugins/hook_copyright.py index 98d5b0c7..3ebe9366 100644 --- a/lib/debsources/plugins/hook_copyright.py +++ b/lib/debsources/plugins/hook_copyright.py @@ -84,7 +84,7 @@ def emit_license(out, package, version, relpath, copyright): # added to the db in the past, then *all* of them have, as # additions are part of the same transaction licenses = parse_license_file(license_file) - for (synopsis, path) in licenses: + for synopsis, path in licenses: if file_table: try: file_id = file_table[path] diff --git a/lib/debsources/plugins/hook_sloccount.py b/lib/debsources/plugins/hook_sloccount.py index fa058262..0c7ce177 100644 --- a/lib/debsources/plugins/hook_sloccount.py +++ b/lib/debsources/plugins/hook_sloccount.py @@ -97,7 +97,7 @@ def add_package(session, pkg, pkgdir, file_table): # ASSUMPTION: if *a* loc count of this package has already been # added to the db in the past, then *all* of them have, as # additions are part of the same transaction - for (lang, locs) in slocs.items(): + for lang, locs in slocs.items(): sloccount = SlocCount(db_package, lang, locs) session.add(sloccount) diff --git a/lib/debsources/query.py b/lib/debsources/query.py index 15ba37db..b5ccf49e 100644 --- a/lib/debsources/query.py +++ b/lib/debsources/query.py @@ -174,12 +174,12 @@ def location_get_path_links(endpoint, path_to: Path): # This hack is similar to the one in helper.py in redirect_to_url function if endpoint == ".versions": - for (i, p) in enumerate(path_dict): + for i, p in enumerate(path_dict): pathl.append( (p, url_for(endpoint, packagename="/".join(path_dict[: i + 1]))) ) else: - for (i, p) in enumerate(path_dict): + for i, p in enumerate(path_dict): pathl.append((p, url_for(endpoint, path_to="/".join(path_dict[: i + 1])))) return pathl @@ -216,7 +216,7 @@ def location_get_stat(sources_path): file_type = sign break file_perms = "" - for (flag, do_true, do_false) in perm_flags: + for flag, do_true, do_false in perm_flags: file_perms += do_true if (sources_mode & flag) else do_false file_size = sources_size @@ -353,7 +353,6 @@ def get_files_by_checksum(session, checksum, package=None, suite=None): ) if package is not None and package != "": - results = results.filter(PackageName.name == package) if suite is not None and suite != "": diff --git a/lib/debsources/tests/test_archiver.py b/lib/debsources/tests/test_archiver.py index 0c1d0324..9635a2ea 100644 --- a/lib/debsources/tests/test_archiver.py +++ b/lib/debsources/tests/test_archiver.py @@ -30,7 +30,6 @@ @attr("infra") @attr("postgres") class Archiver(unittest.TestCase, DbTestFixture): - TEST_STAGES = set([updater.STAGE_EXTRACT, updater.STAGE_SUITES, updater.STAGE_GC]) def setUp(self): diff --git a/lib/debsources/tests/test_paths.py b/lib/debsources/tests/test_paths.py index c0f99d7f..2a9fb289 100644 --- a/lib/debsources/tests/test_paths.py +++ b/lib/debsources/tests/test_paths.py @@ -78,7 +78,7 @@ def tearDownClass(cls): cls.db_teardown_cls() def test_sqlalchemy_path(self): - for (path, path_bytes) in [ + for path, path_bytes in [ (Path("/hello") / "world", b"/hello/world"), (Path("\udcff"), b"\xff"), # non utf8, surrogateescape ]: diff --git a/lib/debsources/tests/test_queries.py b/lib/debsources/tests/test_queries.py index b7cdcb5e..2ffcdcfa 100644 --- a/lib/debsources/tests/test_queries.py +++ b/lib/debsources/tests/test_queries.py @@ -85,7 +85,7 @@ def test_list_versions(self): # Test returning suites without suit as parameter self.assertTrue( - {"suites": [u"wheezy"], "version": u"0.90+20120429-1", "area": u"main"} + {"suites": ["wheezy"], "version": "0.90+20120429-1", "area": "main"} in qry.pkg_names_list_versions_w_suites(self.session, "gnubg") ) @@ -94,9 +94,9 @@ def test_list_versions(self): qry.pkg_names_list_versions_w_suites(self.session, "gnubg", "jessie"), [ { - "suites": [u"jessie", u"sid"], - "version": u"1.02.000-2", - "area": u"main", + "suites": ["jessie", "sid"], + "version": "1.02.000-2", + "area": "main", } ], ) @@ -110,8 +110,8 @@ def test_find_ctag(self): { "path": Path("eval.c"), "line": 1747, - "version": u"0.90+20091206-4", - "package": u"gnubg", + "version": "0.90+20091206-4", + "package": "gnubg", } in ctags[1] ) diff --git a/lib/debsources/updater.py b/lib/debsources/updater.py index 6fe352ac..52d798c8 100644 --- a/lib/debsources/updater.py +++ b/lib/debsources/updater.py @@ -143,7 +143,7 @@ def notify_plugins( If triggers is not None, only Python hooks whose names are listed in them will be triggered. Note: shell hooks will not be triggered in that case. """ - for (title, action) in observers[event]: + for title, action in observers[event]: try: if triggers is None: action(session, pkg, pkgdir, file_table) @@ -386,7 +386,7 @@ def update_suites(status, conf, session, mirror): if not conf["dry_run"] and "db" in conf["backends"]: session.query(SuiteAlias).delete() - for (suite, pkgs) in mirror.suites.items(): + for suite, pkgs in mirror.suites.items(): if not conf["dry_run"] and "db" in conf["backends"]: session.query(Suite).filter_by(suite=suite).delete() for pkg_id in pkgs: @@ -632,7 +632,7 @@ def update_charts(status, conf, session, suites=None): # size charts, various metrics for metric in ["source_packages", "disk_usage", "source_files", "ctags"]: - for (period, granularity) in CHARTS: + for period, granularity in CHARTS: for suite in suites + ["ALL"]: series = getattr(statistics, "history_size_" + granularity)( session, metric, interval=period, suite=suite @@ -643,7 +643,7 @@ def update_charts(status, conf, session, suites=None): charts.size_plot(series, chart_file) # sloccount: historical histograms - for (period, granularity) in CHARTS: + for period, granularity in CHARTS: for suite in suites + ["ALL"]: # historical histogram mseries = getattr(statistics, "history_sloc_" + granularity)( @@ -678,7 +678,7 @@ def update_charts(status, conf, session, suites=None): def update_license_charts(): # License: historical histogramms - for (period, granularity) in CHARTS: + for period, granularity in CHARTS: for suite in suites + ["ALL"]: mseries = getattr(statistics, "history_copyright_" + granularity)( session, interval=period, suite=suite