diff --git a/browser/components/migration/tests/marionette/test_refresh_firefox.py b/browser/components/migration/tests/marionette/test_refresh_firefox.py index ebf607b52427..921cfb9adce3 100644 --- a/browser/components/migration/tests/marionette/test_refresh_firefox.py +++ b/browser/components/migration/tests/marionette/test_refresh_firefox.py @@ -306,7 +306,7 @@ class TestFirefoxRefresh(MarionetteTestCase): """, script_args=(self._historyURL,), ) - if type(historyResult) == str: + if type(historyResult) is str: self.fail(historyResult) return @@ -322,7 +322,7 @@ class TestFirefoxRefresh(MarionetteTestCase): """, script_args=(self._formHistoryFieldName,), ) - if type(formFieldResults) == str: + if type(formFieldResults) is str: self.fail(formFieldResults) return @@ -357,7 +357,7 @@ class TestFirefoxRefresh(MarionetteTestCase): }).then(resolve); """, ) - if type(formAutofillResults) == str: + if type(formAutofillResults) is str: self.fail(formAutofillResults) return @@ -465,7 +465,7 @@ class TestFirefoxRefresh(MarionetteTestCase): }); """ ) - if type(result) != dict: + if type(result) is not dict: self.fail(result) return self.assertEqual(result["accountData"]["email"], "test@test.com") diff --git a/build/build-clang/build-clang.py b/build/build-clang/build-clang.py index 8aadc401732a..25caa740ad8d 100755 --- a/build/build-clang/build-clang.py +++ b/build/build-clang/build-clang.py @@ -556,7 +556,7 @@ def main(): elif value is None: if key in config: del config[key] - elif type(old_value) != type(value): + elif type(old_value) is not type(value): raise Exception( "{} is overriding `{}` with a value of the wrong type".format( c.name, key diff --git a/dom/canvas/test/reftest/colors/generate_color_canvas_reftests.py b/dom/canvas/test/reftest/colors/generate_color_canvas_reftests.py index 7d5fbcf2dc23..ca91f2ba3402 100644 --- a/dom/canvas/test/reftest/colors/generate_color_canvas_reftests.py +++ b/dom/canvas/test/reftest/colors/generate_color_canvas_reftests.py @@ -33,7 +33,7 @@ U = TypeVar("U") def cross_combine(*args_tup: list[dict]) -> list[dict]: args = list(args_tup) for i, a in enumerate(args): - assert type(a) == list, f"Arg{i} is {type(a)}, expected {list}." + assert type(a) is list, f"Arg{i} is {type(a)}, expected {list}." def cross_combine2(listA, listB): listC = [] diff --git a/js/src/builtin/intl/make_intl_data.py b/js/src/builtin/intl/make_intl_data.py index d3703dadeb1e..a37f7d6d5b7a 100755 --- a/js/src/builtin/intl/make_intl_data.py +++ b/js/src/builtin/intl/make_intl_data.py @@ -172,7 +172,7 @@ def writeMappingsBinarySearchBody( # Sort the subtags by length. That enables using an optimized comparator # for the binary search, which only performs a single |memcmp| for multiple # of two subtag lengths. - mappings_keys = mappings.keys() if type(mappings) == dict else mappings + mappings_keys = mappings.keys() if type(mappings) is dict else mappings for length, subtags in groupby(sorted(mappings_keys, key=len), len): # Omit the length check if the current length is the maximum length. if length != tag_maxlength: @@ -203,7 +203,7 @@ def writeMappingsBinarySearchBody( # Don't emit a binary search for short lists. if len(subtags) == 1: - if type(mappings) == dict: + if type(mappings) is dict: println( """ if ({}) {{ @@ -228,7 +228,7 @@ def writeMappingsBinarySearchBody( ) ) elif len(subtags) <= 4: - if type(mappings) == dict: + if type(mappings) is dict: for subtag in subtags: println( """ @@ -265,7 +265,7 @@ def writeMappingsBinarySearchBody( else: write_array(subtags, source_name + "s", length, True) - if type(mappings) == dict: + if type(mappings) is dict: write_array([mappings[k] for k in subtags], "aliases", length, False) println( diff --git a/js/src/devtools/rootAnalysis/explain.py b/js/src/devtools/rootAnalysis/explain.py index 2fb45e07f933..2f91856a2b4a 100755 --- a/js/src/devtools/rootAnalysis/explain.py +++ b/js/src/devtools/rootAnalysis/explain.py @@ -150,7 +150,7 @@ def sourcelink(symbol=None, loc=None, range=None): def quoted_dict(d): - return {k: escape(v) for k, v in d.items() if type(v) == str} + return {k: escape(v) for k, v in d.items() if type(v) is str} num_hazards = 0 diff --git a/js/src/devtools/rootAnalysis/t/types/test.py b/js/src/devtools/rootAnalysis/t/types/test.py index 4a2b985abf17..0fa3750731d3 100644 --- a/js/src/devtools/rootAnalysis/t/types/test.py +++ b/js/src/devtools/rootAnalysis/t/types/test.py @@ -1,6 +1,5 @@ # flake8: noqa: F821 -from collections import defaultdict test.compile("source.cpp") test.run_analysis_script() diff --git a/js/src/gdb/lib-for-tests/catcher.py b/js/src/gdb/lib-for-tests/catcher.py index 8ef3529255b4..9c94e8e51bdd 100644 --- a/js/src/gdb/lib-for-tests/catcher.py +++ b/js/src/gdb/lib-for-tests/catcher.py @@ -29,7 +29,7 @@ try: # testlibdir is set on the GDB command line, via: # --eval-command python testlibdir=... execfile(os.path.join(testlibdir, "prologue.py"), globals(), locals()) -except Exception as err: +except Exception: sys.stderr.write("Error running GDB prologue:\n") traceback.print_exc() sys.exit(1) diff --git a/js/src/gdb/tests/enum-printers.py b/js/src/gdb/tests/enum-printers.py index ff2c088dc8ab..105ff00e5931 100644 --- a/js/src/gdb/tests/enum-printers.py +++ b/js/src/gdb/tests/enum-printers.py @@ -5,7 +5,7 @@ import mozilla.prettyprinters @mozilla.prettyprinters.pretty_printer("unscoped_no_storage") -class my_typedef(object): +class UnscopedNoStoragePrinter(object): def __init__(self, value, cache): pass @@ -14,7 +14,7 @@ class my_typedef(object): @mozilla.prettyprinters.pretty_printer("unscoped_with_storage") -class my_typedef(object): +class UnscopedWithStoragePrinter(object): def __init__(self, value, cache): pass @@ -23,7 +23,7 @@ class my_typedef(object): @mozilla.prettyprinters.pretty_printer("scoped_no_storage") -class my_typedef(object): +class ScopedNoStoragePrinter(object): def __init__(self, value, cache): pass @@ -32,7 +32,7 @@ class my_typedef(object): @mozilla.prettyprinters.pretty_printer("scoped_with_storage") -class my_typedef(object): +class ScopedWithStoragePrinter(object): def __init__(self, value, cache): pass diff --git a/js/src/tests/test262-update.py b/js/src/tests/test262-update.py index b4f4321957fb..e341fbad3bf1 100755 --- a/js/src/tests/test262-update.py +++ b/js/src/tests/test262-update.py @@ -311,7 +311,7 @@ def convertTestFile(test262parser, testSource, testName, includeSet, strictTests # currently ignoring the error phase attribute. # testRec["negative"] == {type=, phase=parse|resolution|runtime} isNegative = "negative" in testRec - assert not isNegative or type(testRec["negative"]) == dict + assert not isNegative or type(testRec["negative"]) is dict errorType = testRec["negative"]["type"] if isNegative else None # Async tests are marked with the "async" attribute. diff --git a/modules/libpref/init/generate_static_pref_list.py b/modules/libpref/init/generate_static_pref_list.py index ad92fa87263e..dceb0175b1be 100644 --- a/modules/libpref/init/generate_static_pref_list.py +++ b/modules/libpref/init/generate_static_pref_list.py @@ -156,7 +156,7 @@ def check_pref_list(pref_list): if "name" not in pref: error("missing `name` key") name = pref["name"] - if type(name) != str: + if type(name) is not str: error("non-string `name` value `{}`".format(name)) if "." not in name: error("`name` value `{}` lacks a '.'".format(name)) @@ -185,7 +185,7 @@ def check_pref_list(pref_list): error("missing `value` key for pref `{}`".format(name)) value = pref["value"] if typ == "String" or typ == "DataMutexString": - if type(value) != str: + if type(value) is not str: error( "non-string `value` value `{}` for `{}` pref `{}`; " "add double quotes".format(value, typ, name) @@ -206,7 +206,7 @@ def check_pref_list(pref_list): # Check 'do_not_use_directly' if present. if "do_not_use_directly" in pref: do_not_use_directly = pref["do_not_use_directly"] - if type(do_not_use_directly) != bool: + if type(do_not_use_directly) is not bool: error( "non-boolean `do_not_use_directly` value `{}` for pref " "`{}`".format(do_not_use_directly, name) @@ -220,7 +220,7 @@ def check_pref_list(pref_list): # Check 'include' if present. if "include" in pref: include = pref["include"] - if type(include) != str: + if type(include) is not str: error( "non-string `include` value `{}` for pref `{}`".format( include, name @@ -235,7 +235,7 @@ def check_pref_list(pref_list): # Check 'rust' if present. if "rust" in pref: rust = pref["rust"] - if type(rust) != bool: + if type(rust) is not bool: error("non-boolean `rust` value `{}` for pref `{}`".format(rust, name)) if rust and mirror == "never": error( diff --git a/python/mach/mach/commands/settings.py b/python/mach/mach/commands/settings.py index 8e168a3921ca..474790cd426a 100644 --- a/python/mach/mach/commands/settings.py +++ b/python/mach/mach/commands/settings.py @@ -7,7 +7,6 @@ from textwrap import TextWrapper from mach.config import TYPE_CLASSES from mach.decorators import Command, CommandArgument - # Interact with settings for mach. # Currently, we only provide functionality to view what settings are diff --git a/python/mach/mach/site.py b/python/mach/mach/site.py index 44381356b0cb..8365c9f43379 100644 --- a/python/mach/mach/site.py +++ b/python/mach/mach/site.py @@ -168,7 +168,7 @@ class MozSiteMetadata: def __eq__(self, other): return ( - type(self) == type(other) + type(self) is type(other) and self.hex_version == other.hex_version and self.site_name == other.site_name and self.mach_site_packages_source == other.mach_site_packages_source diff --git a/python/mozboot/mozboot/bootstrap.py b/python/mozboot/mozboot/bootstrap.py index df3f39f5483f..e1e004ae51de 100644 --- a/python/mozboot/mozboot/bootstrap.py +++ b/python/mozboot/mozboot/bootstrap.py @@ -818,7 +818,7 @@ def update_git_tools(git: Optional[Path], root_state_dir: Path): os.chmod(path, stat.S_IRWXU) func(path) else: - raise + raise exc shutil.rmtree(str(cinnabar_dir), onerror=onerror) diff --git a/python/mozbuild/mozbuild/compilation/codecomplete.py b/python/mozbuild/mozbuild/compilation/codecomplete.py index b5a466b72928..497061e983bd 100644 --- a/python/mozbuild/mozbuild/compilation/codecomplete.py +++ b/python/mozbuild/mozbuild/compilation/codecomplete.py @@ -9,7 +9,6 @@ from mach.decorators import Command, CommandArgument from mozbuild.shellutil import quote as shell_quote from mozbuild.shellutil import split as shell_split - # Instropection commands. diff --git a/python/mozbuild/mozbuild/configure/lint.py b/python/mozbuild/mozbuild/configure/lint.py index 4858188964aa..ce62d2040f95 100644 --- a/python/mozbuild/mozbuild/configure/lint.py +++ b/python/mozbuild/mozbuild/configure/lint.py @@ -210,7 +210,7 @@ class LintSandbox(ConfigureSandbox): name = args[0] default = kwargs.get("default") - if type(default) != bool: + if type(default) is not bool: return table = { diff --git a/python/mozbuild/mozbuild/configure/options.py b/python/mozbuild/mozbuild/configure/options.py index 7c2ab4cd5be0..fc33cf07014e 100644 --- a/python/mozbuild/mozbuild/configure/options.py +++ b/python/mozbuild/mozbuild/configure/options.py @@ -94,12 +94,12 @@ class OptionValue(tuple): ) # Allow explicit tuples to be compared. - if type(other) == tuple: + if type(other) is tuple: return tuple.__eq__(self, other) elif isinstance(other, bool): return bool(self) == other # Else we're likely an OptionValue class. - elif type(other) != type(self): + elif type(other) is not type(self): return False else: return super(OptionValue, self).__eq__(other) diff --git a/python/mozbuild/mozbuild/frontend/context.py b/python/mozbuild/mozbuild/frontend/context.py index 0ba4ebcf28c7..dec3d2aa68f7 100644 --- a/python/mozbuild/mozbuild/frontend/context.py +++ b/python/mozbuild/mozbuild/frontend/context.py @@ -2604,7 +2604,7 @@ VARIABLES = { # Sanity check: we don't want any variable above to have a list as storage type. for name, (storage_type, input_types, docs) in VARIABLES.items(): - if storage_type == list: + if storage_type is list: raise RuntimeError('%s has a "list" storage type. Use "List" instead.' % name) # Set of variables that are only allowed in templates: diff --git a/python/mozbuild/mozbuild/frontend/data.py b/python/mozbuild/mozbuild/frontend/data.py index dfc0e647a7ae..bad49365af0a 100644 --- a/python/mozbuild/mozbuild/frontend/data.py +++ b/python/mozbuild/mozbuild/frontend/data.py @@ -148,7 +148,7 @@ class VariablePassthru(ContextDerived): in our build backends since we will continue to be tied to our rules.mk. """ - __slots__ = "variables" + __slots__ = ("variables",) def __init__(self, context): ContextDerived.__init__(self, context) @@ -197,7 +197,7 @@ class BaseDefines(ContextDerived): which are OrderedDicts. """ - __slots__ = "defines" + __slots__ = ("defines",) def __init__(self, context, defines): ContextDerived.__init__(self, context) @@ -477,7 +477,7 @@ class BaseProgram(Linkable): Otherwise, the suffix is appended to the program name. """ - __slots__ = "program" + __slots__ = ("program",) DICT_ATTRS = {"install_target", "KIND", "program", "relobjdir"} @@ -1201,7 +1201,7 @@ class FinalTargetFiles(ContextDerived): HierarchicalStringList, which is created when parsing FINAL_TARGET_FILES. """ - __slots__ = "files" + __slots__ = ("files",) def __init__(self, sandbox, files): ContextDerived.__init__(self, sandbox) @@ -1218,7 +1218,7 @@ class FinalTargetPreprocessedFiles(ContextDerived): FINAL_TARGET_PP_FILES. """ - __slots__ = "files" + __slots__ = ("files",) def __init__(self, sandbox, files): ContextDerived.__init__(self, sandbox) diff --git a/python/mozbuild/mozbuild/frontend/reader.py b/python/mozbuild/mozbuild/frontend/reader.py index 798fb0369544..714f4759d9f3 100644 --- a/python/mozbuild/mozbuild/frontend/reader.py +++ b/python/mozbuild/mozbuild/frontend/reader.py @@ -799,7 +799,7 @@ class BuildReaderError(Exception): s.write("\n") s.write("This variable expects the following type(s):\n") s.write("\n") - if type(inner.args[4]) == type: + if type(inner.args[4]) is type: s.write(" %s\n" % inner.args[4].__name__) else: for t in inner.args[4]: diff --git a/python/mozbuild/mozbuild/shellutil.py b/python/mozbuild/mozbuild/shellutil.py index 65af11814a9a..94cb66b2617c 100644 --- a/python/mozbuild/mozbuild/shellutil.py +++ b/python/mozbuild/mozbuild/shellutil.py @@ -181,7 +181,7 @@ def _quote(s): As a special case, if given an int, returns a string containing the int, not enclosed in quotes. """ - if type(s) == int: + if type(s) is int: return f"{s}" # Empty strings need to be quoted to have any significance diff --git a/python/mozbuild/mozbuild/toolchains.py b/python/mozbuild/mozbuild/toolchains.py index ca6b77852cb0..3e0af2373e2c 100644 --- a/python/mozbuild/mozbuild/toolchains.py +++ b/python/mozbuild/mozbuild/toolchains.py @@ -8,7 +8,8 @@ import six def toolchain_task_definitions(): - import gecko_taskgraph # noqa: triggers override of the `graph_config_schema` + # triggers override of the `graph_config_schema` noqa + import gecko_taskgraph # noqa from taskgraph.generator import load_tasks_for_kind # Don't import globally to allow this module being imported without diff --git a/python/mozbuild/mozbuild/util.py b/python/mozbuild/mozbuild/util.py index 1ee46eecd4bc..74f0247242be 100644 --- a/python/mozbuild/mozbuild/util.py +++ b/python/mozbuild/mozbuild/util.py @@ -191,8 +191,8 @@ class FileAvoidWrite(BytesIO): def __init__(self, filename, capture_diff=False, dry_run=False, readmode="r"): BytesIO.__init__(self) self.name = filename - assert type(capture_diff) == bool - assert type(dry_run) == bool + assert type(capture_diff) is bool + assert type(dry_run) is bool assert "r" in readmode self._capture_diff = capture_diff self._write_to_file = not dry_run diff --git a/python/mozbuild/mozpack/chrome/manifest.py b/python/mozbuild/mozpack/chrome/manifest.py index 14c11d4c1daa..db86d4c8aef0 100644 --- a/python/mozbuild/mozpack/chrome/manifest.py +++ b/python/mozbuild/mozpack/chrome/manifest.py @@ -345,7 +345,7 @@ MANIFESTS_TYPES = dict( [ (c.type, c) for c in globals().values() - if type(c) == type + if type(c) is type and issubclass(c, ManifestEntry) and hasattr(c, "type") and c.type diff --git a/python/mozbuild/mozpack/test/test_pkg.py b/python/mozbuild/mozpack/test/test_pkg.py index f1febbbae021..4272e6ab0fc3 100644 --- a/python/mozbuild/mozpack/test/test_pkg.py +++ b/python/mozbuild/mozpack/test/test_pkg.py @@ -41,7 +41,7 @@ class TestPkg(TestWithTmpDir): def test_get_apple_template(self): tmpl = get_apple_template("Distribution.template") - assert type(tmpl) == Template + assert type(tmpl) is Template def test_get_apple_template_not_file(self): with self.assertRaises(Exception): diff --git a/python/mozperftest/mozperftest/tests/test_notebookupload.py b/python/mozperftest/mozperftest/tests/test_notebookupload.py index c05942c1ebb4..f586e0d69927 100644 --- a/python/mozperftest/mozperftest/tests/test_notebookupload.py +++ b/python/mozperftest/mozperftest/tests/test_notebookupload.py @@ -45,7 +45,7 @@ def test_notebookupload_with_filter(notebook, no_filter): if no_filter: args, kwargs = notebook.call_args_list[0] - assert type(kwargs["data"][0]["data"][0]["value"]) == str + assert type(kwargs["data"][0]["data"][0]["value"]) is str else: for call in notebook.call_args_list: args, kwargs = call diff --git a/taskcluster/docker/snap-coreXX-build/parse.py b/taskcluster/docker/snap-coreXX-build/parse.py index 36981accecf3..f1b4c7c6ab7a 100644 --- a/taskcluster/docker/snap-coreXX-build/parse.py +++ b/taskcluster/docker/snap-coreXX-build/parse.py @@ -13,7 +13,7 @@ def has_pkg_section(p, section): has_section = section in p.keys() if has_section: for pkg in p[section]: - if type(pkg) == str: + if type(pkg) is str: yield pkg else: yield from has_pkg_section(pkg, next(iter(pkg.keys()))) diff --git a/taskcluster/docker/snap-coreXX-build/snap-tests/basic_tests.py b/taskcluster/docker/snap-coreXX-build/snap-tests/basic_tests.py index a0d1d97bca4d..1e72a2f10d7a 100644 --- a/taskcluster/docker/snap-coreXX-build/snap-tests/basic_tests.py +++ b/taskcluster/docker/snap-coreXX-build/snap-tests/basic_tests.py @@ -400,7 +400,7 @@ class SnapTests(SnapTestsBase): video = self._wait.until( EC.visibility_of_element_located((By.CLASS_NAME, "html5-main-video")) ) - self._wait.until(lambda d: type(video.get_property("duration")) == float) + self._wait.until(lambda d: type(video.get_property("duration")) is float) self._logger.info("video duration: {}".format(video.get_property("duration"))) assert ( video.get_property("duration") > exp["duration"] @@ -470,7 +470,7 @@ class SnapTests(SnapTestsBase): (By.CSS_SELECTOR, "video.html5-main-video") ) ) - self._wait.until(lambda d: type(video.get_property("duration")) == float) + self._wait.until(lambda d: type(video.get_property("duration")) is float) self._logger.info("video duration: {}".format(video.get_property("duration"))) assert ( video.get_property("duration") > exp["duration"] diff --git a/taskcluster/docker/snap-coreXX-build/snap-tests/qa_tests.py b/taskcluster/docker/snap-coreXX-build/snap-tests/qa_tests.py index 2cecf7af1213..e5b7e5866a78 100644 --- a/taskcluster/docker/snap-coreXX-build/snap-tests/qa_tests.py +++ b/taskcluster/docker/snap-coreXX-build/snap-tests/qa_tests.py @@ -58,7 +58,7 @@ class QATests(SnapTestsBase): (By.CSS_SELECTOR, video_selector or "video") ) ) - self._wait.until(lambda d: type(video.get_property("duration")) == float) + self._wait.until(lambda d: type(video.get_property("duration")) is float) assert video.get_property("duration") > 0.0, "