Fix all flake8 warnings from newer flake8-bugbear and flake8-comprehensions

Address warnings introduced by flake8-bugbear 24.12.12 and
flake8-comprehensions 3.16.0:

- C408: Replace dict()/list() calls with literal {} and []
- C413: Remove unnecessary list() around sorted()
- C414: Remove unnecessary list() inside sorted()
- C419: Suppress intentional list comprehension in all() (noqa)
- B001: Replace bare except with except Exception
- B006: Replace mutable default arguments with None
- B010: Replace setattr() with direct attribute assignment
- B017: Use RuntimeError instead of Exception in tests
- B019: Suppress lru_cache on methods for long-lived objects (noqa)
- B033: Remove duplicate item in set literal

Change-Id: If4693d3e946200bbc22f689f7b94da604addcb80
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/566321
Tested-by: Carlos Fernandez <carlosfsanz@meta.com>
Commit-Queue: Carlos Fernandez <carlosfsanz@meta.com>
Reviewed-by: Mike Frysinger <vapier@google.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
This commit is contained in:
Carlos Fernandez
2026-03-26 13:46:38 -07:00
committed by LUCI
parent 3f3c681a02
commit 573983948a
11 changed files with 39 additions and 30 deletions
+7 -5
View File
@@ -225,7 +225,7 @@ class ReviewableBranch:
@property
def unabbrev_commits(self):
r = dict()
r = {}
for commit in self.project.bare_git.rev_list(
not_rev(self.base), R_HEADS + self.name, "--"
):
@@ -553,7 +553,7 @@ class Project:
revisionExpr,
revisionId,
rebase=True,
groups=set(),
groups=None,
sync_c=False,
sync_s=False,
sync_tags=True,
@@ -605,7 +605,7 @@ class Project:
self.SetRevision(revisionExpr, revisionId=revisionId)
self.rebase = rebase
self.groups = groups
self.groups = groups if groups is not None else set()
self.sync_c = sync_c
self.sync_s = sync_s
self.sync_tags = sync_tags
@@ -943,7 +943,7 @@ class Project:
out.important("prior sync failed; rebase still in progress")
out.nl()
paths = list()
paths = []
paths.extend(di.keys())
paths.extend(df.keys())
paths.extend(do)
@@ -1257,7 +1257,7 @@ class Project:
submodules=False,
ssh_proxy=None,
clone_filter=None,
partial_clone_exclude=set(),
partial_clone_exclude=None,
clone_filter_for_depth=None,
):
"""Perform only the network IO portion of the sync process.
@@ -1310,6 +1310,8 @@ class Project:
if clone_bundle and os.path.exists(self.objdir):
clone_bundle = False
if partial_clone_exclude is None:
partial_clone_exclude = set()
if self.name in partial_clone_exclude:
clone_bundle = True
clone_filter = None