Bug 1681096 - python3 - pylint --py3k - W1620: Calling a dict.iter*() method (dict-iter-method) r=marionette-reviewers,perftest-reviewers,jmaher,jgraham,AlexandruIonescu
authorBob Clary <bclary@bclary.com>
Wed, 09 Dec 2020 09:02:22 +0000
changeset 560751 68f9d997f40ee332c331cb6fbc90d34a6132dc88
parent 560750 03e46a1ed9c18dfee6002d37044d4a052cdeb956
child 560752 785e060f126695071633321c7a97e3f34b45df0c
push id38033
push userdluca@mozilla.com
push dateTue, 15 Dec 2020 21:34:27 +0000
treeherdermozilla-central@914398229db8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmarionette-reviewers, perftest-reviewers, jmaher, jgraham, AlexandruIonescu
bugs1681096
milestone86.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1681096 - python3 - pylint --py3k - W1620: Calling a dict.iter*() method (dict-iter-method) r=marionette-reviewers,perftest-reviewers,jmaher,jgraham,AlexandruIonescu Differential Revision: https://phabricator.services.mozilla.com/D99049
testing/awsy/awsy/process_perf_data.py
testing/awsy/mach_commands.py
testing/firefox-ui/mach_commands.py
testing/mochitest/mach_test_package_commands.py
testing/mozbase/docs/_static/structured_example.py
testing/mozharness/mozharness/base/script.py
testing/mozharness/mozharness/mozilla/testing/try_tools.py
testing/raptor/raptor/cmdline.py
testing/raptor/raptor/output.py
testing/raptor/raptor/results.py
testing/tps/create_venv.py
--- a/testing/awsy/awsy/process_perf_data.py
+++ b/testing/awsy/awsy/process_perf_data.py
@@ -1,15 +1,16 @@
 #!/usr/bin/env python
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from __future__ import absolute_import, division, print_function
 
+import six
 import os
 import sys
 import json
 import math
 import glob
 
 AWSY_PATH = os.path.dirname(os.path.realpath(__file__))
 if AWSY_PATH not in sys.path:
