Browse Source

Merge "dict_object.keys() is not required for *in* operator"

tags/3.5.0
Zuul 5 months ago
parent
commit
6bb3f9d9ea

+ 4
- 4
tests/base.py View File

@@ -257,7 +257,7 @@ class FakeGerritChange(object):
257 257
                      'type': 'ADDED'},
258 258
                     {'file': 'README',
259 259
                      'type': 'MODIFIED'}]
260
-        for f in files.keys():
260
+        for f in files:
261 261
             ps_files.append({'file': f, 'type': 'ADDED'})
262 262
         d = {'approvals': [],
263 263
              'createdOn': time.time(),
@@ -416,7 +416,7 @@ class FakeGerritChange(object):
416 416
 
417 417
     def getSubmitRecords(self):
418 418
         status = {}
419
-        for cat in self.categories.keys():
419
+        for cat in self.categories:
420 420
             status[cat] = 0
421 421
 
422 422
         for a in self.patchsets[-1]['approvals']:
@@ -695,7 +695,7 @@ class FakeGerritConnection(gerritconnection.GerritConnection):
695 695
         # happens they can add their own verified event into the queue.
696 696
         # Nevertheless, we can update change with the new review in gerrit.
697 697
 
698
-        for cat in action.keys():
698
+        for cat in action:
699 699
             if cat != 'submit':
700 700
                 change.addApproval(cat, action[cat], username=self.user)
701 701
 
@@ -1155,7 +1155,7 @@ class FakeGithubConnection(githubconnection.GithubConnection):
1155 1155
         # simulate one installation per org
1156 1156
         orgs = {}
1157 1157
         latest_inst_id = 0
1158
-        for repo in self.github_data.repos.keys():
1158
+        for repo in self.github_data.repos:
1159 1159
             inst_id = orgs.get(repo[0])
1160 1160
             if not inst_id:
1161 1161
                 latest_inst_id += 1

+ 2
- 2
zuul/ansible/callback/zuul_stream.py View File

@@ -402,10 +402,10 @@ class CallbackModule(default.CallbackModule):
402 402
                     msg=result_dict['module_stderr'])
403 403
         elif result._task.action == 'debug':
404 404
             # this is a debug statement, handle it special
405
-            for key in [k for k in result_dict.keys()
405
+            for key in [k for k in result_dict
406 406
                         if k.startswith('_ansible')]:
407 407
                 del result_dict[key]
408
-            if 'changed' in result_dict.keys():
408
+            if 'changed' in result_dict:
409 409
                 del result_dict['changed']
410 410
             keyname = next(iter(result_dict.keys()))
411 411
             # If it has msg, that means it was like:

+ 1
- 1
zuul/cmd/client.py View File

@@ -308,7 +308,7 @@ class Client(zuul.cmd.ZuulApp):
308 308
             fields = all_fields.keys()
309 309
         else:
310 310
             fields = [f.strip().lower() for f in self.args.columns.split(',')
311
-                      if f.strip().lower() in all_fields.keys()]
311
+                      if f.strip().lower() in all_fields]
312 312
 
313 313
         table = prettytable.PrettyTable(
314 314
             field_names=[all_fields[f]['title'] for f in fields])

+ 4
- 4
zuul/cmd/migrate.py View File

@@ -182,7 +182,7 @@ def merge_project_dict(project_dicts, name, project):
182 182
         return
183 183
 
184 184
     old = project_dicts[name]
185
-    for key in project.keys():
185
+    for key in project:
186 186
         if key not in old:
187 187
             old[key] = project[key]
188 188
         elif isinstance(old[key], list):
@@ -212,7 +212,7 @@ def normalize_project_expansions():
212 212
     # Second, find out which projects need to expand a given template
213 213
     for job_name, project in copy.deepcopy(JOBS_FOR_EXPAND).items():
214 214
         # There is a job-level expansion for this one
215
-        if job_name in JOB_MATCHERS.keys():
215
+        if job_name in JOB_MATCHERS:
216 216
             continue
217 217
         for project_name, expansion in project.items():
218 218
             TEMPLATES_TO_EXPAND[project_name] = []
@@ -416,7 +416,7 @@ def expandYamlForTemplateJob(self, project, template, jobs_glob=None):
416 416
             and self.config.getboolean(
417 417
                 'job_builder', 'allow_empty_variables')
418 418
 
419
-        for key in template.keys():
419
+        for key in template:
420 420
             if key not in params:
421 421
                 params[key] = template[key]
422 422
 
@@ -1054,7 +1054,7 @@ class JobMapping:
1054 1054
 
1055 1055
     def _expandVars(self, info, match_dict):
1056 1056
         job_vars = info['vars'].copy()
1057
-        for key in job_vars.keys():
1057
+        for key in job_vars:
1058 1058
             job_vars[key] = job_vars[key].format(**match_dict)
1059 1059
         return job_vars
1060 1060
 

+ 1
- 1
zuul/configloader.py View File

@@ -1871,7 +1871,7 @@ class TenantParser(object):
1871 1871
                     layout.getJob(job.name)
1872 1872
                     job.validateReferences(layout)
1873 1873
 
1874
-        for project_name in layout.project_configs.keys():
1874
+        for project_name in layout.project_configs:
1875 1875
             for project_config in layout.project_configs[project_name]:
1876 1876
                 with reference_exceptions(
1877 1877
                         'project', project_config, layout.loading_errors):

+ 1
- 1
zuul/driver/gerrit/gerritconnection.py View File

@@ -798,7 +798,7 @@ class GerritConnection(BaseConnection):
798 798
             return branches
799 799
 
800 800
         refs = self.getInfoRefs(project)
801
-        heads = [str(k[len('refs/heads/'):]) for k in refs.keys()
801
+        heads = [str(k[len('refs/heads/'):]) for k in refs
802 802
                  if k.startswith('refs/heads/') and
803 803
                  GerritConnection._checkRefFormat(k)]
804 804
         self._project_branch_cache[project.name] = heads

+ 1
- 1
zuul/executor/client.py View File

@@ -320,7 +320,7 @@ class ExecutorClient(object):
320 320
             _fname = '%s:%s' % (
321 321
                 function_name,
322 322
                 executor_zone)
323
-            if _fname in functions.keys():
323
+            if _fname in functions:
324 324
                 function_name = _fname
325 325
             else:
326 326
                 self.log.warning(

+ 1
- 1
zuul/lib/statsd.py View File

@@ -50,7 +50,7 @@ def get_statsd(config, extra_keys=None):
50 50
             format_keys = copy.copy(keys)
51 51
 
52 52
             # we need to normalize all keys which go into the metric name
53
-            for key in format_keys.keys():
53
+            for key in format_keys:
54 54
                 normalized_value = normalize_statsd_name(format_keys[key])
55 55
                 format_keys[key] = normalized_value
56 56
 

Loading…
Cancel
Save