From 686721e91f3dddee3a3d55ced7308d0a159e9b7a Mon Sep 17 00:00:00 2001 From: Niels Thykier Date: Sun, 15 Apr 2018 10:11:52 +0000 Subject: [PATCH] Rewrite some set constructs The first case is to avoid a creating a list, which is then converted to a set only to throw away the list again. Here we can just create the set right away without a list inbetween. The second case is "if x in [...]:" is better written as "if x in {...}:" as sets provides faster "__contains__" (assuming you are on a "recent enough python3", which britney is). Signed-off-by: Niels Thykier --- britney2/policies/autopkgtest.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/britney2/policies/autopkgtest.py b/britney2/policies/autopkgtest.py index 18df899..d06ddc3 100644 --- a/britney2/policies/autopkgtest.py +++ b/britney2/policies/autopkgtest.py @@ -234,7 +234,7 @@ class AutopkgtestPolicy(BasePolicy): cloud_url = self.options.adt_ci_url + "packages/%(h)s/%(s)s/%(r)s/%(a)s" for (testsrc, testver) in sorted(pkg_arch_result): arch_results = pkg_arch_result[(testsrc, testver)] - r = set([v[0] for v in arch_results.values()]) + r = {v[0] for v in arch_results.values()} if 'REGRESSION' in r: verdict = PolicyVerdict.REJECTED_PERMANENTLY elif 'RUNNING' in r and verdict == PolicyVerdict.PASS: @@ -310,7 +310,7 @@ class AutopkgtestPolicy(BasePolicy): if self.options.adt_success_bounty and verdict == PolicyVerdict.PASS and src_has_own_test: excuse.add_bounty('autopkgtest', int(self.options.adt_success_bounty)) if self.options.adt_regression_penalty and \ - verdict in [PolicyVerdict.REJECTED_PERMANENTLY, PolicyVerdict.REJECTED_TEMPORARILY]: + verdict in {PolicyVerdict.REJECTED_PERMANENTLY, PolicyVerdict.REJECTED_TEMPORARILY}: excuse.add_penalty('autopkgtest', int(self.options.adt_regression_penalty)) # In case we give penalties instead of blocking, we must always pass verdict = PolicyVerdict.PASS