@@ -156,17 +157,17 @@ def create_suite(
             # with RSS + USS of e10s).
             totals_rss = parse_about_memory.calculate_memory_report_values(
                 memory_report_path, node, ["Main"]
             )
             totals_uss = parse_about_memory.calculate_memory_report_values(
                 memory_report_path, "resident-unique"
             )
             value = list(totals_rss.values())[0] + sum(
-                [v for k, v in totals_uss.iteritems() if "Main" not in k]
+                [v for k, v in six.iteritems(totals_uss) if "Main" not in k]
             )
 
         subtest = {
             "name": checkpoint["name"],
             "value": value,
             "lowerIsBetter": True,
             "unit": "bytes",
         }
--- a/testing/awsy/mach_commands.py
+++ b/testing/awsy/mach_commands.py
@@ -183,17 +183,17 @@ class MachCommands(MachCommandBase):
                 #   Name.app/Contents/MacOS/libdmd.dylib
                 #   Name.app/Contents/Resources/dmd.py
                 bin_dir = os.path.join(bin_dir, "../Resources/")
 
             # Also add the bin dir to the python path so we can use dmd.py
             if bin_dir not in sys.path:
                 sys.path.append(bin_dir)
 
-        for k, v in kwargs.iteritems():
+        for k, v in six.iteritems(kwargs):
             setattr(args, k, v)
 
         parser.verify_usage(args)
 
         args.logger = commandline.setup_logging(
             "Are We Slim Yet Tests", args, {"mach": sys.stdout}
         )
         failed = MarionetteHarness(MarionetteTestRunner, args=vars(args)).run()
--- a/testing/firefox-ui/mach_commands.py
+++ b/testing/firefox-ui/mach_commands.py
@@ -1,14 +1,15 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from __future__ import absolute_import, unicode_literals
 
+import six
 import logging
 import os
 import sys
 
 from mozbuild.base import (
     MachCommandBase,
     MachCommandConditions as conditions,
     BinaryNotFoundException,
@@ -68,17 +69,17 @@ def run_firefox_ui_test(testtype=None, t
     kwargs["logger"] = kwargs.pop("log", None)
     if not kwargs["logger"]:
         kwargs["logger"] = commandline.setup_logging(
             "Firefox UI - {} Tests".format(testtype), {"mach": sys.stdout}
         )
 
     args = Namespace()
 
-    for k, v in kwargs.iteritems():
+    for k, v in six.iteritems(kwargs):
         setattr(args, k, v)
 
     parser.verify_usage(args)
 
     failed = test_types[testtype]["cli_module"].cli(args=vars(args))
 
     if failed > 0:
         return 1
--- a/testing/mochitest/mach_test_package_commands.py
+++ b/testing/mochitest/mach_test_package_commands.py
@@ -1,14 +1,14 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from __future__ import absolute_import, unicode_literals
-
+import six
 import json
 import os
 import sys
 from argparse import Namespace
 from functools import partial
 
 from mach.decorators import (
     CommandProvider,
@@ -27,17 +27,17 @@ def run_test(context, is_junit, **kwargs
 
     if not kwargs.get("log"):
         kwargs["log"] = setup_logging("mochitest", kwargs, {"mach": sys.stdout})
     global logger
     logger = kwargs["log"]
 
     flavor = kwargs.get("flavor") or "mochitest"
     if flavor not in ALL_FLAVORS:
-        for fname, fobj in ALL_FLAVORS.iteritems():
+        for fname, fobj in six.iteritems(ALL_FLAVORS):
             if flavor in fobj["aliases"]:
                 flavor = fname
                 break
     fobj = ALL_FLAVORS[flavor]
     kwargs.update(fobj.get("extra_args", {}))
 
     if kwargs.get("allow_software_gl_layers"):
         os.environ["MOZ_LAYERS_ALLOW_SOFTWARE_GL"] = "1"
--- a/testing/mozbase/docs/_static/structured_example.py
+++ b/testing/mozbase/docs/_static/structured_example.py
@@ -1,14 +1,15 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from __future__ import absolute_import
 
+import six
 import argparse
 import sys
 import traceback
 import types
 
 from mozlog import commandline, get_default_logger
 
 
@@ -50,17 +51,17 @@ def test_expected_fail():
     assert_equals(2 + 2, 5)
 
 
 class TestRunner(object):
     def __init__(self):
         self.logger = get_default_logger(component="TestRunner")
 
     def gather_tests(self):
-        for item in globals().itervalues():
+        for item in six.itervalues(globals()):
             if isinstance(item, types.FunctionType) and item.__name__.startswith(
                 "test_"
             ):
                 yield item.__name__, item
 
     def run(self):
         tests = list(self.gather_tests())
 
--- a/testing/mozharness/mozharness/base/script.py
+++ b/testing/mozharness/mozharness/base/script.py
@@ -1411,17 +1411,17 @@ class ScriptMixin(PlatformMixin):
         repl_dict = {}
         if hasattr(self.script_obj, "query_abs_dirs"):
             # allow for 'make': '%(abs_work_dir)s/...' etc.
             dirs = self.script_obj.query_abs_dirs()
             repl_dict.update(dirs)
         if isinstance(exe, dict):
             found = False
             # allow for searchable paths of the exe
-            for name, path in exe.iteritems():
+            for name, path in six.iteritems(exe):
                 if isinstance(path, list) or isinstance(path, tuple):
                     path = [x % repl_dict for x in path]
                     if all([os.path.exists(section) for section in path]):
                         found = True
                 elif isinstance(path, str):
                     path = path % repl_dict
                     if os.path.exists(path):
                         found = True
--- a/testing/mozharness/mozharness/mozilla/testing/try_tools.py
+++ b/testing/mozharness/mozharness/mozilla/testing/try_tools.py
@@ -1,16 +1,17 @@
 #!/usr/bin/env python
 # ***** BEGIN LICENSE BLOCK *****
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
 # You can obtain one at http://mozilla.org/MPL/2.0/.
 # ***** END LICENSE BLOCK *****
 
 from __future__ import absolute_import
+import six
 import argparse
 import os
 import re
 from collections import defaultdict
 
 from mozharness.base.script import PostScriptAction
 from mozharness.base.transfer import TransferMixin
 
@@ -153,17 +154,17 @@ class TryToolsMixin(TransferMixin):
 
         label_dict = {}
 
         def label_from_val(val):
             if val in label_dict:
                 return label_dict[val]
             return "--%s" % val.replace("_", "-")
 
-        for label, (opts, _) in self.known_try_arguments.iteritems():
+        for label, (opts, _) in six.iteritems(self.known_try_arguments):
             if "action" in opts and opts["action"] not in (
                 "append",
                 "store",
                 "store_true",
                 "store_false",
             ):
                 self.fatal(
                     "Try syntax does not support passing custom or store_const "
@@ -178,17 +179,17 @@ class TryToolsMixin(TransferMixin):
         (args, _) = parser.parse_known_args(all_try_args)
         self.try_test_paths = self._group_test_paths(args.try_test_paths)
         del args.try_test_paths
 
         out_args = defaultdict(list)
         # This is a pretty hacky way to echo arguments down to the harness.
         # Hopefully this can be improved once we have a configuration system
         # in tree for harnesses that relies less on a command line.
-        for arg, value in vars(args).iteritems():
+        for arg, value in six.iteritems(vars(args)):
             if value:
                 label = label_from_val(arg)
                 _, flavors = self.known_try_arguments[label]
 
                 for f in flavors:
                     if isinstance(value, bool):
                         # A store_true or store_false argument.
                         out_args[f].append(label)
--- a/testing/raptor/raptor/cmdline.py
+++ b/testing/raptor/raptor/cmdline.py
@@ -1,13 +1,14 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
 # You can obtain one at http://mozilla.org/MPL/2.0/.
 from __future__ import absolute_import, print_function
 
+import six
 import argparse
 import os
 import platform
 
 from mozlog.commandline import add_logging_group
 
 (FIREFOX, CHROME, CHROMIUM) = DESKTOP_APPS = ["firefox", "chrome", "chromium"]
 (FENNEC, GECKOVIEW, REFBROW, FENIX, CHROME_ANDROID) = FIREFOX_ANDROID_APPS = [
@@ -601,17 +602,17 @@ class _PrintTests(_StopAction):
                     if next_test["type"] == "pageload":
                         subtest = next_test["name"]
                         measure = next_test.get("measure")
                         if measure is not None:
                             subtest = "{0} ({1})".format(subtest, measure)
                         test_list[suite]["subtests"].append(subtest)
 
             # print the list in a nice, readable format
-            for key in sorted(test_list.iterkeys()):
+            for key in sorted(six.iterkeys(test_list)):
                 print("\n%s" % key)
                 print("  type: %s" % test_list[key]["type"])
                 if len(test_list[key]["subtests"]) != 0:
                     print("  subtests:")
                     for _sub in sorted(test_list[key]["subtests"]):
                         print("    %s" % _sub)
 
         print("\nDone.")
--- a/testing/raptor/raptor/output.py
+++ b/testing/raptor/raptor/output.py
@@ -2,16 +2,17 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 # some parts of this originally taken from /testing/talos/talos/output.py
 
 """output raptor test results"""
 from __future__ import absolute_import, division, print_function
 
+import six
 import filters
 
 import json
 import os
 
 from abc import ABCMeta, abstractmethod
 from logger.logger import RaptorLogger
 
@@ -628,17 +629,17 @@ class PerftestOutput(object):
                 if name in self.subtest_alert_on:
                     LOG.info(
                         "turning on subtest alerting for measurement type: %s" % name
                     )
                     _subtests[name]["shouldAlert"] = True
 
         failed_tests = []
         for pagecycle in data:
-            for _sub, _value in pagecycle[0].iteritems():
+            for _sub, _value in six.iteritems(pagecycle[0]):
                 if _value["decodedFrames"] == 0:
                     failed_tests.append(
                         "%s test Failed. decodedFrames %s droppedFrames %s."
                         % (_sub, _value["decodedFrames"], _value["droppedFrames"])
                     )
 
                 try:
                     percent_dropped = (
--- a/testing/raptor/raptor/results.py
+++ b/testing/raptor/raptor/results.py
@@ -1,16 +1,17 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 # class to process, format, and report raptor test results
 # received from the raptor control server
 from __future__ import absolute_import
 
+import six
 import json
 import os
 
 from abc import ABCMeta, abstractmethod
 from logger.logger import RaptorLogger
 from output import RaptorOutput, BrowsertimeOutput
 
 LOG = RaptorLogger(component="perftest-results-handler")
@@ -786,17 +787,19 @@ class BrowsertimeResultsHandler(Perftest
                 elif test["type"] == "pageload":
                     self.results.append(_new_pageload_result(new_result))
                 elif test["type"] == "benchmark":
                     for i, item in enumerate(self.results):
                         if item["name"] == test["name"] and not _is_supporting_data(
                             item
                         ):
                             # add page cycle custom measurements to the existing results
-                            for measurement in new_result["measurements"].iteritems():
+                            for measurement in six.iteritems(
+                                new_result["measurements"]
+                            ):
                                 self.results[i]["measurements"][measurement[0]].extend(
                                     measurement[1]
                                 )
                             break
                     else:
                         self.results.append(_new_benchmark_result(new_result))
 
         # now have all results gathered from all browsertime test URLs; format them for output
--- a/testing/tps/create_venv.py
+++ b/testing/tps/create_venv.py
@@ -6,16 +6,17 @@
 """
 This scripts sets up a virtualenv and installs TPS into it.
 It's probably best to specify a path NOT inside the repo, otherwise
 all the virtualenv files will show up in e.g. hg status.
 """
 
 from __future__ import absolute_import, print_function
 
+import six
 import optparse
 import os
 import shutil
 import subprocess
 import sys
 import urllib2
 import zipfile
 
@@ -92,17 +93,17 @@ def setup_virtualenv(target, python_bin=
         shutil.rmtree(os.path.dirname(script_path), ignore_errors=True)
 
 
 def update_configfile(source, target, replacements):
     lines = []
 
     with open(source) as config:
         for line in config:
-            for source_string, target_string in replacements.iteritems():
+            for source_string, target_string in six.iteritems(replacements):
                 if target_string:
                     line = line.replace(source_string, target_string)
             lines.append(line)
 
     with open(target, "w") as config:
         for line in lines:
             config.write(line)