From d5ce3722e6a058f8b74ff501097eb8a194aa6cfb Mon Sep 17 00:00:00 2001 From: Alex Hochheiden Date: Thu, 8 Jan 2026 21:13:30 +0000 Subject: [PATCH 001/223] Bug 2006716 - Set `target-version = "py38"` in `pyproject.toml` r=ahal CI workers on `ubuntu1804` still use `Python 3.8`. When we did the minimum Python version bump to `3.9` for `mach`, changing this was a mistake, because these jobs use files from in the tree, but don't go through `mach`. With this set a `py39`, formatters can make changes that are incompatible with `Python 3.8`, which causes jobs on these workers to fail. We don't want that, so we're switching back to `py38` until the tasks these workers run are moved to `ubuntu2404` which is not on `Python 3.8`. Differential Revision: https://phabricator.services.mozilla.com/D278340 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index b1fb454914a7e..1a7252979631c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.ruff] line-length = 99 -target-version = "py39" +target-version = "py38" # See https://beta.ruff.rs/docs/rules/ for a full list of rules. lint.select = [ "E", "W", # pycodestyle From 02333707ab4fd24655bdf6065b206fc7b67ec334 Mon Sep 17 00:00:00 2001 From: Alex Hochheiden Date: Thu, 8 Jan 2026 21:13:31 +0000 Subject: [PATCH 002/223] Bug 2006716 - Reformat entire repo with `ruff-format` (`black` replacement) r=ahal,sylvestre,linter-reviewers,perftest-reviewers,mozperftest-reviewers,geckoview-reviewers,extension-reviewers,media-playback-reviewers,webrtc-reviewers,releng-reviewers,sessionstore-reviewers,win-reviewers,dom-storage-reviewers,translations-reviewers,omc-reviewers,android-reviewers,home-newtab-reviewers,toolkit-telemetry-reviewers,firefox-style-system-reviewers,layout-reviewers,dom-worker-reviewers,geckodriver-reviewers,Sasha,emz,fchasen,sthompson,dholbert,sparky,padenot,emilio,Gijs,mconley,tcampbell,mjf,emcminn,willdurand,gstoll,jgraham,asuth # ignore-this-changeset Differential Revision: https://phabricator.services.mozilla.com/D276894 --- .../tests/browser/windows/a11y_setup.py | 3 +- .../content-src/schemas/make-schemas.py | 12 +- .../backup/tests/marionette/test_backup.py | 24 +- .../telemetry/test_ping_submitted.py | 12 +- .../marionette/test_engines_on_restart.py | 8 +- .../marionette/session_store_test_case.py | 90 +- .../test/marionette/test_log_files.py | 20 +- ...st_persist_closed_tabs_restore_manually.py | 16 +- .../test/marionette/test_restore_manually.py | 20 +- .../test_restore_manually_with_pinned_tabs.py | 18 +- .../test_restore_manually_with_tab_groups.py | 20 +- .../test/marionette/test_restore_sidebar.py | 14 +- .../test_restore_sidebar_automatic.py | 14 +- .../test/marionette/test_tabgroups_restore.py | 12 +- .../marionette/test_taskbartab_restore.py | 32 +- .../test_taskbartab_sessionstate.py | 16 +- .../test_default_launcher_visible.py | 33 +- .../test_initialize_vertical_tabs.py | 48 +- browser/extensions/newtab/mach_commands.py | 39 +- build/RunCbindgen.py | 24 +- build/appini_header.py | 2 +- build/gen_symverscript.py | 8 +- build/gen_test_packages_manifest.py | 2 +- build/gn_processor.py | 48 +- .../test/python/test_android_gradle_build.py | 24 +- build/variables.py | 2 +- client.py | 10 +- config/check_macroassembler_style.py | 37 +- config/check_spidermonkey_style.py | 144 +- config/external/ffi/subst_header.py | 14 +- config/mozunit/mozunit/mozunit.py | 34 +- config/tests/unit-nsinstall.py | 4 +- config/tests/unitMozZipFile.py | 1 + configure.py | 2 +- dom/base/usecounters.py | 240 ++-- dom/bindings/Configuration.py | 3 +- .../parser/tests/test_attr_sequence_type.py | 2 +- dom/bindings/parser/tests/test_constructor.py | 9 +- dom/bindings/parser/tests/test_dictionary.py | 8 +- .../parser/tests/test_distinguishability.py | 4 +- .../test_empty_sequence_default_value.py | 2 +- .../parser/tests/test_global_extended_attr.py | 6 +- dom/bindings/parser/tests/test_interface.py | 12 +- .../parser/tests/test_interfacemixin.py | 6 +- .../parser/tests/test_optional_constraints.py | 3 +- dom/bindings/parser/tests/test_promise.py | 4 +- dom/bindings/parser/tests/test_toJSON.py | 11 +- dom/bindings/parser/tests/test_typedef.py | 3 +- dom/bindings/parser/tests/test_union.py | 9 +- .../parser/tests/test_union_nullable.py | 4 +- .../parser/tests/test_variadic_constraints.py | 6 +- .../colors/generate_color_canvas_reftests.py | 8 +- .../generate-wrappers-and-manifest.py | 26 +- dom/canvas/test/webgl-conf/import.py | 6 +- dom/media/driftcontrol/plot.py | 10 +- dom/media/test/reftest/gen_combos.py | 146 +- dom/media/tools/checkGmpBalrog.py | 16 +- dom/media/tools/generateGmpJson.py | 11 +- .../third_party_build/filter_git_changes.py | 6 +- .../third_party_build/write_default_config.py | 2 +- dom/origin-trials/gen-keys.py | 12 +- .../qm_try_analysis/analyze.py | 2 +- .../qm_try_analysis/fn_anchors.py | 22 +- .../qm-try-analysis/qm_try_analysis/report.py | 6 +- .../qm_try_analysis/stackanalysis.py | 18 +- .../update-safe-default-configuration.py | 14 +- .../test_service_workers_disabled.py | 8 +- gfx/gl/GLConsts.py | 8 +- intl/icu_sources_data.py | 32 +- ipc/ipdl/ipdl.py | 2 +- ipc/pull-chromium.py | 18 +- js/src/builtin/embedjs.py | 12 +- js/src/builtin/intl/make_intl_data.py | 317 ++--- js/src/devtools/automation/autospider.py | 54 +- js/src/devtools/gc/gc-test.py | 2 +- js/src/devtools/rootAnalysis/analyze.py | 15 +- js/src/devtools/rootAnalysis/mach_commands.py | 21 +- js/src/devtools/rootAnalysis/run-test.py | 8 +- js/src/devtools/rootAnalysis/t/graph/test.py | 12 +- js/src/frontend/align_stack_comment.py | 10 +- js/src/gdb/run-tests.py | 14 +- js/src/jit-test/jit_test.py | 13 +- js/src/jit/GenerateABIFunctionType.py | 4 +- js/src/shell/js-gdb.py | 2 +- js/src/tests/compare_bench.py | 3 +- js/src/tests/jstests.py | 59 +- js/src/tests/lib/jittests.py | 17 +- js/src/tests/lib/manifest.py | 58 +- js/src/tests/lib/results.py | 17 +- js/src/tests/lib/wptreport.py | 42 +- .../make-normalize-generateddata-input.py | 8 +- js/src/tests/parsemark.py | 6 +- js/src/tests/test/run.py | 39 +- js/src/tests/test262-export.py | 18 +- js/src/tests/test262-update.py | 87 +- js/src/util/make_unicode.py | 16 +- js/src/vm/jsopcode.py | 6 +- js/src/vm/make_opcode_doc.py | 12 +- js/src/wasm/GenerateBuiltinModules.py | 2 +- layout/tools/reftest/reftest/__init__.py | 6 +- layout/tools/reftest/reftestcommandline.py | 17 +- layout/tools/reftest/remotereftest.py | 4 +- layout/tools/reftest/runreftest.py | 11 +- layout/tools/reftest/selftest/conftest.py | 46 +- memory/replace/dmd/block_analyzer.py | 3 +- .../publish_to_maven_local_if_modified.py | 8 +- .../src/main/java/appservices_version_bump.py | 3 +- .../generate_smoke_tests.py | 2 +- .../mozilla/fenix/syncintegration/conftest.py | 4 +- .../org/mozilla/fenix/syncintegration/tps.py | 12 +- .../fenix/tools/data_renewal_request.py | 8 +- .../android/fenix/tools/update-glean-tags.py | 1 + .../tools/data_renewal_request.py | 8 +- .../focus-android/tools/update-glean-tags.py | 1 + .../src/test/resources/apidoc_test.py | 76 +- .../apilint/src/main/resources/apilint.py | 9 +- .../src/main/resources/changelog-check.py | 54 +- .../src/test/resources/apilint_test.py | 18 +- mobile/android/mach_commands.py | 16 +- .../libpref/init/generate_static_pref_list.py | 32 +- .../test/test_generate_static_pref_list.py | 16 +- moz.configure | 3 +- .../build/generate_profiling_categories.py | 18 +- .../test_purge_http_cache_at_shutdown.py | 12 +- netwerk/test/perf/hooks_throttling.py | 1 + python/mach/mach/commands/commandinfo.py | 109 +- python/mach/mach/decorators.py | 2 +- python/mach/mach/dispatcher.py | 7 +- python/mach/mach/main.py | 2 +- python/mach/mach/registrar.py | 2 +- python/mach/mach/sentry.py | 6 +- python/mach/mach/site.py | 30 +- .../mach/mach/test/script_site_activation.py | 12 +- python/mach/mach/test/test_site.py | 6 +- python/mach/mach/test/test_site_activation.py | 14 +- python/mach/mach/util.py | 2 +- python/mozboot/bin/bootstrap.py | 2 +- python/mozboot/mozboot/base.py | 22 +- python/mozboot/mozboot/bootstrap.py | 28 +- python/mozboot/mozboot/linux_common.py | 20 +- python/mozboot/mozboot/mozconfig.py | 2 +- python/mozboot/mozboot/osx.py | 16 +- .../mozbuild/mozbuild/action/check_binary.py | 66 +- .../mozbuild/action/exe_7z_archive.py | 32 +- python/mozbuild/mozbuild/action/fat_aar.py | 28 +- .../mozbuild/action/langpack_manifest.py | 20 +- .../mozbuild/mozbuild/action/test_archive.py | 12 +- python/mozbuild/mozbuild/action/zip.py | 2 +- .../mozbuild/mozbuild/android_version_code.py | 9 +- python/mozbuild/mozbuild/artifact_cache.py | 1 - python/mozbuild/mozbuild/artifacts.py | 30 +- python/mozbuild/mozbuild/backend/base.py | 10 +- python/mozbuild/mozbuild/backend/common.py | 12 +- .../mozbuild/backend/configenvironment.py | 33 +- .../mozbuild/mozbuild/backend/cpp_eclipse.py | 22 +- .../mozbuild/mozbuild/backend/fastermake.py | 18 +- .../mozbuild/backend/recursivemake.py | 86 +- .../mozbuild/code_analysis/mach_commands.py | 3 +- .../mozbuild/codecoverage/lcov_rewriter.py | 12 +- .../mozbuild/mozbuild/compilation/database.py | 12 +- python/mozbuild/mozbuild/config_status.py | 8 +- .../mozbuild/mozbuild/configure/__init__.py | 51 +- .../mozbuild/mozbuild/configure/constants.py | 46 +- python/mozbuild/mozbuild/configure/lint.py | 3 +- python/mozbuild/mozbuild/configure/options.py | 3 +- .../mozbuild/mozbuild/controller/building.py | 48 +- .../mozbuild/mozbuild/controller/clobber.py | 16 +- python/mozbuild/mozbuild/faster_daemon.py | 20 +- python/mozbuild/mozbuild/frontend/context.py | 43 +- python/mozbuild/mozbuild/frontend/data.py | 26 +- python/mozbuild/mozbuild/frontend/emitter.py | 113 +- .../mozbuild/mozbuild/frontend/gyp_reader.py | 10 +- python/mozbuild/mozbuild/frontend/reader.py | 5 +- python/mozbuild/mozbuild/frontend/sandbox.py | 26 +- .../lockfiles/generate_python_lockfiles.py | 1 - .../lockfiles/site_dependency_extractor.py | 1 - python/mozbuild/mozbuild/mach_commands.py | 93 +- .../mozbuild/mozbuild/repackaging/flatpak.py | 24 +- python/mozbuild/mozbuild/repackaging/msix.py | 14 +- python/mozbuild/mozbuild/repackaging/snap.py | 18 +- python/mozbuild/mozbuild/sphinx.py | 130 +- .../mozbuild/test/action/test_buildlist.py | 2 +- .../backend/test_partialconfigenvironment.py | 10 +- .../test/backend/test_test_manifest.py | 14 +- python/mozbuild/mozbuild/test/common.py | 2 +- .../mozbuild/test/configure/test_bootstrap.py | 2 +- .../test/configure/test_checks_configure.py | 10 +- .../mozbuild/test/configure/test_configure.py | 74 +- .../mozbuild/test/configure/test_lint.py | 18 +- .../configure/test_toolchain_configure.py | 110 +- .../test/configure/test_toolchain_helpers.py | 23 +- .../configure/test_toolkit_moz_configure.py | 2 +- .../mozbuild/test/configure/test_util.py | 29 +- .../mozbuild/test/frontend/test_context.py | 42 +- .../mozbuild/test/frontend/test_emitter.py | 11 +- .../mozbuild/test/frontend/test_namespaces.py | 8 +- .../mozbuild/test/frontend/test_reader.py | 85 +- .../mozbuild/test/frontend/test_sandbox.py | 16 +- .../mozbuild/mozbuild/test/test_confvars.py | 3 +- .../mozbuild/test/test_legacy_test.py | 6 +- .../mozbuild/test/test_line_endings.py | 6 +- .../mozbuild/mozbuild/test/test_manifest.py | 1178 ++++++++--------- .../mozbuild/test/test_preprocessor.py | 742 +++++------ .../mozbuild/mozbuild/test/test_pythonutil.py | 10 +- .../mozbuild/test/test_telemetry_settings.py | 12 +- python/mozbuild/mozbuild/test/test_util.py | 10 +- python/mozbuild/mozbuild/test/test_vendor.py | 18 +- python/mozbuild/mozbuild/testing.py | 7 +- python/mozbuild/mozbuild/util.py | 6 +- python/mozbuild/mozbuild/vendor/host_git.py | 9 +- .../mozbuild/mozbuild/vendor/host_github.py | 8 +- .../mozbuild/mozbuild/vendor/host_gitlab.py | 9 +- .../mozbuild/vendor/host_googlesource.py | 16 +- .../mozbuild/mozbuild/vendor/mach_commands.py | 4 +- python/mozbuild/mozbuild/vendor/moz_yaml.py | 166 ++- .../mozbuild/vendor/rewrite_mozbuild.py | 63 +- .../mozbuild/vendor/vendor_manifest.py | 19 +- .../mozbuild/mozbuild/vendor/vendor_python.py | 32 +- .../mozbuild/mozbuild/vendor/vendor_rust.py | 52 +- python/mozbuild/mozpack/archive.py | 2 +- python/mozbuild/mozpack/chrome/manifest.py | 18 +- python/mozbuild/mozpack/dmg.py | 99 +- python/mozbuild/mozpack/files.py | 12 +- python/mozbuild/mozpack/mozjar.py | 96 +- python/mozbuild/mozpack/pkg.py | 34 +- .../mozpack/test/test_chrome_manifest.py | 10 +- python/mozbuild/mozpack/test/test_files.py | 36 +- python/mozbuild/mozpack/test/test_mozjar.py | 56 +- python/mozbuild/mozpack/test/test_packager.py | 84 +- .../mozpack/test/test_packager_formats.py | 200 ++- .../mozpack/test/test_packager_l10n.py | 124 +- python/mozbuild/mozpack/test/test_path.py | 8 +- python/mozbuild/mozpack/test/test_unify.py | 142 +- python/mozlint/mozlint/errors.py | 2 +- python/mozlint/mozlint/formatters/stylish.py | 4 +- python/mozlint/mozlint/formatters/summary.py | 12 +- python/mozlint/mozlint/parser.py | 4 +- python/mozlint/mozlint/pathutils.py | 1 - python/mozlint/mozlint/roller.py | 9 +- python/mozlint/test/test_cli.py | 16 +- python/mozlint/test/test_editor.py | 32 +- python/mozlint/test/test_formatters.py | 8 +- python/mozperftest/mozperftest/environment.py | 6 +- .../mozperftest/mozperftest/metrics/common.py | 6 +- .../mozperftest/metrics/notebookupload.py | 80 +- .../mozperftest/metrics/perfboard/grafana.py | 6 +- .../mozperftest/metrics/perfboard/influx.py | 90 +- .../mozperftest/metrics/perfherder.py | 32 +- .../mozperftest/mozperftest/metrics/utils.py | 13 +- .../mozperftest/metrics/visualmetrics.py | 14 +- python/mozperftest/mozperftest/runner.py | 1 + .../mozperftest/system/geckoprofiler.py | 6 +- .../mozperftest/mozperftest/system/proxy.py | 6 +- python/mozperftest/mozperftest/test/alert.py | 10 +- .../mozperftest/test/androidlog.py | 14 +- .../mozperftest/test/browsertime/runner.py | 14 +- .../test/browsertime/visualtools.py | 4 +- .../mozperftest/mozperftest/test/mochitest.py | 52 +- .../mozperftest/test/shellscript.py | 16 +- .../mozperftest/test/webpagetest.py | 30 +- .../mozperftest/mozperftest/test/xpcshell.py | 20 +- .../mozperftest/tests/test_alert.py | 16 +- .../mozperftest/tests/test_argparser.py | 16 +- .../mozperftest/tests/test_browsertime.py | 6 +- .../mozperftest/tests/test_change_detector.py | 64 +- .../tests/test_functionaltestrunner.py | 4 +- .../mozperftest/tests/test_influx.py | 24 +- .../mozperftest/tests/test_mochitest.py | 4 +- .../mozperftest/tests/test_notebookupload.py | 12 +- .../mozperftest/tests/test_perfherder.py | 185 ++- .../tests/test_perftestnotebook.py | 7 +- .../mozperftest/tests/test_runner.py | 18 +- .../mozperftest/tests/test_simpleperf.py | 22 +- .../mozperftest/tests/test_utils.py | 40 +- .../mozperftest/tests/test_xpcshell.py | 22 +- python/mozperftest/mozperftest/utils.py | 34 +- .../mozrelease/mozrelease/attribute_builds.py | 12 +- python/mozrelease/mozrelease/balrog.py | 10 +- .../mozrelease/mozrelease/buglist_creator.py | 14 +- python/mozrelease/mozrelease/mach_commands.py | 3 +- python/mozrelease/mozrelease/paths.py | 42 +- .../mozrelease/scriptworker_canary.py | 18 +- python/mozrelease/mozrelease/update_verify.py | 26 +- python/mozterm/test/test_widgets.py | 10 +- .../mozversioncontrol/repo/git.py | 34 +- .../mozversioncontrol/repo/mercurial.py | 10 +- python/mozversioncontrol/test/test_commit.py | 6 +- .../test/test_get_mozilla_remote_args.py | 12 +- .../mozversioncontrol/test/test_try_commit.py | 12 +- security/manager/ssl/gen_cert_header.py | 2 +- .../crtshToIdentifyingStruct.py | 1 + security/manager/tools/pytlsbinding.py | 1 - .../manager/tools/regen_root_ca_metadata.py | 12 +- taskcluster/android_taskgraph/__init__.py | 16 +- taskcluster/android_taskgraph/job.py | 76 +- .../transforms/beetmover_android_app.py | 16 +- .../transforms/build_android_app.py | 128 +- .../transforms/build_components.py | 44 +- .../android_taskgraph/transforms/notify.py | 12 +- .../transforms/push_android_app.py | 3 +- .../android_taskgraph/transforms/signing.py | 5 +- .../transforms/startup_tests_deps.py | 6 +- .../android_taskgraph/transforms/ui_tests.py | 18 +- .../transforms/upstream_artifacts.py | 24 +- .../android_taskgraph/util/group_by.py | 12 +- .../android_taskgraph/util/scriptworker.py | 34 +- taskcluster/android_taskgraph/worker_types.py | 10 +- .../scripts/funsize.py | 2 +- .../snap-tests/basic_tests.py | 110 +- .../snap-coreXX-build/snap-tests/qa_tests.py | 194 +-- taskcluster/docker/updatebot/run.py | 4 +- taskcluster/gecko_taskgraph/__init__.py | 18 +- .../gecko_taskgraph/actions/backfill.py | 2 +- .../gecko_taskgraph/actions/registry.py | 56 +- .../actions/release_promotion.py | 25 +- .../gecko_taskgraph/actions/retrigger.py | 12 +- .../actions/retrigger_custom.py | 57 +- .../gecko_taskgraph/actions/side_by_side.py | 6 +- taskcluster/gecko_taskgraph/config.py | 226 ++-- taskcluster/gecko_taskgraph/files_changed.py | 2 +- taskcluster/gecko_taskgraph/main.py | 12 +- taskcluster/gecko_taskgraph/morph.py | 1 - taskcluster/gecko_taskgraph/target_tasks.py | 33 +- taskcluster/gecko_taskgraph/test/conftest.py | 26 +- .../gecko_taskgraph/test/test_actions.py | 36 +- taskcluster/gecko_taskgraph/test/test_main.py | 8 +- .../gecko_taskgraph/test/test_morph.py | 22 +- .../test/test_optimize_strategies.py | 9 +- .../gecko_taskgraph/test/test_target_tasks.py | 24 +- .../test/test_transforms_job.py | 17 +- .../test/test_transforms_test.py | 72 +- .../test/test_util_backstop.py | 7 +- .../test/test_util_chunking.py | 10 +- .../test/test_util_runnable_jobs.py | 6 +- .../gecko_taskgraph/test/test_util_verify.py | 1 - .../gecko_taskgraph/transforms/artifact.py | 1 + .../transforms/balrog_submit.py | 40 +- .../gecko_taskgraph/transforms/beetmover.py | 40 +- .../transforms/beetmover_checksums.py | 24 +- .../transforms/beetmover_emefree_checksums.py | 22 +- .../transforms/beetmover_geckoview.py | 36 +- .../transforms/beetmover_integration.py | 29 +- .../beetmover_langpack_checksums.py | 24 +- .../transforms/beetmover_push_to_release.py | 34 +- .../transforms/beetmover_repackage.py | 38 +- .../transforms/beetmover_repackage_l10n.py | 1 - .../transforms/beetmover_repackage_partner.py | 136 +- .../transforms/beetmover_repackage_rpm.py | 18 +- .../transforms/beetmover_source_checksums.py | 24 +- .../gecko_taskgraph/transforms/bootstrap.py | 28 +- .../transforms/bouncer_aliases.py | 31 +- .../transforms/bouncer_check.py | 20 +- .../transforms/bouncer_submission.py | 13 +- .../transforms/bouncer_submission_partners.py | 43 +- .../gecko_taskgraph/transforms/build.py | 25 +- .../gecko_taskgraph/transforms/build_attrs.py | 10 +- .../transforms/build_signing.py | 1 - .../transforms/cached_tasks.py | 12 +- .../transforms/chunk_partners.py | 1 - .../gecko_taskgraph/transforms/code_review.py | 1 - .../gecko_taskgraph/transforms/condprof.py | 38 +- .../gecko_taskgraph/transforms/diffoscope.py | 80 +- .../transforms/docker_image.py | 58 +- .../gecko_taskgraph/transforms/fetch.py | 82 +- .../transforms/final_verify.py | 1 - .../geckodriver_mac_notarization.py | 24 +- .../transforms/geckodriver_signing.py | 26 +- .../transforms/hardened_signing.py | 14 +- .../transforms/job/__init__.py | 178 ++- .../gecko_taskgraph/transforms/job/common.py | 88 +- .../transforms/job/distro_package.py | 85 +- .../gecko_taskgraph/transforms/job/hazard.py | 43 +- .../gecko_taskgraph/transforms/job/mach.py | 38 +- .../transforms/job/mozharness.py | 207 ++- .../transforms/job/mozharness_test.py | 140 +- .../transforms/job/python_test.py | 27 +- .../transforms/job/run_task.py | 120 +- .../transforms/job/spidermonkey.py | 71 +- .../transforms/job/toolchain.py | 106 +- .../gecko_taskgraph/transforms/l10n.py | 218 ++- .../gecko_taskgraph/transforms/mar_signing.py | 17 +- .../transforms/maybe_release.py | 2 +- .../transforms/merge_automation.py | 2 +- .../transforms/openh264_signing.py | 25 +- .../gecko_taskgraph/transforms/partials.py | 28 +- .../transforms/partials_zucchini.py | 17 +- .../transforms/partner_attribution.py | 12 +- .../partner_attribution_beetmover.py | 62 +- .../transforms/partner_repack.py | 24 +- .../transforms/partner_signing.py | 6 +- .../gecko_taskgraph/transforms/perftest.py | 114 +- .../release_beetmover_signed_addons.py | 40 +- .../transforms/release_flatpak_push.py | 36 +- .../transforms/release_generate_checksums.py | 2 +- .../release_generate_checksums_beetmover.py | 36 +- .../release_generate_checksums_signing.py | 22 +- .../transforms/release_mark_as_shipped.py | 4 +- .../transforms/release_msix_push.py | 34 +- .../transforms/release_notifications.py | 19 +- .../release_sign_and_push_langpacks.py | 38 +- .../transforms/release_started.py | 1 + .../release_update_product_channel_version.py | 2 +- .../gecko_taskgraph/transforms/repackage.py | 344 +++-- .../transforms/repackage_l10n.py | 1 - .../transforms/repackage_partner.py | 133 +- .../repackage_set_upstream_mac_kind.py | 2 +- .../transforms/repackage_signing.py | 50 +- .../transforms/repackage_signing_partner.py | 54 +- .../transforms/reprocess_symbols.py | 1 - .../transforms/scriptworker.py | 1 - .../transforms/scriptworker_canary.py | 14 +- .../transforms/shippable_l10n_signing.py | 32 +- .../gecko_taskgraph/transforms/signing.py | 74 +- .../gecko_taskgraph/transforms/snap_test.py | 4 +- .../transforms/source_checksums_signing.py | 22 +- .../gecko_taskgraph/transforms/source_test.py | 65 +- .../transforms/split_by_locale.py | 30 +- .../gecko_taskgraph/transforms/task.py | 413 +++--- .../transforms/test/__init__.py | 546 ++++---- .../gecko_taskgraph/transforms/test/chunk.py | 6 +- .../gecko_taskgraph/transforms/test/other.py | 18 +- .../gecko_taskgraph/transforms/test/raptor.py | 146 +- .../transforms/test/variant.py | 24 +- .../gecko_taskgraph/transforms/test_apk.py | 3 +- .../gecko_taskgraph/transforms/update_test.py | 6 +- .../transforms/update_verify.py | 1 - .../transforms/update_verify_config.py | 10 +- .../transforms/upload_symbols.py | 1 - .../gecko_taskgraph/util/attributes.py | 10 +- .../gecko_taskgraph/util/cached_tasks.py | 6 +- taskcluster/gecko_taskgraph/util/chunking.py | 1 - taskcluster/gecko_taskgraph/util/docker.py | 23 +- taskcluster/gecko_taskgraph/util/partners.py | 25 +- .../gecko_taskgraph/util/scriptworker.py | 101 +- taskcluster/gecko_taskgraph/util/verify.py | 14 +- .../gecko_taskgraph/util/workertypes.py | 24 +- .../scripts/are_dependencies_completed.py | 8 +- taskcluster/scripts/get-secret.py | 22 +- .../lint/update_buildconfig_from_gradle.py | 6 +- .../scripts/misc/fetch-cft-chromedriver.py | 1 - taskcluster/scripts/misc/repack_rust.py | 40 +- .../tests/generate-flaky-report-from-ftl.py | 38 +- .../scripts/tests/parse-junit-results.py | 24 +- taskcluster/scripts/tests/test-lab.py | 20 +- taskcluster/test/test_mach_try_auto.py | 30 +- taskcluster/test/test_new_config.py | 52 +- testing/awsy/awsy/parse_about_memory.py | 12 +- testing/awsy/awsy/process_perf_data.py | 6 +- testing/awsy/mach_commands.py | 3 +- testing/condprofile/condprof/archiver.py | 4 +- testing/condprofile/condprof/changelog.py | 1 + testing/condprofile/condprof/check_install.py | 27 +- testing/condprofile/condprof/main.py | 4 +- testing/condprofile/condprof/metadata.py | 4 +- .../condprofile/condprof/tests/test_runner.py | 2 +- .../safebrowsing/test_initial_download.py | 36 +- .../functional/security/test_https_first.py | 1 - testing/gtest/reports.py | 10 +- testing/gtest/rungtests.py | 4 +- testing/mach_commands.py | 27 +- testing/manifest/clean_skipfails.py | 11 +- testing/manifest/failedplatform.py | 20 +- testing/manifest/parse_reftest.py | 10 +- testing/manifest/skipfails.py | 42 +- testing/manifest/test/test_failedplatform.py | 246 ++-- .../client/marionette_driver/geckoinstance.py | 28 +- .../client/marionette_driver/marionette.py | 15 +- .../marionette_test/testcases.py | 3 +- .../harness/marionette_harness/runner/base.py | 107 +- testing/mochitest/leaks.py | 39 +- testing/mochitest/mochitest_options.py | 4 +- testing/mochitest/runjunit.py | 18 +- testing/mochitest/runtests.py | 167 ++- testing/mochitest/tests/python/conftest.py | 28 +- .../tests/python/test_create_directories.py | 44 +- .../tests/python/test_message_logger.py | 20 +- .../python/test_mochitest_integration.py | 10 +- .../manifestparser/manifestparser/cli.py | 1 + .../manifestparser/expression.py | 40 +- .../manifestparser/manifestparser/ini.py | 14 +- .../manifestparser/manifestparser.py | 12 +- .../tests/test_manifestparser.py | 39 +- testing/mozbase/mozcrash/mozcrash/__init__.py | 1 + .../mozcrash/tests/test_symbols_path.py | 20 +- testing/mozbase/mozdebug/mozdebug/__init__.py | 1 + testing/mozbase/mozdevice/mozdevice/adb.py | 166 ++- testing/mozbase/mozdevice/mozdevice/ios.py | 36 +- .../mozdevice/mozdevice/version_codes.py | 1 + testing/mozbase/mozfile/mozfile/mozfile.py | 22 +- .../mozbase/mozfile/tests/test_tempfile.py | 1 + testing/mozbase/mozfile/tests/test_url.py | 1 + .../mozgeckoprofiler/__init__.py | 1 + .../mozgeckoprofiler/profiling.py | 55 +- .../mozgeckoprofiler/symbolication.py | 10 +- testing/mozbase/mozhttpd/mozhttpd/__init__.py | 1 + testing/mozbase/mozhttpd/mozhttpd/mozhttpd.py | 8 +- testing/mozbase/mozhttpd/tests/api.py | 8 +- testing/mozbase/mozinfo/mozinfo/mozinfo.py | 10 +- .../mozbase/mozinfo/mozinfo/platforminfo.py | 1 - .../mozinstall/mozinstall/mozinstall.py | 2 +- testing/mozbase/mozlog/mozlog/commandline.py | 14 +- .../mozlog/mozlog/formatters/errorsummary.py | 12 +- .../mozlog/mozlog/formatters/grouping.py | 2 +- .../mozlog/mozlog/formatters/html/html.py | 34 +- .../mozlog/mozlog/formatters/html/xmlgen.py | 64 +- .../mozlog/mozlog/formatters/machformatter.py | 32 +- .../mozlog/mozlog/formatters/tbplformatter.py | 8 +- .../mozlog/mozlog/formatters/unittest.py | 24 +- .../mozbase/mozlog/mozlog/formatters/xunit.py | 16 +- .../mozbase/mozlog/tests/test_formatters.py | 4 +- testing/mozbase/mozlog/tests/test_logger.py | 36 +- .../mozbase/mozlog/tests/test_structured.py | 509 ++++--- .../moznetwork/moznetwork/moznetwork.py | 10 +- .../mozpower/mozpower/intel_power_gadget.py | 36 +- testing/mozbase/mozpower/mozpower/mozpower.py | 2 +- testing/mozbase/mozpower/tests/conftest.py | 4 +- .../mozbase/mozpower/tests/test_mozpower.py | 8 +- .../mozprocess/mozprocess/mozprocess.py | 2 +- .../mozprocess/mozprocess/winprocess.py | 16 +- testing/mozbase/mozprocess/tests/proctest.py | 4 +- testing/mozbase/mozprofile/mozprofile/cli.py | 3 +- .../mozprofile/mozprofile/permissions.py | 13 +- .../mozbase/mozprofile/mozprofile/prefs.py | 1 + .../mozbase/mozprofile/mozprofile/profile.py | 64 +- testing/mozbase/mozprofile/mozprofile/view.py | 1 + .../mozproxy/mozproxy/backends/mitm/mitm.py | 126 +- .../mitm/scripts/alternate-server-replay.py | 18 +- testing/mozbase/mozproxy/mozproxy/driver.py | 64 +- .../mozproxy/tests/test_command_line.py | 16 +- .../mozrunner/mozrunner/devices/ios_device.py | 32 +- .../mozbase/mozrunner/mozrunner/runners.py | 2 +- testing/mozbase/mozserve/mozserve/servers.py | 2 +- .../mozshellutil/mozshellutil/__init__.py | 1 + .../mozsystemmonitor/resourcemonitor.py | 115 +- testing/mozbase/moztest/moztest/resolve.py | 140 +- testing/mozbase/moztest/tests/test_resolve.py | 212 +-- testing/mozbase/setup_development.py | 6 +- testing/mozbase/versioninfo.py | 20 +- .../builds/releng_base_mac_64_cross_builds.py | 2 +- testing/mozharness/mozharness/base/config.py | 30 +- .../mozharness/mozharness/base/diskutils.py | 45 +- testing/mozharness/mozharness/base/log.py | 10 +- .../mozharness/mozharness/base/parallel.py | 3 +- testing/mozharness/mozharness/base/python.py | 91 +- testing/mozharness/mozharness/base/script.py | 20 +- .../mozharness/mozharness/base/transfer.py | 3 +- .../mozharness/base/vcs/mercurial.py | 5 +- .../mozharness/mozharness/base/vcs/vcsbase.py | 3 +- .../mozharness/lib/python/authentication.py | 1 + .../mozharness/mozilla/automation.py | 3 +- .../mozharness/mozilla/building/buildbase.py | 100 +- .../mozharness/mozilla/firefox/autoconfig.py | 2 +- .../mozharness/mozharness/mozilla/secrets.py | 3 +- .../mozilla/testing/per_test_base.py | 111 +- .../mozharness/mozilla/testing/raptor.py | 100 +- .../mozharness/mozilla/testing/talos.py | 50 +- .../mozharness/mozharness/mozilla/tooltool.py | 8 +- .../mozharness/mozharness/mozilla/vcstools.py | 1 + .../scripts/android_emulator_pgo.py | 6 +- .../scripts/android_emulator_unittest.py | 18 +- .../scripts/android_hardware_unittest.py | 6 +- .../scripts/desktop_partner_repacks.py | 1 + .../mozharness/scripts/desktop_unittest.py | 42 +- testing/mozharness/scripts/does_it_crash.py | 5 +- testing/mozharness/scripts/multil10n.py | 4 +- testing/mozharness/scripts/raptor_script.py | 4 +- .../scripts/release/bouncer_check.py | 2 +- testing/mozharness/scripts/repackage.py | 30 +- testing/mozharness/scripts/talos_script.py | 4 +- testing/mozharness/test/test_base_config.py | 42 +- testing/mozharness/test/test_base_script.py | 8 +- .../test/test_base_vcs_mercurial.py | 14 +- .../android-resource/parse_resource_usage.py | 148 +-- testing/performance/hooks_recording.py | 2 +- .../android_startup_cmff_cvns.py | 9 +- .../android_startup_videoapplink.py | 27 +- testing/platform_diff.py | 8 +- .../support-scripts/browsertime_benchmark.py | 20 +- .../support-scripts/browsertime_pageload.py | 6 +- .../browsertime/support-scripts/jetstream3.py | 1 - testing/raptor/mach_commands.py | 16 +- testing/raptor/raptor/base_python_support.py | 6 +- testing/raptor/raptor/benchmark.py | 46 +- testing/raptor/raptor/browsertime/android.py | 71 +- testing/raptor/raptor/browsertime/base.py | 132 +- testing/raptor/raptor/browsertime/desktop.py | 8 +- testing/raptor/raptor/cmdline.py | 32 +- testing/raptor/raptor/gecko_profile.py | 51 +- testing/raptor/raptor/manifest.py | 44 +- testing/raptor/raptor/output.py | 59 +- testing/raptor/raptor/performance_tuning.py | 14 +- testing/raptor/raptor/perftest.py | 17 +- testing/raptor/raptor/raptor.py | 8 +- testing/raptor/raptor/raptor_profiling.py | 37 +- testing/raptor/raptor/results.py | 44 +- testing/raptor/raptor/utils.py | 2 +- testing/raptor/test/test_chrome_trace.py | 6 +- testing/raptor/test/test_raptor.py | 2 +- testing/runcppunittests.py | 26 +- testing/talos/INSTALL.py | 1 + testing/talos/mach_commands.py | 10 +- testing/talos/talos/cmanager_mac.py | 1 + testing/talos/talos/cmdline.py | 2 +- testing/talos/talos/config.py | 8 +- testing/talos/talos/ffsetup.py | 13 +- testing/talos/talos/gecko_profile.py | 73 +- testing/talos/talos/heavy.py | 1 + testing/talos/talos/mainthreadio.py | 42 +- testing/talos/talos/output.py | 15 +- testing/talos/talos/results.py | 11 +- testing/talos/talos/run_tests.py | 32 +- testing/talos/talos/talosconfig.py | 16 +- testing/talos/talos/ttest.py | 21 +- testing/talos/talos/utils.py | 16 +- testing/talos/talos/xtalos/etlparser.py | 2 +- testing/talos/talos/xtalos/parse_xperf.py | 2 +- testing/talos/talos/xtalos/start_xperf.py | 2 +- testing/talos/talos/xtalos/xtalos.py | 17 +- testing/testinfo.py | 16 +- testing/tps/create_venv.py | 8 +- testing/tps/tps/testrunner.py | 14 +- testing/update/test_apply_update.py | 6 +- testing/update/test_background_update.py | 6 +- testing/web-platform/interop.py | 6 +- testing/web-platform/mach_commands_base.py | 2 +- testing/web-platform/manifestdownload.py | 2 +- testing/web-platform/metasummary.py | 2 +- .../mozilla/tests/geolocation-API/dummy.py | 18 +- .../navigate/https_upgrade.py | 20 +- .../emulation/set_locale_override/contexts.py | 14 +- .../set_timezone_override/contexts.py | 14 +- .../add_data_collector/max_total_data_size.py | 14 +- .../classic/navigate_to/https_upgrade.py | 22 +- .../tests/webdriver/harness/detect_crash.py | 18 +- .../handlers/mozilla_push_dummy_wsh.py | 60 +- testing/web-platform/update/upstream.py | 33 +- testing/webcompat/client.py | 6 +- testing/webcompat/fixtures.py | 18 +- .../test_1902464_workhub_transcribeme_com.py | 12 +- testing/xpcshell/remotexpcshelltests.py | 19 +- testing/xpcshell/runxpcshelltests.py | 40 +- testing/xpcshell/selftest.py | 6 +- testing/xpcshell/xpcshellcommandline.py | 4 +- ...test_bouncetracking_storage_persistence.py | 10 +- ...protection_allow_list_prefs_persistence.py | 14 +- .../test_moved_origin_directory_cleanup.py | 14 +- .../webidl-api/GenerateWebIDLBindings.py | 34 +- .../test/test_json_schema_parsing.py | 82 +- .../test/test_webidl_from_json_schema.py | 32 +- .../build_scripts/glean_parser_ext/js.py | 18 +- .../glean_parser_ext/metrics_header_names.py | 10 +- .../glean_parser_ext/run_glean_parser.py | 16 +- .../build_scripts/glean_parser_ext/util.py | 1 + .../glean/tests/pytest/test_yaml_indices.py | 6 +- .../generate/generate_feature_manifest.py | 26 +- .../telemetry/build_scripts/gen_event_data.py | 26 +- .../build_scripts/gen_scalar_data.py | 28 +- .../telemetry/build_scripts/mach_commands.py | 8 +- .../mozparsers/parse_histograms.py | 2 +- .../build_scripts/mozparsers/parse_scalars.py | 2 +- .../mozparsers/parse_user_interactions.py | 3 +- .../tests/integration/tests/conftest.py | 12 +- .../harness/telemetry_harness/fog_testcase.py | 30 +- .../harness/telemetry_harness/runner.py | 60 +- .../harness/telemetry_harness/testcase.py | 12 +- .../tests/client/test_fog_usage_reporting.py | 24 +- .../tests/client/test_fog_user_activity.py | 30 +- .../telemetry/tests/python/test_mirrors.py | 100 +- .../tests/python/test_no_expired_probes.py | 6 +- .../bergamot-translator/build-bergamot.py | 6 +- .../bergamot-translator/upload-bergamot.py | 2 +- toolkit/crashreporter/annotations/generate.py | 2 +- .../crashreporter/crashping/conversions.py | 2 +- .../crashreporter/crashping/glean_metrics.py | 26 +- toolkit/crashreporter/tools/symbolstore.py | 60 +- .../crashreporter/tools/unit-symbolstore.py | 12 +- toolkit/library/libxul.so-gdb.py | 2 +- .../mozglue/gen_dll_blocklist_defs.py | 12 +- .../xre/test/marionette/gen_win32k_tests.py | 8 +- .../test_xdg_config_legacy_existing.py | 1 - .../test_xdg_config_legacy_forced.py | 1 - .../xdg_config/test_xdg_config_new.py | 1 - .../xdg_config/test_xdg_config_new_env.py | 1 - .../test_xdg_config_new_env_invalid.py | 1 - .../test_xdg_config_new_existing.py | 1 - .../xdg_config/xdg_config_home_test_case.py | 6 +- tools/browsertime/mach_commands.py | 23 +- .../system-symbols/mac/PackageSymbolDumper.py | 1 + tools/fuzzing/smoke/js.py | 3 +- tools/fuzzing/smoke/smoke.py | 3 +- tools/fuzzing/smoke/test_grizzly.py | 6 +- tools/lint/android/lints.py | 4 +- tools/lint/cargo-audit/__init__.py | 23 +- tools/lint/eslint/__init__.py | 23 +- tools/lint/eslint/prettier_utils.py | 4 +- tools/lint/fluent-lint/__init__.py | 9 +- tools/lint/glean-parser/__init__.py | 5 +- tools/lint/includes/std.py | 2 +- tools/lint/libpref/__init__.py | 30 +- tools/lint/mach_commands.py | 16 +- tools/lint/node-licenses/__init__.py | 2 +- tools/lint/perfdocs/framework_gatherers.py | 12 +- tools/lint/perfdocs/generator.py | 36 +- tools/lint/rst/__init__.py | 8 +- tools/lint/stylelint/__init__.py | 23 +- tools/lint/test/test_includes.py | 12 +- tools/lint/test/test_perfdocs_generation.py | 6 +- tools/lint/test/test_perfdocs_helpers.py | 26 +- tools/lint/wpt/wpt.py | 2 +- tools/mach_commands.py | 16 +- tools/moztreedocs/__init__.py | 10 +- tools/moztreedocs/mach_commands.py | 8 +- tools/rb/find_leakers.py | 4 +- tools/signing/macos/mach_commands.py | 16 +- tools/tryselect/selectors/coverage.py | 24 +- tools/tryselect/selectors/perf.py | 29 +- tools/tryselect/selectors/perf_preview.py | 1 - tools/tryselect/selectors/preview.py | 1 - tools/tryselect/selectors/release.py | 12 +- tools/tryselect/test/test_auto.py | 7 +- .../test/test_mozharness_integration.py | 10 +- tools/tryselect/test/test_perf.py | 25 +- tools/tryselect/test/test_presets.py | 2 +- tools/tryselect/test/test_selectors.py | 42 +- tools/tryselect/test/test_task_configs.py | 2 +- tools/tryselect/util/fzf.py | 6 +- tools/ts/mach_commands.py | 8 +- .../make_incremental_zucchini.py | 6 +- tools/update-programs/mach_commands.py | 1 - tools/update-verify/scripts/async_download.py | 4 +- xpcom/base/ErrorList.py | 8 +- xpcom/components/gen_static_components.py | 9 +- xpcom/ds/StaticAtoms.py | 26 +- xpcom/ds/tools/make_dafsa.py | 1 + xpcom/ds/tools/perfecthash.py | 72 +- xpcom/idl-parser/xpidl/header.py | 16 +- xpcom/idl-parser/xpidl/jsonxpt.py | 36 +- xpcom/idl-parser/xpidl/xpidl.py | 30 +- 738 files changed, 10435 insertions(+), 12200 deletions(-) diff --git a/accessible/tests/browser/windows/a11y_setup.py b/accessible/tests/browser/windows/a11y_setup.py index 40e306152b83e..719b06fa9b983 100644 --- a/accessible/tests/browser/windows/a11y_setup.py +++ b/accessible/tests/browser/windows/a11y_setup.py @@ -2,8 +2,7 @@ # 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/. -"""Python environment for Windows a11y browser tests. -""" +"""Python environment for Windows a11y browser tests.""" import ctypes import os diff --git a/browser/components/asrouter/content-src/schemas/make-schemas.py b/browser/components/asrouter/content-src/schemas/make-schemas.py index 570f27ba6e30c..f4b325a1f0937 100755 --- a/browser/components/asrouter/content-src/schemas/make-schemas.py +++ b/browser/components/asrouter/content-src/schemas/make-schemas.py @@ -262,13 +262,11 @@ def dfn_filter(name): # patch_schema mutates the given schema, so we read a new copy in for # each bundle operation. - defs.update( - { - name: dfn - for name, dfn in common_schema["$defs"].items() - if dfn_filter(name) - } - ) + defs.update({ + name: dfn + for name, dfn in common_schema["$defs"].items() + if dfn_filter(name) + }) # Ensure all bundled schemas have an $id so that $refs inside the # bundled schema work correctly (i.e, they will reference the subschema diff --git a/browser/components/backup/tests/marionette/test_backup.py b/browser/components/backup/tests/marionette/test_backup.py index 924c36779cd13..402af08ab54ea 100644 --- a/browser/components/backup/tests/marionette/test_backup.py +++ b/browser/components/backup/tests/marionette/test_backup.py @@ -21,19 +21,17 @@ def setUp(self): # We need to force the service to be enabled because it's disabled # by default for Marionette. Also "browser.backup.log" has to be set # to true before Firefox starts in order for it to be displayed. - self.marionette.enforce_gecko_prefs( - { - "browser.backup.enabled": True, - "browser.backup.log": True, - "browser.backup.archive.enabled": True, - "browser.backup.restore.enabled": True, - "browser.backup.archive.overridePlatformCheck": True, - "browser.backup.restore.overridePlatformCheck": True, - # Necessary to test Session Restore from backup, which relies on - # the crash restore mechanism. - "browser.sessionstore.resume_from_crash": True, - } - ) + self.marionette.enforce_gecko_prefs({ + "browser.backup.enabled": True, + "browser.backup.log": True, + "browser.backup.archive.enabled": True, + "browser.backup.restore.enabled": True, + "browser.backup.archive.overridePlatformCheck": True, + "browser.backup.restore.overridePlatformCheck": True, + # Necessary to test Session Restore from backup, which relies on + # the crash restore mechanism. + "browser.sessionstore.resume_from_crash": True, + }) self.marionette.set_context("chrome") diff --git a/browser/components/search/test/marionette/telemetry/test_ping_submitted.py b/browser/components/search/test/marionette/telemetry/test_ping_submitted.py index a1eaf25a80c28..81244cead59c9 100644 --- a/browser/components/search/test/marionette/telemetry/test_ping_submitted.py +++ b/browser/components/search/test/marionette/telemetry/test_ping_submitted.py @@ -12,13 +12,11 @@ def setUp(self): self.marionette.set_context(self.marionette.CONTEXT_CHROME) - self.marionette.enforce_gecko_prefs( - { - "datareporting.healthreport.uploadEnabled": True, - "telemetry.fog.test.localhost_port": 3000, - "browser.search.log": True, - } - ) + self.marionette.enforce_gecko_prefs({ + "datareporting.healthreport.uploadEnabled": True, + "telemetry.fog.test.localhost_port": 3000, + "browser.search.log": True, + }) # The categorization ping is submitted on startup. If anything delays # its initialization, turning the preference on and immediately # attaching a categorization event could result in the ping being diff --git a/browser/components/search/test/marionette/test_engines_on_restart.py b/browser/components/search/test/marionette/test_engines_on_restart.py index 5eccd58623266..8e0b6a6eb842a 100644 --- a/browser/components/search/test/marionette/test_engines_on_restart.py +++ b/browser/components/search/test/marionette/test_engines_on_restart.py @@ -10,11 +10,9 @@ class TestEnginesOnRestart(MarionetteTestCase): def setUp(self): super().setUp() - self.marionette.enforce_gecko_prefs( - { - "browser.search.log": True, - } - ) + self.marionette.enforce_gecko_prefs({ + "browser.search.log": True, + }) def get_default_search_engine(self): """Retrieve the identifier of the default search engine.""" diff --git a/browser/components/sessionstore/test/marionette/session_store_test_case.py b/browser/components/sessionstore/test/marionette/session_store_test_case.py index 4d955cc855869..593cca5e49d45 100644 --- a/browser/components/sessionstore/test/marionette/session_store_test_case.py +++ b/browser/components/sessionstore/test/marionette/session_store_test_case.py @@ -15,23 +15,21 @@ def inline(doc): # Each list element represents a window of tabs loaded at # some testing URL -DEFAULT_WINDOWS = set( - [ - # Window 1. Note the comma after the inline call - - # this is Python's way of declaring a 1 item tuple. - (inline("""Lorem"""),), - # Window 2 - ( - inline("""ipsum"""), - inline("""dolor"""), - ), - # Window 3 - ( - inline("""sit"""), - inline("""amet"""), - ), - ] -) +DEFAULT_WINDOWS = set([ + # Window 1. Note the comma after the inline call - + # this is Python's way of declaring a 1 item tuple. + (inline("""Lorem"""),), + # Window 2 + ( + inline("""ipsum"""), + inline("""dolor"""), + ), + # Window 3 + ( + inline("""sit"""), + inline("""amet"""), + ), +]) class SessionStoreTestCase(WindowManagerMixin, MarionetteTestCase): @@ -53,37 +51,33 @@ def setUp( self.test_windows = test_windows - self.private_windows = set( - [ - ( - inline("""consectetur"""), - inline("""ipsum"""), - ), - ( - inline("""adipiscing"""), - inline("""consectetur"""), - ), - ] - ) - - self.marionette.enforce_gecko_prefs( - { - # Set browser restore previous session pref, - # depending on what the test requires. - "browser.startup.page": startup_page, - # Make the content load right away instead of waiting for - # the user to click on the background tabs - "browser.sessionstore.restore_on_demand": restore_on_demand, - # Avoid race conditions by having the content process never - # send us session updates unless the parent has explicitly asked - # for them via the TabStateFlusher. - "browser.sessionstore.debug.no_auto_updates": no_auto_updates, - # Whether to enable the register application restart mechanism. - "toolkit.winRegisterApplicationRestart": win_register_restart, - # Whether to enable taskbar tabs for this test - "browser.taskbarTabs.enabled": taskbartabs_enable, - } - ) + self.private_windows = set([ + ( + inline("""consectetur"""), + inline("""ipsum"""), + ), + ( + inline("""adipiscing"""), + inline("""consectetur"""), + ), + ]) + + self.marionette.enforce_gecko_prefs({ + # Set browser restore previous session pref, + # depending on what the test requires. + "browser.startup.page": startup_page, + # Make the content load right away instead of waiting for + # the user to click on the background tabs + "browser.sessionstore.restore_on_demand": restore_on_demand, + # Avoid race conditions by having the content process never + # send us session updates unless the parent has explicitly asked + # for them via the TabStateFlusher. + "browser.sessionstore.debug.no_auto_updates": no_auto_updates, + # Whether to enable the register application restart mechanism. + "toolkit.winRegisterApplicationRestart": win_register_restart, + # Whether to enable taskbar tabs for this test + "browser.taskbarTabs.enabled": taskbartabs_enable, + }) self.all_windows = self.test_windows.copy() self.open_windows(self.test_windows) diff --git a/browser/components/sessionstore/test/marionette/test_log_files.py b/browser/components/sessionstore/test/marionette/test_log_files.py index 0b2b3477a4b95..070fb252f387b 100644 --- a/browser/components/sessionstore/test/marionette/test_log_files.py +++ b/browser/components/sessionstore/test/marionette/test_log_files.py @@ -16,12 +16,10 @@ def inline(doc): class TestSessionRestoreLogging(WindowManagerMixin, MarionetteTestCase): def setUp(self): super().setUp() - self.marionette.enforce_gecko_prefs( - { - "browser.sessionstore.loglevel": "Debug", - "browser.sessionstore.log.appender.file.logOnSuccess": True, - } - ) + self.marionette.enforce_gecko_prefs({ + "browser.sessionstore.loglevel": "Debug", + "browser.sessionstore.log.appender.file.logOnSuccess": True, + }) def tearDown(self): try: @@ -101,11 +99,9 @@ def test_per_startup_logfile_creation(self): self.marionette.start_session() def test_errors_flush_to_disk(self): - self.marionette.enforce_gecko_prefs( - { - "browser.sessionstore.log.appender.file.logOnSuccess": False, - } - ) + self.marionette.enforce_gecko_prefs({ + "browser.sessionstore.log.appender.file.logOnSuccess": False, + }) self.marionette.quit() sessionFile = self.getSessionFilePath() self.assertTrue( @@ -114,7 +110,7 @@ def test_errors_flush_to_disk(self): ) # replace the contents with nonsense so we get a not-readable error on startup with open(sessionFile, "wb") as f: - f.write(b"\x00\xFF\xABgarbageDATA") + f.write(b"\x00\xff\xabgarbageDATA") self.marionette.start_session() self.marionette.set_context("chrome") diff --git a/browser/components/sessionstore/test/marionette/test_persist_closed_tabs_restore_manually.py b/browser/components/sessionstore/test/marionette/test_persist_closed_tabs_restore_manually.py index 011eac40905ee..1a58a92dabe0d 100644 --- a/browser/components/sessionstore/test/marionette/test_persist_closed_tabs_restore_manually.py +++ b/browser/components/sessionstore/test/marionette/test_persist_closed_tabs_restore_manually.py @@ -33,15 +33,13 @@ def setUp(self): startup_page=1, include_private=False, restore_on_demand=True, - test_windows=set( - [ - # Window 1 - ( - inline("lorem ipsom"), - inline("dolor"), - ), - ] - ), + test_windows=set([ + # Window 1 + ( + inline("lorem ipsom"), + inline("dolor"), + ), + ]), ) def test_restore(self): diff --git a/browser/components/sessionstore/test/marionette/test_restore_manually.py b/browser/components/sessionstore/test/marionette/test_restore_manually.py index 42b3b5c640caa..0f3291f2e8b79 100644 --- a/browser/components/sessionstore/test/marionette/test_restore_manually.py +++ b/browser/components/sessionstore/test/marionette/test_restore_manually.py @@ -26,17 +26,15 @@ def setUp(self): startup_page=1, include_private=False, restore_on_demand=True, - test_windows=set( - [ - # Window 1 - ( - inline("lorem ipsom"), - inline("dolor"), - ), - # Window 2 - (inline("sit"),), - ] - ), + test_windows=set([ + # Window 1 + ( + inline("lorem ipsom"), + inline("dolor"), + ), + # Window 2 + (inline("sit"),), + ]), ) def test_restore(self): diff --git a/browser/components/sessionstore/test/marionette/test_restore_manually_with_pinned_tabs.py b/browser/components/sessionstore/test/marionette/test_restore_manually_with_pinned_tabs.py index 9266edc54740c..5e92dce2b0a46 100644 --- a/browser/components/sessionstore/test/marionette/test_restore_manually_with_pinned_tabs.py +++ b/browser/components/sessionstore/test/marionette/test_restore_manually_with_pinned_tabs.py @@ -23,16 +23,14 @@ def setUp(self): startup_page=1, include_private=False, restore_on_demand=True, - test_windows=set( - [ - # Window 1 - ( - inline("""ipsum"""), - inline("""dolor"""), - inline("""amet"""), - ), - ] - ), + test_windows=set([ + # Window 1 + ( + inline("""ipsum"""), + inline("""dolor"""), + inline("""amet"""), + ), + ]), ) def test_no_restore_with_quit(self): diff --git a/browser/components/sessionstore/test/marionette/test_restore_manually_with_tab_groups.py b/browser/components/sessionstore/test/marionette/test_restore_manually_with_tab_groups.py index dd60bb6bd75f6..bee623e8e8ed0 100644 --- a/browser/components/sessionstore/test/marionette/test_restore_manually_with_tab_groups.py +++ b/browser/components/sessionstore/test/marionette/test_restore_manually_with_tab_groups.py @@ -23,17 +23,15 @@ def setUp(self): startup_page=1, include_private=False, restore_on_demand=True, - test_windows=set( - [ - ( - inline("""lorem"""), - inline("""ipsum"""), - inline("""dolor"""), - inline("""sit"""), - inline("""amet"""), - ), - ] - ), + test_windows=set([ + ( + inline("""lorem"""), + inline("""ipsum"""), + inline("""dolor"""), + inline("""sit"""), + inline("""amet"""), + ), + ]), ) def test_no_restore_with_quit(self): diff --git a/browser/components/sessionstore/test/marionette/test_restore_sidebar.py b/browser/components/sessionstore/test/marionette/test_restore_sidebar.py index 9ca6ee46d7063..fcccf7c137fe5 100644 --- a/browser/components/sessionstore/test/marionette/test_restore_sidebar.py +++ b/browser/components/sessionstore/test/marionette/test_restore_sidebar.py @@ -25,14 +25,12 @@ def setUp(self): startup_page=1, include_private=False, restore_on_demand=True, - test_windows=set( - [ - ( - inline("lorem ipsom"), - inline("dolor"), - ), - ] - ), + test_windows=set([ + ( + inline("lorem ipsom"), + inline("dolor"), + ), + ]), ) def test_restore_sidebar_open(self): diff --git a/browser/components/sessionstore/test/marionette/test_restore_sidebar_automatic.py b/browser/components/sessionstore/test/marionette/test_restore_sidebar_automatic.py index cad527b8aa881..19c64844cdc71 100644 --- a/browser/components/sessionstore/test/marionette/test_restore_sidebar_automatic.py +++ b/browser/components/sessionstore/test/marionette/test_restore_sidebar_automatic.py @@ -25,14 +25,12 @@ def setUp(self): startup_page=3, include_private=False, restore_on_demand=False, - test_windows=set( - [ - ( - inline("lorem ipsom"), - inline("dolor"), - ), - ] - ), + test_windows=set([ + ( + inline("lorem ipsom"), + inline("dolor"), + ), + ]), ) def test_restore(self): diff --git a/browser/components/sessionstore/test/marionette/test_tabgroups_restore.py b/browser/components/sessionstore/test/marionette/test_tabgroups_restore.py index 501075b906c8f..f3fdee269f85c 100644 --- a/browser/components/sessionstore/test/marionette/test_tabgroups_restore.py +++ b/browser/components/sessionstore/test/marionette/test_tabgroups_restore.py @@ -19,13 +19,11 @@ def inline(doc): # Each list element represents a window of tabs loaded at # some testing URL -DEFAULT_WINDOWS = set( - [ - # Window 1. Note the comma after the inline call - - # this is Python's way of declaring a 1 item tuple. - (inline("""Lorem"""), inline("""Ipsum""")), - ] -) +DEFAULT_WINDOWS = set([ + # Window 1. Note the comma after the inline call - + # this is Python's way of declaring a 1 item tuple. + (inline("""Lorem"""), inline("""Ipsum""")), +]) class TestAutoRestoreWithTabGroups(SessionStoreTestCase): diff --git a/browser/components/sessionstore/test/marionette/test_taskbartab_restore.py b/browser/components/sessionstore/test/marionette/test_taskbartab_restore.py index 96baf1c796fd1..de6b8e2667a70 100644 --- a/browser/components/sessionstore/test/marionette/test_taskbartab_restore.py +++ b/browser/components/sessionstore/test/marionette/test_taskbartab_restore.py @@ -24,15 +24,13 @@ def setUp(self): include_private=False, restore_on_demand=False, taskbartabs_enable=True, - test_windows=set( - [ - # Window 1 - ( - inline("lorem ipsom"), - inline("dolor"), - ), - ] - ), + test_windows=set([ + # Window 1 + ( + inline("lorem ipsom"), + inline("dolor"), + ), + ]), ) """ @@ -94,15 +92,13 @@ def setUp(self): include_private=False, restore_on_demand=False, taskbartabs_enable=True, - test_windows=set( - [ - # Window 1 - ( - inline("lorem ipsom"), - inline("dolor"), - ), - ] - ), + test_windows=set([ + # Window 1 + ( + inline("lorem ipsom"), + inline("dolor"), + ), + ]), ) """ diff --git a/browser/components/sessionstore/test/marionette/test_taskbartab_sessionstate.py b/browser/components/sessionstore/test/marionette/test_taskbartab_sessionstate.py index 0ffc6aa5fbb56..7f75f27dffe8f 100644 --- a/browser/components/sessionstore/test/marionette/test_taskbartab_sessionstate.py +++ b/browser/components/sessionstore/test/marionette/test_taskbartab_sessionstate.py @@ -22,15 +22,13 @@ def setUp(self): include_private=False, restore_on_demand=False, taskbartabs_enable=True, - test_windows=set( - [ - # Window 1 - ( - inline("lorem ipsom"), - inline("dolor"), - ), - ] - ), + test_windows=set([ + # Window 1 + ( + inline("lorem ipsom"), + inline("dolor"), + ), + ]), ) """ diff --git a/browser/components/sidebar/tests/marionette/test_default_launcher_visible.py b/browser/components/sidebar/tests/marionette/test_default_launcher_visible.py index ac639b04d8391..7fa0792519763 100644 --- a/browser/components/sidebar/tests/marionette/test_default_launcher_visible.py +++ b/browser/components/sidebar/tests/marionette/test_default_launcher_visible.py @@ -15,7 +15,6 @@ class TestDefaultLauncherVisible(MarionetteTestCase): - def setUp(self): MarionetteTestCase.setUp(self) @@ -106,12 +105,10 @@ def test_first_use_default_visible_pref_false(self): ) # Mimic an update which enables sidebar.revamp for the first time - self.restart_with_prefs( - { - "sidebar.revamp": True, - "browser.startup.page": 3, - } - ) + self.restart_with_prefs({ + "sidebar.revamp": True, + "browser.startup.page": 3, + }) self.assertTrue( self.is_button_visible(), @@ -222,12 +219,10 @@ def test_new_sidebar_enabled_at_runtime_via_nimbus(self): ) # This mocks the enrollment in which Nimbus sets the following prefs - self.marionette.set_prefs( - { - "sidebar.revamp": True, - "sidebar.revamp.defaultLauncherVisible": False, - } - ) + self.marionette.set_prefs({ + "sidebar.revamp": True, + "sidebar.revamp.defaultLauncherVisible": False, + }) # We expect enabling the pref to add the button to the toolbar Wait(self.marionette).until( @@ -254,13 +249,11 @@ def test_new_sidebar_enabled_at_runtime_via_nimbus(self): def test_vertical_tabs_default_hidden(self): # Verify that starting with verticalTabs enabled and default visibility false results in a visible # launcher with the vertical tabstrip - self.restart_with_prefs( - { - "sidebar.revamp": True, - "sidebar.verticalTabs": True, - "sidebar.visibility": "always-show", - } - ) + self.restart_with_prefs({ + "sidebar.revamp": True, + "sidebar.verticalTabs": True, + "sidebar.visibility": "always-show", + }) Wait(self.marionette).until( lambda _: self.is_launcher_visible(), diff --git a/browser/components/sidebar/tests/marionette/test_initialize_vertical_tabs.py b/browser/components/sidebar/tests/marionette/test_initialize_vertical_tabs.py index 0a52b863c5f77..ef9ca5b2c3ecd 100644 --- a/browser/components/sidebar/tests/marionette/test_initialize_vertical_tabs.py +++ b/browser/components/sidebar/tests/marionette/test_initialize_vertical_tabs.py @@ -97,14 +97,12 @@ def check_tabs_toolbar_visibilities(self, orientation="vertical"): def test_vertical_widgets_in_area(self): # A clean startup in verticalTabs mode; we should get all the defaults - self.restart_with_prefs( - { - "sidebar.revamp": True, - "sidebar.verticalTabs": True, - customization_pref: None, - snapshot_pref: None, - } - ) + self.restart_with_prefs({ + "sidebar.revamp": True, + "sidebar.verticalTabs": True, + customization_pref: None, + snapshot_pref: None, + }) horiz_tab_ids = self.get_area_widgets("AREA_TABSTRIP") vertical_tab_ids = self.get_area_widgets("AREA_VERTICAL_TABSTRIP") @@ -153,13 +151,11 @@ def test_restore_tabstrip_customizations(self): "sidebar.revamp": True, "sidebar.verticalTabs": False, } - self.restart_with_prefs( - { - **fixture_prefs, - customization_pref: None, - snapshot_pref: None, - } - ) + self.restart_with_prefs({ + **fixture_prefs, + customization_pref: None, + snapshot_pref: None, + }) # Add a widget at the start of the horizontal tabstrip # This is synchronous and should result in updating the UI and the saved state in uiCustomization pref @@ -222,13 +218,11 @@ def test_preserve_visibility_pref_after_restart(self): "sidebar.verticalTabs": True, "sidebar.visibility": "hide-sidebar", } - self.restart_with_prefs( - { - **fixture_prefs, - customization_pref: None, - snapshot_pref: None, - } - ) + self.restart_with_prefs({ + **fixture_prefs, + customization_pref: None, + snapshot_pref: None, + }) pref_value = self.marionette.execute_script( """ @@ -265,12 +259,10 @@ def test_preserve_visibility_pref_after_restart(self): def test_hide_drag_to_pin_promo_if_horizontal_tabs_pinned(self): # Pin a tab using the horizontal tabstrip. - self.restart_with_prefs( - { - "sidebar.revamp": False, - "sidebar.verticalTabs": False, - } - ) + self.restart_with_prefs({ + "sidebar.revamp": False, + "sidebar.verticalTabs": False, + }) self.marionette.execute_async_script( """ let resolve = arguments[0]; diff --git a/browser/extensions/newtab/mach_commands.py b/browser/extensions/newtab/mach_commands.py index fce18f0ddf7eb..0f6c349cb5eff 100644 --- a/browser/extensions/newtab/mach_commands.py +++ b/browser/extensions/newtab/mach_commands.py @@ -104,9 +104,13 @@ def watch(command_context): processes = [] try: - p1 = subprocess.Popen( - ["./mach", "npm", "run", "watchmc", "--prefix=browser/extensions/newtab"] - ) + p1 = subprocess.Popen([ + "./mach", + "npm", + "run", + "watchmc", + "--prefix=browser/extensions/newtab", + ]) p2 = subprocess.Popen(["./mach", "watch"]) processes.extend([p1, p2]) print("Watching subprocesses started. Press Ctrl-C to terminate them.") @@ -145,9 +149,13 @@ def update_locales(command_context): # Step 1: We download the latest reckoning of strings from firefox-l10n print("Cloning the latest HEAD of firefox-l10n repository") with tempfile.TemporaryDirectory() as clone_dir: - subprocess.check_call( - ["git", "clone", "--depth=1", FIREFOX_L10N_REPO, clone_dir] - ) + subprocess.check_call([ + "git", + "clone", + "--depth=1", + FIREFOX_L10N_REPO, + clone_dir, + ]) # Step 2: Get some metadata about what we just pulled down - # specifically, the revision. revision = subprocess.check_output( @@ -831,9 +839,13 @@ def bundle(command_context): proc = None try: - proc = subprocess.Popen( - ["./mach", "npm", "run", "bundle", "--prefix=browser/extensions/newtab"] - ) + proc = subprocess.Popen([ + "./mach", + "npm", + "run", + "bundle", + "--prefix=browser/extensions/newtab", + ]) print("Bundling newtab started. Press Ctrl-C to terminate.") proc.wait() except KeyboardInterrupt: @@ -871,9 +883,12 @@ def install(command_context): proc = None try: - proc = subprocess.Popen( - ["./mach", "npm", "install", "--prefix=browser/extensions/newtab"] - ) + proc = subprocess.Popen([ + "./mach", + "npm", + "install", + "--prefix=browser/extensions/newtab", + ]) print( "Installing node dependencies for newtab started. Press Ctrl-C to terminate." ) diff --git a/build/RunCbindgen.py b/build/RunCbindgen.py index fbbe9d05842f5..bb0de610edb98 100644 --- a/build/RunCbindgen.py +++ b/build/RunCbindgen.py @@ -71,19 +71,17 @@ def generate_metadata(output, cargo_config): def generate(output, metadata_path, cbindgen_crate_path, *in_tree_dependencies): - stdout, returncode = _run_process( - [ - buildconfig.substs["CBINDGEN"], - buildconfig.topsrcdir, - "--lockfile", - CARGO_LOCK, - "--crate", - _get_crate_name(cbindgen_crate_path), - "--metadata", - metadata_path, - "--cpp-compat", - ] - ) + stdout, returncode = _run_process([ + buildconfig.substs["CBINDGEN"], + buildconfig.topsrcdir, + "--lockfile", + CARGO_LOCK, + "--crate", + _get_crate_name(cbindgen_crate_path), + "--metadata", + metadata_path, + "--cpp-compat", + ]) if returncode != 0: return returncode diff --git a/build/appini_header.py b/build/appini_header.py index 4cf9481ea099c..eb384d24592ce 100644 --- a/build/appini_header.py +++ b/build/appini_header.py @@ -3,7 +3,7 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. """Parses a given application.ini file and outputs the corresponding - StaticXREAppData structure as a C++ header file""" +StaticXREAppData structure as a C++ header file""" import configparser import sys diff --git a/build/gen_symverscript.py b/build/gen_symverscript.py index d1a5abd07d4e3..22583aa571f1b 100644 --- a/build/gen_symverscript.py +++ b/build/gen_symverscript.py @@ -11,11 +11,9 @@ def main(output, input_file, version): pp = Preprocessor() - pp.context.update( - { - "VERSION": version, - } - ) + pp.context.update({ + "VERSION": version, + }) pp.out = output pp.do_include(input_file) diff --git a/build/gen_test_packages_manifest.py b/build/gen_test_packages_manifest.py index 9baea9997e016..33af31b8d5399 100644 --- a/build/gen_test_packages_manifest.py +++ b/build/gen_test_packages_manifest.py @@ -62,7 +62,7 @@ def parse_args(): required=True, action="store", dest="tests_common", - help='Name of the "common" archive, a package to be used by all ' "harnesses.", + help='Name of the "common" archive, a package to be used by all harnesses.', ) parser.add_argument( "--jsshell", diff --git a/build/gn_processor.py b/build/gn_processor.py index 4e4295870b491..87b73b486f040 100644 --- a/build/gn_processor.py +++ b/build/gn_processor.py @@ -609,13 +609,11 @@ def write_mozbuild(topsrcdir, write_mozbuild_variables, relsrcdir, configs): conditions.add(cond) for cond in sorted(conditions): - common_attrs = find_common_attrs( - [ - attrs - for args, attrs in configs - if all((args.get(k) or "") == v for k, v in cond) - ] - ) + common_attrs = find_common_attrs([ + attrs + for args, attrs in configs + if all((args.get(k) or "") == v for k, v in cond) + ]) if any(common_attrs.values()): if cond: mb.write_condition(dict(cond)) @@ -726,31 +724,25 @@ def str_for_arg(v): srcdir = build_root_dir / target_dir input_variables = input_variables.copy() - input_variables.update( - { - f"{moz_build_flag}": True, - "concurrent_links": 1, - "action_pool_depth": 1, - } - ) + input_variables.update({ + f"{moz_build_flag}": True, + "concurrent_links": 1, + "action_pool_depth": 1, + }) if input_variables["target_os"] == "win": - input_variables.update( - { - "visual_studio_path": "/", - "visual_studio_version": 2015, - "wdk_path": "/", - "windows_sdk_version": "n/a", - } - ) + input_variables.update({ + "visual_studio_path": "/", + "visual_studio_version": 2015, + "wdk_path": "/", + "windows_sdk_version": "n/a", + }) if input_variables["target_os"] == "mac": - input_variables.update( - { - "mac_sdk_path": "/", - } - ) + input_variables.update({ + "mac_sdk_path": "/", + }) - gn_args = f'--args={" ".join([f"{k}={str_for_arg(v)}" for k, v in input_variables.items()])}' + gn_args = f"--args={' '.join([f'{k}={str_for_arg(v)}' for k, v in input_variables.items()])}" with tempfile.TemporaryDirectory() as tempdir: # On Mac, `tempdir` starts with /var which is a symlink to /private/var. # We resolve the symlinks in `tempdir` here so later usage with diff --git a/build/test/python/test_android_gradle_build.py b/build/test/python/test_android_gradle_build.py index a84d328843d0d..9feecbe1b42f7 100644 --- a/build/test/python/test_android_gradle_build.py +++ b/build/test/python/test_android_gradle_build.py @@ -186,13 +186,13 @@ def assert_all_task_statuses(objdir, acceptable_statuses, always_executed_tasks= actual_status = task.get("status") if task_name in always_executed_tasks: - assert ( - actual_status == "EXECUTED" - ), f"Task {task_name} should always execute, got '{actual_status}'" + assert actual_status == "EXECUTED", ( + f"Task {task_name} should always execute, got '{actual_status}'" + ) else: - assert ( - actual_status in acceptable_statuses - ), f"Task {task_name} had status '{actual_status}', expected one of {acceptable_statuses}" + assert actual_status in acceptable_statuses, ( + f"Task {task_name} had status '{actual_status}', expected one of {acceptable_statuses}" + ) def assert_ordered_task_outcomes(objdir, ordered_expected_task_statuses): @@ -219,18 +219,18 @@ def assert_ordered_task_outcomes(objdir, ordered_expected_task_statuses): assert not missing_tasks, f"Tasks not found in build metrics: {missing_tasks}" # Check order matches expectation - assert ( - task_order == expected_order - ), f"Task execution order mismatch. Expected: {expected_order}, Got: {task_order}" + assert task_order == expected_order, ( + f"Task execution order mismatch. Expected: {expected_order}, Got: {task_order}" + ) # Check statuses for each task task_lookup = {task.get("path"): task for task in metrics_tasks} for task_name, expected_status in ordered_expected_task_statuses: task_info = task_lookup[task_name] actual_status = task_info.get("status") - assert ( - actual_status == expected_status - ), f"Task {task_name} had status '{actual_status}', expected '{expected_status}'" + assert actual_status == expected_status, ( + f"Task {task_name} had status '{actual_status}', expected '{expected_status}'" + ) def test_artifact_build(objdir, mozconfig, run_mach): diff --git a/build/variables.py b/build/variables.py index 8b510b3ed9e87..6ba3cb50f1699 100644 --- a/build/variables.py +++ b/build/variables.py @@ -97,7 +97,7 @@ def source_repo_header(output): changeset = get_hg_changeset(buildconfig.topsrcdir) if not changeset: raise Exception( - "could not resolve changeset; " "try setting MOZ_SOURCE_CHANGESET" + "could not resolve changeset; try setting MOZ_SOURCE_CHANGESET" ) if changeset: diff --git a/client.py b/client.py index e662343a76d9f..77829fab4906a 100755 --- a/client.py +++ b/client.py @@ -32,9 +32,13 @@ def do_hg_pull(dir, repository, hg): if repository is not None: cmd.append(repository) check_call_noisy(cmd) - check_call( - [hg, "parent", "-R", fulldir, "--template=Updated to revision {node}.\n"] - ) + check_call([ + hg, + "parent", + "-R", + fulldir, + "--template=Updated to revision {node}.\n", + ]) def do_hg_replace(dir, repository, tag, exclusions, hg): diff --git a/config/check_macroassembler_style.py b/config/check_macroassembler_style.py index 675db90a8360e..4515bc31139a6 100644 --- a/config/check_macroassembler_style.py +++ b/config/check_macroassembler_style.py @@ -27,12 +27,23 @@ architecture_independent = set(["generic"]) all_unsupported_architectures_names = set(["mips64", "mips_shared"]) -all_architecture_names = set( - ["x86", "x64", "arm", "arm64", "loong64", "riscv64", "wasm32"] -) -all_shared_architecture_names = set( - ["x86_shared", "arm", "arm64", "loong64", "riscv64", "wasm32"] -) +all_architecture_names = set([ + "x86", + "x64", + "arm", + "arm64", + "loong64", + "riscv64", + "wasm32", +]) +all_shared_architecture_names = set([ + "x86_shared", + "arm", + "arm64", + "loong64", + "riscv64", + "wasm32", +]) reBeforeArg = r"(?<=[(,\s])" reArgType = r"(?P[\w\s:*&<>]+)" @@ -101,14 +112,12 @@ def get_normalized_signatures(signature, fileAnnot=None): return signatures -file_suffixes = set( - [ - a.replace("_", "-") - for a in all_architecture_names.union(all_shared_architecture_names).union( - all_unsupported_architectures_names - ) - ] -) +file_suffixes = set([ + a.replace("_", "-") + for a in all_architecture_names.union(all_shared_architecture_names).union( + all_unsupported_architectures_names + ) +]) def get_file_annotation(filename): diff --git a/config/check_spidermonkey_style.py b/config/check_spidermonkey_style.py index 0b717e5c93acd..2f2e3b3d420f0 100644 --- a/config/check_spidermonkey_style.py +++ b/config/check_spidermonkey_style.py @@ -54,63 +54,61 @@ ] # We ignore #includes of these files, because they don't follow the usual rules. -included_inclnames_to_ignore = set( - [ - "ffi.h", # generated in ctypes/libffi/ - "devtools/Instruments.h", # we ignore devtools/ in general - "diplomat_runtime.hpp", # ICU4X - "double-conversion/double-conversion.h", # strange MFBT case - "frontend/ReservedWordsGenerated.h", # generated in $OBJDIR - "gc/StatsPhasesGenerated.h", # generated in $OBJDIR - "gc/StatsPhasesGenerated.inc", # generated in $OBJDIR - "icu4x/Calendar.hpp", # ICU4X - "icu4x/Date.hpp", # ICU4X - "icu4x/GraphemeClusterSegmenter.hpp", # ICU4X - "icu4x/IsoDate.hpp", # ICU4X - "icu4x/Locale.hpp", # ICU4X - "icu4x/SentenceSegmenter.hpp", # ICU4X - "icu4x/WordSegmenter.hpp", # ICU4X - "jit/ABIFunctionTypeGenerated.h", # generated in $OBJDIR" - "jit/AtomicOperationsGenerated.h", # generated in $OBJDIR - "jit/CacheIROpsGenerated.h", # generated in $OBJDIR - "jit/CacheIRAOTGenerated.h", # generated in $OBJDIR - "jit/LIROpsGenerated.h", # generated in $OBJDIR - "jit/MIROpsGenerated.h", # generated in $OBJDIR - "js/PrefsGenerated.h", # generated in $OBJDIR - "mozilla/ProfilingCategoryList.h", # comes from mozglue/baseprofiler - "mozilla/glue/Debug.h", # comes from mozglue/misc, shadowed by - "jscustomallocator.h", # provided by embedders; allowed to be missing - "js-config.h", # generated in $OBJDIR - "fdlibm.h", # fdlibm - "FuzzerDefs.h", # included without a path - "FuzzingInterface.h", # included without a path - "mozmemory.h", # included without a path - "mozmemory_stall.h", # included without a path - "pratom.h", # NSPR - "prcvar.h", # NSPR - "prerror.h", # NSPR - "prinit.h", # NSPR - "prio.h", # NSPR - "private/pprio.h", # NSPR - "prlink.h", # NSPR - "prlock.h", # NSPR - "prprf.h", # NSPR - "prthread.h", # NSPR - "prtypes.h", # NSPR - "selfhosted.out.h", # generated in $OBJDIR - "shellmoduleloader.out.h", # generated in $OBJDIR - "unicode/locid.h", # ICU - "unicode/uchar.h", # ICU - "unicode/uniset.h", # ICU - "unicode/unistr.h", # ICU - "unicode/utypes.h", # ICU - "vtune/VTuneWrapper.h", # VTune - "wasm/WasmBuiltinModuleGenerated.h", # generated in $OBJDIR" - "zydis/ZydisAPI.h", # Zydis - "xsum/xsum.h", # xsum - "fmt/format.h", # {fmt} main header - ] -) +included_inclnames_to_ignore = set([ + "ffi.h", # generated in ctypes/libffi/ + "devtools/Instruments.h", # we ignore devtools/ in general + "diplomat_runtime.hpp", # ICU4X + "double-conversion/double-conversion.h", # strange MFBT case + "frontend/ReservedWordsGenerated.h", # generated in $OBJDIR + "gc/StatsPhasesGenerated.h", # generated in $OBJDIR + "gc/StatsPhasesGenerated.inc", # generated in $OBJDIR + "icu4x/Calendar.hpp", # ICU4X + "icu4x/Date.hpp", # ICU4X + "icu4x/GraphemeClusterSegmenter.hpp", # ICU4X + "icu4x/IsoDate.hpp", # ICU4X + "icu4x/Locale.hpp", # ICU4X + "icu4x/SentenceSegmenter.hpp", # ICU4X + "icu4x/WordSegmenter.hpp", # ICU4X + "jit/ABIFunctionTypeGenerated.h", # generated in $OBJDIR" + "jit/AtomicOperationsGenerated.h", # generated in $OBJDIR + "jit/CacheIROpsGenerated.h", # generated in $OBJDIR + "jit/CacheIRAOTGenerated.h", # generated in $OBJDIR + "jit/LIROpsGenerated.h", # generated in $OBJDIR + "jit/MIROpsGenerated.h", # generated in $OBJDIR + "js/PrefsGenerated.h", # generated in $OBJDIR + "mozilla/ProfilingCategoryList.h", # comes from mozglue/baseprofiler + "mozilla/glue/Debug.h", # comes from mozglue/misc, shadowed by + "jscustomallocator.h", # provided by embedders; allowed to be missing + "js-config.h", # generated in $OBJDIR + "fdlibm.h", # fdlibm + "FuzzerDefs.h", # included without a path + "FuzzingInterface.h", # included without a path + "mozmemory.h", # included without a path + "mozmemory_stall.h", # included without a path + "pratom.h", # NSPR + "prcvar.h", # NSPR + "prerror.h", # NSPR + "prinit.h", # NSPR + "prio.h", # NSPR + "private/pprio.h", # NSPR + "prlink.h", # NSPR + "prlock.h", # NSPR + "prprf.h", # NSPR + "prthread.h", # NSPR + "prtypes.h", # NSPR + "selfhosted.out.h", # generated in $OBJDIR + "shellmoduleloader.out.h", # generated in $OBJDIR + "unicode/locid.h", # ICU + "unicode/uchar.h", # ICU + "unicode/uniset.h", # ICU + "unicode/unistr.h", # ICU + "unicode/utypes.h", # ICU + "vtune/VTuneWrapper.h", # VTune + "wasm/WasmBuiltinModuleGenerated.h", # generated in $OBJDIR" + "zydis/ZydisAPI.h", # Zydis + "xsum/xsum.h", # xsum + "fmt/format.h", # {fmt} main header +]) # JSAPI functions should be included through headers from js/public instead of # using the old, catch-all jsapi.h file. @@ -126,19 +124,17 @@ # These files have additional constraints on where they are #included, so we # ignore #includes of them when checking #include ordering. -oddly_ordered_inclnames = set( - [ - "ctypes/typedefs.h", # Included multiple times in the body of ctypes/CTypes.h - # Included in the body of frontend/TokenStream.h - "frontend/ReservedWordsGenerated.h", - "gc/StatsPhasesGenerated.h", # Included in the body of gc/Statistics.h - "gc/StatsPhasesGenerated.inc", # Included in the body of gc/Statistics.cpp - "psapi.h", # Must be included after "util/WindowsWrapper.h" on Windows - "machine/endian.h", # Must be included after on BSD - "process.h", # Windows-specific - "util/WindowsWrapper.h", # Must precede other system headers(?) - ] -) +oddly_ordered_inclnames = set([ + "ctypes/typedefs.h", # Included multiple times in the body of ctypes/CTypes.h + # Included in the body of frontend/TokenStream.h + "frontend/ReservedWordsGenerated.h", + "gc/StatsPhasesGenerated.h", # Included in the body of gc/Statistics.h + "gc/StatsPhasesGenerated.inc", # Included in the body of gc/Statistics.cpp + "psapi.h", # Must be included after "util/WindowsWrapper.h" on Windows + "machine/endian.h", # Must be included after on BSD + "process.h", # Windows-specific + "util/WindowsWrapper.h", # Must precede other system headers(?) +]) # System headers which shouldn't be included directly, but instead use the # designated wrapper. @@ -217,9 +213,7 @@ -> tests/style/HeaderCycleB1-inl.h -> tests/style/HeaderCycleB4-inl.h -""".splitlines( - True -) +""".splitlines(True) actual_output = [] @@ -381,9 +375,7 @@ def check_style(enable_fixup): def module_name(name): """Strip the trailing .cpp, .h, or -inl.h from a filename.""" - return ( - name.replace("-inl.h", "").replace(".h", "").replace(".cpp", "") - ) # NOQA: E501 + return name.replace("-inl.h", "").replace(".h", "").replace(".cpp", "") # NOQA: E501 def is_module_header(enclosing_inclname, header_inclname): diff --git a/config/external/ffi/subst_header.py b/config/external/ffi/subst_header.py index f8fa5b47534be..71fdceabd0d06 100644 --- a/config/external/ffi/subst_header.py +++ b/config/external/ffi/subst_header.py @@ -12,14 +12,12 @@ def main(output, input_file, *defines): pp = Preprocessor() - pp.context.update( - { - "FFI_EXEC_TRAMPOLINE_TABLE": "0", - "HAVE_LONG_DOUBLE": "0", - "TARGET": buildconfig.substs["FFI_TARGET"], - "VERSION": "", - } - ) + pp.context.update({ + "FFI_EXEC_TRAMPOLINE_TABLE": "0", + "HAVE_LONG_DOUBLE": "0", + "TARGET": buildconfig.substs["FFI_TARGET"], + "VERSION": "", + }) for d in defines: pp.context.update({d: "1"}) pp.do_filter("substitution") diff --git a/config/mozunit/mozunit/mozunit.py b/config/mozunit/mozunit/mozunit.py index 56676787a02bd..bbb2ca0f09b5b 100644 --- a/config/mozunit/mozunit/mozunit.py +++ b/config/mozunit/mozunit/mozunit.py @@ -312,22 +312,20 @@ def main(*args, **kwargs): args.append("--color=yes") module = __import__("__main__") - args.extend( - [ - "--rootdir", - str(topsrcdir), - "-c", - os.path.join(here, "pytest.ini"), - "-vv", - "--tb=short", - "-p", - "mozlog.pytest_mozlog.plugin", - "-p", - "mozunit.pytest_plugin", - "-p", - "no:cacheprovider", - "-rsx", # show reasons for skip / xfail - module.__file__, - ] - ) + args.extend([ + "--rootdir", + str(topsrcdir), + "-c", + os.path.join(here, "pytest.ini"), + "-vv", + "--tb=short", + "-p", + "mozlog.pytest_mozlog.plugin", + "-p", + "mozunit.pytest_plugin", + "-p", + "no:cacheprovider", + "-rsx", # show reasons for skip / xfail + module.__file__, + ]) sys.exit(pytest.main(args)) diff --git a/config/tests/unit-nsinstall.py b/config/tests/unit-nsinstall.py index 6c5c094a845c1..d24178f2ca120 100644 --- a/config/tests/unit-nsinstall.py +++ b/config/tests/unit-nsinstall.py @@ -139,7 +139,7 @@ def test_nsinstall_non_ascii(self): "Test that nsinstall handles non-ASCII files" filename = "\u2325\u3452\u2415\u5081" testfile = self.touch(filename) - testdir = self.mkdirs("\u4241\u1D04\u1414") + testdir = self.mkdirs("\u4241\u1d04\u1414") self.assertEqual( nsinstall([testfile.encode("utf-8"), testdir.encode("utf-8")]), 0 ) @@ -155,7 +155,7 @@ def test_nsinstall_non_ascii_subprocess(self): "Test that nsinstall as a subprocess handles non-ASCII files" filename = "\u2325\u3452\u2415\u5081" testfile = self.touch(filename) - testdir = self.mkdirs("\u4241\u1D04\u1414") + testdir = self.mkdirs("\u4241\u1d04\u1414") p = subprocess.Popen([sys.executable, NSINSTALL_PATH, testfile, testdir]) rv = p.wait() diff --git a/config/tests/unitMozZipFile.py b/config/tests/unitMozZipFile.py index e7fec74d750df..beba41ce9678e 100644 --- a/config/tests/unitMozZipFile.py +++ b/config/tests/unitMozZipFile.py @@ -207,6 +207,7 @@ def _write(self, zf, seed=None, leaf=0, length=0): class TestExtensiveDeflated(TestExtensiveStored): "Test all that has been tested with ZIP_STORED with DEFLATED, too." + compression = zipfile.ZIP_DEFLATED diff --git a/configure.py b/configure.py index 0cdb5c48f8748..bb36ac156c2fa 100644 --- a/configure.py +++ b/configure.py @@ -241,7 +241,7 @@ def sanitize_config(v): fh.write("%s = " % k) pprint.pprint(v, stream=fh, indent=4) fh.write( - "__all__ = ['topobjdir', 'topsrcdir', 'defines', " "'substs', 'mozconfig']" + "__all__ = ['topobjdir', 'topsrcdir', 'defines', 'substs', 'mozconfig']" ) if execute: diff --git a/dom/base/usecounters.py b/dom/base/usecounters.py index 79fbeb6574f28..eb842c8fe4013 100644 --- a/dom/base/usecounters.py +++ b/dom/base/usecounters.py @@ -383,42 +383,38 @@ def parse_use_counters(): ) name = f"{counter['interface_name']}_{counter['attribute_name']}".lower() attr = f"{counter['interface_name']}.{counter['attribute_name']}" - page.append( - (f"{enum_root}_getter", f"{name}_getter", f"Whether a page got {attr}.") - ) - page.append( - (f"{enum_root}_setter", f"{name}_setter", f"Whether a page set {attr}.") - ) - doc.append( - ( - f"{enum_root}_getter", - f"{name}_getter", - f"Whether a document got {attr}.", - ) - ) - doc.append( - ( - f"{enum_root}_setter", - f"{name}_setter", - f"Whether a document set {attr}.", - ) - ) + page.append(( + f"{enum_root}_getter", + f"{name}_getter", + f"Whether a page got {attr}.", + )) + page.append(( + f"{enum_root}_setter", + f"{name}_setter", + f"Whether a page set {attr}.", + )) + doc.append(( + f"{enum_root}_getter", + f"{name}_getter", + f"Whether a document got {attr}.", + )) + doc.append(( + f"{enum_root}_setter", + f"{name}_setter", + f"Whether a document set {attr}.", + )) elif counter["type"] == "custom": enum_name = f"eUseCounter_custom_{counter['name']}" - page.append( - ( - enum_name, - to_snake_case(counter["name"]), - f"Whether a page {counter['desc']}.", - ) - ) - doc.append( - ( - enum_name, - to_snake_case(counter["name"]), - f"Whether a document {counter['desc']}.", - ) - ) + page.append(( + enum_name, + to_snake_case(counter["name"]), + f"Whether a page {counter['desc']}.", + )) + doc.append(( + enum_name, + to_snake_case(counter["name"]), + f"Whether a document {counter['desc']}.", + )) else: print(f"Found unexpected use counter type {counter['type']}. Returning 1.") return 1 @@ -434,84 +430,72 @@ def parse_use_counters(): enum_name = f"{counter['interface_name']}_{counter['method_name']}" name = f"{counter['interface_name']}_{counter['method_name']}".lower() method = f"called {counter['interface_name']}.{counter['method_name']}" - dedicated.append( - (enum_name, name, f"Whether a dedicated worker called {method}.") - ) - shared.append( - (enum_name, name, f"Whether a shared worker called {method}.") - ) - service.append( - (enum_name, name, f"Whether a service worker called {method}.") - ) + dedicated.append(( + enum_name, + name, + f"Whether a dedicated worker called {method}.", + )) + shared.append(( + enum_name, + name, + f"Whether a shared worker called {method}.", + )) + service.append(( + enum_name, + name, + f"Whether a service worker called {method}.", + )) elif counter["type"] == "attribute": enum_root = f"{counter['interface_name']}_{counter['attribute_name']}" name = f"{counter['interface_name']}_{counter['attribute_name']}".lower() attr = f"{counter['interface_name']}.{counter['attribute_name']}" - dedicated.append( - ( - f"{enum_root}_getter", - f"{name}_getter", - f"Whether a dedicated worker got {attr}.", - ) - ) - dedicated.append( - ( - f"{enum_root}_setter", - f"{name}_setter", - f"Whether a dedicated worker set {attr}.", - ) - ) - shared.append( - ( - f"{enum_root}_getter", - f"{name}_getter", - f"Whether a shared worker got {attr}.", - ) - ) - shared.append( - ( - f"{enum_root}_setter", - f"{name}_setter", - f"Whether a shared worker set {attr}.", - ) - ) - service.append( - ( - f"{enum_root}_getter", - f"{name}_getter", - f"Whether a service worker got {attr}.", - ) - ) - service.append( - ( - f"{enum_root}_setter", - f"{name}_setter", - f"Whether a service worker set {attr}.", - ) - ) + dedicated.append(( + f"{enum_root}_getter", + f"{name}_getter", + f"Whether a dedicated worker got {attr}.", + )) + dedicated.append(( + f"{enum_root}_setter", + f"{name}_setter", + f"Whether a dedicated worker set {attr}.", + )) + shared.append(( + f"{enum_root}_getter", + f"{name}_getter", + f"Whether a shared worker got {attr}.", + )) + shared.append(( + f"{enum_root}_setter", + f"{name}_setter", + f"Whether a shared worker set {attr}.", + )) + service.append(( + f"{enum_root}_getter", + f"{name}_getter", + f"Whether a service worker got {attr}.", + )) + service.append(( + f"{enum_root}_setter", + f"{name}_setter", + f"Whether a service worker set {attr}.", + )) elif counter["type"] == "custom": enum_name = f"Custom_{counter['name']}" - dedicated.append( - ( - enum_name, - to_snake_case(counter["name"]), - f"Whether a dedicated worker {counter['desc']}.", - ) - ) - shared.append( - ( - enum_name, - to_snake_case(counter["name"]), - f"Whether a shared worker {counter['desc']}.", - ) - ) - service.append( - ( - enum_name, - to_snake_case(counter["name"]), - f"Whether a service worker {counter['desc']}.", - ) - ) + dedicated.append(( + enum_name, + to_snake_case(counter["name"]), + f"Whether a dedicated worker {counter['desc']}.", + )) + shared.append(( + enum_name, + to_snake_case(counter["name"]), + f"Whether a shared worker {counter['desc']}.", + )) + service.append(( + enum_name, + to_snake_case(counter["name"]), + f"Whether a service worker {counter['desc']}.", + )) else: print( f"Found unexpected worker use counter type {counter['type']}. Returning 1." @@ -564,16 +548,16 @@ def parse_use_counters(): method = method[3:] # remove the moz prefix enum_name = f"eUseCounter_property_{method}" - css_page.append( - (enum_name, prop_name, f"Whether a page used the CSS property {prop.name}.") - ) - css_doc.append( - ( - enum_name, - prop_name, - f"Whether a document used the CSS property {prop.name}.", - ) - ) + css_page.append(( + enum_name, + prop_name, + f"Whether a page used the CSS property {prop.name}.", + )) + css_doc.append(( + enum_name, + prop_name, + f"Whether a document used the CSS property {prop.name}.", + )) # Counted unknown properties: AKA - stuff that doesn't exist, but we want # to count uses of anyway. @@ -600,20 +584,16 @@ def parse_use_counters(): for prop in unknown_properties: enum_name = f"eUseCounter_unknown_property_{to_camel_case(prop)}" prop_name = to_snake_case(prop) - css_page.append( - ( - enum_name, - prop_name, - f"Whether a page used the (unknown, counted) CSS property {prop}.", - ) - ) - css_doc.append( - ( - enum_name, - prop_name, - f"Whether a document used the (unknown, counted) CSS property {prop}.", - ) - ) + css_page.append(( + enum_name, + prop_name, + f"Whether a page used the (unknown, counted) CSS property {prop}.", + )) + css_doc.append(( + enum_name, + prop_name, + f"Whether a document used the (unknown, counted) CSS property {prop}.", + )) return (page, doc, dedicated, shared, service, ops_page, ops_doc, css_page, css_doc) diff --git a/dom/bindings/Configuration.py b/dom/bindings/Configuration.py index e69e23a930036..8b26d797bfd13 100644 --- a/dom/bindings/Configuration.py +++ b/dom/bindings/Configuration.py @@ -837,8 +837,7 @@ def addOperation(operation, m): ) if len(m.signatures()) != 1: raise TypeError( - "We don't support overloaded " - "legacycaller.\n%s" % m.location + "We don't support overloaded legacycaller.\n%s" % m.location ) addOperation("LegacyCaller", m) diff --git a/dom/bindings/parser/tests/test_attr_sequence_type.py b/dom/bindings/parser/tests/test_attr_sequence_type.py index 7a23265daf673..80c89aff7474f 100644 --- a/dom/bindings/parser/tests/test_attr_sequence_type.py +++ b/dom/bindings/parser/tests/test_attr_sequence_type.py @@ -54,7 +54,7 @@ def WebIDLTest(parser, harness): harness.ok( threw, - "Attribute type must not be a union with a nullable sequence " "member type", + "Attribute type must not be a union with a nullable sequence member type", ) parser.reset() diff --git a/dom/bindings/parser/tests/test_constructor.py b/dom/bindings/parser/tests/test_constructor.py index 22712245cd31f..bb9032ec06f19 100644 --- a/dom/bindings/parser/tests/test_constructor.py +++ b/dom/bindings/parser/tests/test_constructor.py @@ -446,7 +446,7 @@ def checkResults(results): harness.ok( threw, - "Can't have both a HTMLConstructor and a throwing constructor " "operation", + "Can't have both a HTMLConstructor and a throwing constructor operation", ) # Test HTMLConstructor and [ChromeOnly] constructor operation @@ -486,7 +486,7 @@ def checkResults(results): harness.ok( threw, - "Can't have both a throwing chromeonly constructor and a " "HTMLConstructor", + "Can't have both a throwing chromeonly constructor and a HTMLConstructor", ) parser = parser.reset() @@ -507,7 +507,7 @@ def checkResults(results): harness.ok( threw, - "Can't have both a HTMLConstructor and a chromeonly constructor " "operation", + "Can't have both a HTMLConstructor and a chromeonly constructor operation", ) parser = parser.reset() @@ -549,8 +549,7 @@ def checkResults(results): harness.ok( threw, - "Can't have a constructor operation on a [LegacyNoInterfaceObject] " - "interface", + "Can't have a constructor operation on a [LegacyNoInterfaceObject] interface", ) parser = parser.reset() diff --git a/dom/bindings/parser/tests/test_dictionary.py b/dom/bindings/parser/tests/test_dictionary.py index 80c13a4238e8d..2c9efd6f8bd3b 100644 --- a/dom/bindings/parser/tests/test_dictionary.py +++ b/dom/bindings/parser/tests/test_dictionary.py @@ -120,7 +120,7 @@ def WebIDLTest(parser, harness): threw = True harness.ok( - threw, "Should not allow name duplication in a dictionary and " "its ancestor" + threw, "Should not allow name duplication in a dictionary and its ancestor" ) # More reset @@ -324,7 +324,7 @@ def WebIDLTest(parser, harness): harness.ok( threw, - "Union arg containing dictionary followed by optional arg must " "be optional", + "Union arg containing dictionary followed by optional arg must be optional", ) parser = parser.reset() @@ -404,7 +404,7 @@ def WebIDLTest(parser, harness): harness.ok(threw, "Required dictionary arg must not be nullable") harness.ok( "nullable" in str(threw), - "Must have the expected exception for required nullable " "dictionary arg", + "Must have the expected exception for required nullable dictionary arg", ) parser = parser.reset() @@ -605,7 +605,7 @@ def WebIDLTest(parser, harness): harness.ok( threw, - "Member type must not be a Dictionary that " "inherits from its Dictionary.", + "Member type must not be a Dictionary that inherits from its Dictionary.", ) parser = parser.reset() diff --git a/dom/bindings/parser/tests/test_distinguishability.py b/dom/bindings/parser/tests/test_distinguishability.py index c1365ce16800c..a89db729b3384 100644 --- a/dom/bindings/parser/tests/test_distinguishability.py +++ b/dom/bindings/parser/tests/test_distinguishability.py @@ -58,11 +58,11 @@ def WebIDLTest(parser, harness): harness.ok( not nullableUnionType.isDistinguishableFrom(nullableIfaceType), - "Nullable type not distinguishable from union with nullable " "member type", + "Nullable type not distinguishable from union with nullable member type", ) harness.ok( not nullableIfaceType.isDistinguishableFrom(nullableUnionType), - "Union with nullable member type not distinguishable from " "nullable type", + "Union with nullable member type not distinguishable from nullable type", ) parser = parser.reset() diff --git a/dom/bindings/parser/tests/test_empty_sequence_default_value.py b/dom/bindings/parser/tests/test_empty_sequence_default_value.py index 4771a6b1e54bb..a89703f16f193 100644 --- a/dom/bindings/parser/tests/test_empty_sequence_default_value.py +++ b/dom/bindings/parser/tests/test_empty_sequence_default_value.py @@ -50,5 +50,5 @@ def WebIDLTest(parser, harness): harness.ok( isinstance(results[0].members[0].defaultValue, WebIDL.IDLEmptySequenceValue), - "Should have IDLEmptySequenceValue as default value of " "dictionary member", + "Should have IDLEmptySequenceValue as default value of dictionary member", ) diff --git a/dom/bindings/parser/tests/test_global_extended_attr.py b/dom/bindings/parser/tests/test_global_extended_attr.py index 9d52747a1dabc..ef2c9e9dffbc9 100644 --- a/dom/bindings/parser/tests/test_global_extended_attr.py +++ b/dom/bindings/parser/tests/test_global_extended_attr.py @@ -42,7 +42,7 @@ def WebIDLTest(parser, harness): harness.ok( threw, - "Should have thrown for [Global] used on an interface with a " "named setter", + "Should have thrown for [Global] used on an interface with a named setter", ) parser = parser.reset() @@ -63,7 +63,7 @@ def WebIDLTest(parser, harness): harness.ok( threw, - "Should have thrown for [Global] used on an interface with a " "named deleter", + "Should have thrown for [Global] used on an interface with a named deleter", ) parser = parser.reset() @@ -128,7 +128,7 @@ def WebIDLTest(parser, harness): harness.ok( threw, - "Should have thrown for [Global] used on an interface with a " "descendant", + "Should have thrown for [Global] used on an interface with a descendant", ) parser = parser.reset() diff --git a/dom/bindings/parser/tests/test_interface.py b/dom/bindings/parser/tests/test_interface.py index 5b32a27f4d326..82b7e6bea61cf 100644 --- a/dom/bindings/parser/tests/test_interface.py +++ b/dom/bindings/parser/tests/test_interface.py @@ -263,8 +263,7 @@ def WebIDLTest(parser, harness): threw = True harness.ok( threw, - "Should not allow a name collision between partial interface " - "and other object", + "Should not allow a name collision between partial interface and other object", ) parser = parser.reset() @@ -284,7 +283,7 @@ def WebIDLTest(parser, harness): except WebIDL.WebIDLError: threw = True harness.ok( - threw, "Should not allow a name collision between interface " "and other object" + threw, "Should not allow a name collision between interface and other object" ) parser = parser.reset() @@ -303,8 +302,7 @@ def WebIDLTest(parser, harness): threw = True harness.ok( threw, - "Should not allow a name collision between external interface " - "and other object", + "Should not allow a name collision between external interface and other object", ) parser = parser.reset() @@ -323,7 +321,7 @@ def WebIDLTest(parser, harness): threw = True harness.ok( threw, - "Should not allow a name collision between external interface " "and interface", + "Should not allow a name collision between external interface and interface", ) parser = parser.reset() @@ -336,7 +334,7 @@ def WebIDLTest(parser, harness): results = parser.finish() harness.ok( len(results) == 1 and isinstance(results[0], WebIDL.IDLExternalInterface), - "Should allow name collisions between external interface " "declarations", + "Should allow name collisions between external interface declarations", ) parser = parser.reset() diff --git a/dom/bindings/parser/tests/test_interfacemixin.py b/dom/bindings/parser/tests/test_interfacemixin.py index 297cc10915093..3b11e5eeb7e5a 100644 --- a/dom/bindings/parser/tests/test_interfacemixin.py +++ b/dom/bindings/parser/tests/test_interfacemixin.py @@ -219,7 +219,7 @@ def WebIDLTest(parser, harness): threw = True harness.ok( threw, - "Should not allow a name collision between interface mixin " "and other object", + "Should not allow a name collision between interface mixin and other object", ) parser = parser.reset() @@ -523,12 +523,12 @@ def WebIDLTest(parser, harness): harness.check( attr.exposureSet, set(["Window", "Worker"]), - "Should expose on all globals where including interfaces are " "exposed", + "Should expose on all globals where including interfaces are exposed", ) base = results[3] attr = base.members[0] harness.check( attr.exposureSet, set(["Window", "Worker"]), - "Should expose on all globals where including interfaces are " "exposed", + "Should expose on all globals where including interfaces are exposed", ) diff --git a/dom/bindings/parser/tests/test_optional_constraints.py b/dom/bindings/parser/tests/test_optional_constraints.py index 34f03467621f8..3391179535b2c 100644 --- a/dom/bindings/parser/tests/test_optional_constraints.py +++ b/dom/bindings/parser/tests/test_optional_constraints.py @@ -18,8 +18,7 @@ def WebIDLTest(parser, harness): harness.ok( not threw, - "Should not have thrown on non-optional argument following " - "optional argument.", + "Should not have thrown on non-optional argument following optional argument.", ) parser = parser.reset() diff --git a/dom/bindings/parser/tests/test_promise.py b/dom/bindings/parser/tests/test_promise.py index 1dfb6d4643c38..9e59eb5d98701 100644 --- a/dom/bindings/parser/tests/test_promise.py +++ b/dom/bindings/parser/tests/test_promise.py @@ -98,9 +98,7 @@ def WebIDLTest(parser, harness): ) parser.finish() - harness.ok( - True, "Should allow overloads which only have Promise and return " "types." - ) + harness.ok(True, "Should allow overloads which only have Promise and return types.") parser = parser.reset() threw = False diff --git a/dom/bindings/parser/tests/test_toJSON.py b/dom/bindings/parser/tests/test_toJSON.py index ec81080becae4..fe008afe4e451 100644 --- a/dom/bindings/parser/tests/test_toJSON.py +++ b/dom/bindings/parser/tests/test_toJSON.py @@ -167,7 +167,7 @@ def doTest(testIDL, shouldThrow, description): ) doTest( - "dictionary Foo { %s foo; }; " "interface Test { Foo toJSON(); }; " % type, + "dictionary Foo { %s foo; }; interface Test { Foo toJSON(); }; " % type, False, "dictionary containing only JSON type (%s) should be a JSON type" % type, ) @@ -233,7 +233,7 @@ def doTest(testIDL, shouldThrow, description): ) doTest( - "interface Foo : InterfaceWithToJSON { };" "interface Test { Foo toJSON(); };", + "interface Foo : InterfaceWithToJSON { };interface Test { Foo toJSON(); };", False, "inherited interface with toJSON should be a JSON type", ) @@ -252,7 +252,7 @@ def doTest(testIDL, shouldThrow, description): ) doTest( - "dictionary Foo { %s foo; }; " "interface Test { Foo toJSON(); }; " % type, + "dictionary Foo { %s foo; }; interface Test { Foo toJSON(); }; " % type, True, "Dictionary containing a non-JSON type (%s) should not be a JSON type" % type, @@ -299,14 +299,13 @@ def doTest(testIDL, shouldThrow, description): ) doTest( - "dictionary Foo { long foo; any bar; };" "interface Test { Foo toJSON(); };", + "dictionary Foo { long foo; any bar; };interface Test { Foo toJSON(); };", True, "dictionary containing a non-JSON type should not be a JSON type", ) doTest( - "interface Foo : InterfaceWithoutToJSON { }; " - "interface Test { Foo toJSON(); };", + "interface Foo : InterfaceWithoutToJSON { }; interface Test { Foo toJSON(); };", True, "interface without toJSON should not be a JSON type", ) diff --git a/dom/bindings/parser/tests/test_typedef.py b/dom/bindings/parser/tests/test_typedef.py index 9f2fd1f3c8c9c..d4f658f0b3ada 100644 --- a/dom/bindings/parser/tests/test_typedef.py +++ b/dom/bindings/parser/tests/test_typedef.py @@ -74,8 +74,7 @@ def WebIDLTest(parser, harness): harness.ok( threw, - "Should have thrown on nullable inside nullable const typedef " - "after interface.", + "Should have thrown on nullable inside nullable const typedef after interface.", ) parser = parser.reset() diff --git a/dom/bindings/parser/tests/test_union.py b/dom/bindings/parser/tests/test_union.py index 20a4c0238dbdc..247c5eb5dbefe 100644 --- a/dom/bindings/parser/tests/test_union.py +++ b/dom/bindings/parser/tests/test_union.py @@ -174,16 +174,13 @@ def invalidUnionWithUnion(typeCombinations): parser = parser.reset() for invalid in invalidUnionTypes: - interface = ( - testPre - + string.Template( - """ + interface = testPre + string.Template( + """ interface TestUnion { undefined method(${type} arg); }; """ - ).substitute(type=invalid) - ) + ).substitute(type=invalid) threw = False try: diff --git a/dom/bindings/parser/tests/test_union_nullable.py b/dom/bindings/parser/tests/test_union_nullable.py index d5ae2e1e74cb7..7c2a1b26f69fa 100644 --- a/dom/bindings/parser/tests/test_union_nullable.py +++ b/dom/bindings/parser/tests/test_union_nullable.py @@ -36,7 +36,7 @@ def WebIDLTest(parser, harness): harness.ok( threw, - "A nullable union type with a nullable member type should have " "thrown.", + "A nullable union type with a nullable member type should have thrown.", ) parser.reset() @@ -59,5 +59,5 @@ def WebIDLTest(parser, harness): harness.ok( threw, - "A nullable union type with a nullable member type should have " "thrown.", + "A nullable union type with a nullable member type should have thrown.", ) diff --git a/dom/bindings/parser/tests/test_variadic_constraints.py b/dom/bindings/parser/tests/test_variadic_constraints.py index 749c4a7812a25..6a7743b164208 100644 --- a/dom/bindings/parser/tests/test_variadic_constraints.py +++ b/dom/bindings/parser/tests/test_variadic_constraints.py @@ -18,7 +18,7 @@ def WebIDLTest(parser, harness): harness.ok( threw, - "Should have thrown on variadic argument followed by required " "argument.", + "Should have thrown on variadic argument followed by required argument.", ) parser = parser.reset() @@ -37,7 +37,7 @@ def WebIDLTest(parser, harness): harness.ok( threw, - "Should have thrown on variadic argument followed by optional " "argument.", + "Should have thrown on variadic argument followed by optional argument.", ) parser = parser.reset() @@ -57,7 +57,7 @@ def WebIDLTest(parser, harness): harness.ok( threw, - "Should have thrown on variadic argument explicitly flagged as " "optional.", + "Should have thrown on variadic argument explicitly flagged as optional.", ) parser = parser.reset() 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 48621d00c1ba7..7ee8930722abb 100644 --- a/dom/canvas/test/reftest/colors/generate_color_canvas_reftests.py +++ b/dom/canvas/test/reftest/colors/generate_color_canvas_reftests.py @@ -332,7 +332,7 @@ def encode_url_v(k, v): def url_from_config(kvs: Config) -> str: - parts = [f"{k}={encode_url_v(k,v)}" for k, v in kvs.items()] + parts = [f"{k}={encode_url_v(k, v)}" for k, v in kvs.items()] url = "color_canvas.html?" + "&".join(parts) return url @@ -405,7 +405,7 @@ def aligned_lines_from_table( {GENERATED_FILE_LINE} {GENERATED_FILE_LINE} -# Generated by `{' '.join(GENERATED_BY_ARGS)}`. +# Generated by `{" ".join(GENERATED_BY_ARGS)}`. # - defaults pref(webgl.drawing_buffer_color_space,true) @@ -414,9 +414,9 @@ def aligned_lines_from_table( # - # Ensure not white-screening: -!= {url_from_config({})+'='} about:blank +!= {url_from_config({}) + "="} about:blank # Ensure differing results with different args: -!= {url_from_config({'e_color':'color(srgb 1 0 0)'})} {url_from_config({'e_color':'color(srgb 0 1 0)'})} +!= {url_from_config({"e_color": "color(srgb 1 0 0)"})} {url_from_config({"e_color": "color(srgb 0 1 0)"})} {GENERATED_FILE_LINE} # - diff --git a/dom/canvas/test/webgl-conf/generate-wrappers-and-manifest.py b/dom/canvas/test/webgl-conf/generate-wrappers-and-manifest.py index 12080689ec68e..dce1bdeea6cfb 100755 --- a/dom/canvas/test/webgl-conf/generate-wrappers-and-manifest.py +++ b/dom/canvas/test/webgl-conf/generate-wrappers-and-manifest.py @@ -32,14 +32,12 @@ "mochi-single.html", ] -ACCEPTABLE_ERRATA_KEYS = set( - [ - "fail-if", - "prefs", - "skip-if", - "tags", - ] -) +ACCEPTABLE_ERRATA_KEYS = set([ + "fail-if", + "prefs", + "skip-if", + "tags", +]) def ChooseSubsuite(name): @@ -475,9 +473,9 @@ def LoadTOML(path): if line[0] == "[": assert line[-1] == "]", f"{path}:{lineNum}" curSectionName = line[1:-1].strip('"') - assert ( - curSectionName not in ret - ), f"Line {lineNum}: Duplicate section: {line}" + assert curSectionName not in ret, ( + f"Line {lineNum}: Duplicate section: {line}" + ) curSectionMap = {} ret[curSectionName] = (lineNum, curSectionMap) continue @@ -506,9 +504,9 @@ def LoadErrata(): continue elif sectionName != "DEFAULT": path = sectionName.replace("/", os.sep) - assert os.path.exists( - path - ), f"Errata line {sectionLineNum}: Invalid file: {sectionName}" + assert os.path.exists(path), ( + f"Errata line {sectionLineNum}: Invalid file: {sectionName}" + ) for key, (lineNum, val) in sectionMap.items(): assert key in ACCEPTABLE_ERRATA_KEYS, f"Line {lineNum}: {key}" diff --git a/dom/canvas/test/webgl-conf/import.py b/dom/canvas/test/webgl-conf/import.py index dbf49cb15488e..7ce1e955a16cd 100755 --- a/dom/canvas/test/webgl-conf/import.py +++ b/dom/canvas/test/webgl-conf/import.py @@ -13,9 +13,9 @@ REL_PATH = "/dom/canvas/test/webgl-conf" REPO_DIR = Path.cwd() DIR_IN_GECKO = Path(__file__).parent -assert not REPO_DIR.samefile( - DIR_IN_GECKO -), "Run this script from the source git checkout." +assert not REPO_DIR.samefile(DIR_IN_GECKO), ( + "Run this script from the source git checkout." +) assert DIR_IN_GECKO.as_posix().endswith(REL_PATH) # Be paranoid with rm -rf. gecko_base_dir = DIR_IN_GECKO.as_posix()[: -len(REL_PATH)] diff --git a/dom/media/driftcontrol/plot.py b/dom/media/driftcontrol/plot.py index c30542cdf3ff2..2a9f98a7aee62 100755 --- a/dom/media/driftcontrol/plot.py +++ b/dom/media/driftcontrol/plot.py @@ -106,12 +106,10 @@ def main(): absAvgError = [abs(e) for e in avgError] slow_offset = [e / slowConvergenceSecs - slowHysteresis for e in absAvgError] fast_offset = [e / adjustmentInterval for e in absAvgError] - low_offset, high_offset = zip( - *[ - (s, f) if e >= 0 else (-f, -s) - for (e, s, f) in zip(avgError, slow_offset, fast_offset) - ] - ) + low_offset, high_offset = zip(*[ + (s, f) if e >= 0 else (-f, -s) + for (e, s, f) in zip(avgError, slow_offset, fast_offset) + ]) fig2 = figure(x_range=fig1.x_range) fig2.varea( diff --git a/dom/media/test/reftest/gen_combos.py b/dom/media/test/reftest/gen_combos.py index 6e3f337223677..e85f32d603a99 100644 --- a/dom/media/test/reftest/gen_combos.py +++ b/dom/media/test/reftest/gen_combos.py @@ -69,83 +69,75 @@ def eprint(*args, **kwargs): # - -FORMAT_LIST = set( - [ +FORMAT_LIST = set([ + "yuv420p", + "yuv420p10", + # 'yuv420p12', + # 'yuv420p16be', + # 'yuv420p16le', + "gbrp", +]) + +if "--all" in ARGS: + FORMAT_LIST |= set([ "yuv420p", "yuv420p10", - # 'yuv420p12', - # 'yuv420p16be', - # 'yuv420p16le', + "yuv420p12", + "yuv420p16be", + "yuv420p16le", + "yuv422p", + "yuv422p10", + "yuv422p12", + "yuv422p16be", + "yuv422p16le", + "yuv444p", + "yuv444p10", + "yuv444p12", + "yuv444p16be", + "yuv444p16le", + "yuv411p", + "yuv410p", + "yuyv422", + "uyvy422", + "rgb24", + "bgr24", + "rgb8", + "bgr8", + "rgb444be", + "rgb444le", + "bgr444be", + "bgr444le", + # 'nv12', # Encoding not different than yuv420p? + # 'nv21', # Encoding not different than yuv420p? "gbrp", - ] -) - -if "--all" in ARGS: - FORMAT_LIST |= set( - [ - "yuv420p", - "yuv420p10", - "yuv420p12", - "yuv420p16be", - "yuv420p16le", - "yuv422p", - "yuv422p10", - "yuv422p12", - "yuv422p16be", - "yuv422p16le", - "yuv444p", - "yuv444p10", - "yuv444p12", - "yuv444p16be", - "yuv444p16le", - "yuv411p", - "yuv410p", - "yuyv422", - "uyvy422", - "rgb24", - "bgr24", - "rgb8", - "bgr8", - "rgb444be", - "rgb444le", - "bgr444be", - "bgr444le", - # 'nv12', # Encoding not different than yuv420p? - # 'nv21', # Encoding not different than yuv420p? - "gbrp", - "gbrp9be", - "gbrp9le", - "gbrp10be", - "gbrp10le", - "gbrp12be", - "gbrp12le", - "gbrp14be", - "gbrp14le", - "gbrp16be", - "gbrp16le", - ] - ) + "gbrp9be", + "gbrp9le", + "gbrp10be", + "gbrp10le", + "gbrp12be", + "gbrp12le", + "gbrp14be", + "gbrp14le", + "gbrp16be", + "gbrp16le", + ]) FORMATS = keyed_combiner("format", list(FORMAT_LIST)) RANGE = keyed_combiner("range", ["tv", "pc"]) -CSPACE_LIST = set( - [ - "bt709", - # 'bt2020', - ] -) +CSPACE_LIST = set([ + "bt709", + # 'bt2020', +]) if "--all" in ARGS: - CSPACE_LIST |= set( - [ - "bt709", - "bt2020", - "bt601-6-525", # aka smpte170m NTSC - "bt601-6-625", # aka bt470bg PAL - ] - ) + CSPACE_LIST |= set([ + "bt709", + "bt2020", + "bt601-6-525", # aka smpte170m NTSC + "bt601-6-625", # aka bt470bg PAL + ]) CSPACE_LIST = list(CSPACE_LIST) # - @@ -164,17 +156,15 @@ def eprint(*args, **kwargs): todo = [] for c in COMBOS: - dst_name = ".".join( - [ - SRC_PATH.name, - c["src_cspace"], - c["dst_cspace"], - c["range"], - c["format"], - c["vcodec"], - c["ext"], - ] - ) + dst_name = ".".join([ + SRC_PATH.name, + c["src_cspace"], + c["dst_cspace"], + c["range"], + c["format"], + c["vcodec"], + c["ext"], + ]) src_cspace = c["src_cspace"] diff --git a/dom/media/tools/checkGmpBalrog.py b/dom/media/tools/checkGmpBalrog.py index c5a8e362046f6..70318f9543597 100644 --- a/dom/media/tools/checkGmpBalrog.py +++ b/dom/media/tools/checkGmpBalrog.py @@ -47,15 +47,13 @@ def fetch_balrog_xml( for channel in channels: results[channel] = {} for target in targets: - balrog_url = url.format_map( - { - "url_base": url_base, - "buildid": buildid, - "channel": channel, - "version": version, - "target": target, - } - ) + balrog_url = url.format_map({ + "url_base": url_base, + "buildid": buildid, + "channel": channel, + "version": version, + "target": target, + }) response = requests.get(balrog_url) response.raise_for_status() diff --git a/dom/media/tools/generateGmpJson.py b/dom/media/tools/generateGmpJson.py index 9bf90bf2b3c53..abdba20001df2 100644 --- a/dom/media/tools/generateGmpJson.py +++ b/dom/media/tools/generateGmpJson.py @@ -32,9 +32,14 @@ def fetch_url_for_cdms(cdms, urlParams): "{} expected https scheme '{}'".format(cdm["target"], redirectUrl) ) - sanitizedUrl = urlunparse( - (parsedUrl.scheme, parsedUrl.netloc, parsedUrl.path, None, None, None) - ) + sanitizedUrl = urlunparse(( + parsedUrl.scheme, + parsedUrl.netloc, + parsedUrl.path, + None, + None, + None, + )) # Note that here we modify the returned URL from the # component update service because it returns a preferred diff --git a/dom/media/webrtc/third_party_build/filter_git_changes.py b/dom/media/webrtc/third_party_build/filter_git_changes.py index c0ec3421f0f2e..fbb9ad285229f 100644 --- a/dom/media/webrtc/third_party_build/filter_git_changes.py +++ b/dom/media/webrtc/third_party_build/filter_git_changes.py @@ -47,9 +47,9 @@ def filter_git_changes(github_path, commit_sha, diff_filter): # Convert the directory exclude list to a regex string and filter # out the excluded directory paths (note the lack of trailing '$' # in the regex). - regex_excludes = "|".join( - [f"^(M|A|D|R\\d\\d\\d)\t{incl}" for incl in exclude_dir_list] - ) + regex_excludes = "|".join([ + f"^(M|A|D|R\\d\\d\\d)\t{incl}" for incl in exclude_dir_list + ]) files_not_excluded = [ path for path in changed_files if not re.findall(regex_excludes, path) ] diff --git a/dom/media/webrtc/third_party_build/write_default_config.py b/dom/media/webrtc/third_party_build/write_default_config.py index 72cc573a039a1..886c4baf028c4 100644 --- a/dom/media/webrtc/third_party_build/write_default_config.py +++ b/dom/media/webrtc/third_party_build/write_default_config.py @@ -220,6 +220,6 @@ def build_default_config_env( run_shell( f"{'git commit -m' if repo_type == RepoType.GIT else 'hg commit --message'} " f'"Bug {args.bug_number} - ' - f'updated default_config_env for v{args.milestone+1}"' + f'updated default_config_env for v{args.milestone + 1}"' f" {args.output_path}" ) diff --git a/dom/origin-trials/gen-keys.py b/dom/origin-trials/gen-keys.py index 6d00d695cf024..aae56d945752d 100644 --- a/dom/origin-trials/gen-keys.py +++ b/dom/origin-trials/gen-keys.py @@ -17,12 +17,12 @@ def public_key_to_string(file, name): ) key = decoder.decode(substrate) ident = key[0][0] - assert ident[0] == univ.ObjectIdentifier( - "1.2.840.10045.2.1" - ), "should be an ECPublicKey" - assert ident[1] == univ.ObjectIdentifier( - "1.2.840.10045.3.1.7" - ), "should be a EcdsaP256 key" + assert ident[0] == univ.ObjectIdentifier("1.2.840.10045.2.1"), ( + "should be an ECPublicKey" + ) + assert ident[1] == univ.ObjectIdentifier("1.2.840.10045.3.1.7"), ( + "should be a EcdsaP256 key" + ) bits = key[0][1] assert isinstance(bits, univ.BitString), "Should be a bit string" assert len(bits) == 520, "Should be 520 bits (65 bytes)" diff --git a/dom/quota/scripts/qm-try-analysis/qm_try_analysis/analyze.py b/dom/quota/scripts/qm-try-analysis/qm_try_analysis/analyze.py index 1173555e08551..67cf92c314061 100755 --- a/dom/quota/scripts/qm-try-analysis/qm_try_analysis/analyze.py +++ b/dom/quota/scripts/qm-try-analysis/qm_try_analysis/analyze.py @@ -63,7 +63,7 @@ def analyze_qm_failures(output_to, workdir): sys.exit(2) if output_to == "qmstacks_until_.txt": - output_to = path.join(workdir, f'qmstacks_until_{run["lasteventtime"]}.txt') + output_to = path.join(workdir, f"qmstacks_until_{run['lasteventtime']}.txt") elif output_to.exists(): error( f'The output file "{output_to}" already exists. This script would override it.' diff --git a/dom/quota/scripts/qm-try-analysis/qm_try_analysis/fn_anchors.py b/dom/quota/scripts/qm-try-analysis/qm_try_analysis/fn_anchors.py index 2280b0b2fce69..cdeb1b2d7f055 100644 --- a/dom/quota/scripts/qm-try-analysis/qm_try_analysis/fn_anchors.py +++ b/dom/quota/scripts/qm-try-analysis/qm_try_analysis/fn_anchors.py @@ -14,12 +14,10 @@ def getMetricsJson(src_url): if src_url.startswith("http"): info(f"Fetching source for function extraction: {src_url}") - metrics = subprocess.check_output( - [ - path.join(path.dirname(path.realpath(__file__)), "fetch_fn_names.sh"), - src_url, - ] - ) + metrics = subprocess.check_output([ + path.join(path.dirname(path.realpath(__file__)), "fetch_fn_names.sh"), + src_url, + ]) else: warning(f"Skip fetching source: {src_url}") metrics = "" @@ -37,13 +35,11 @@ def getSpaceFunctionsRecursive(metrics_space): and metrics_space["name"] and metrics_space["name"] != "" ): - functions.append( - { - "name": metrics_space["name"], - "start_line": int(metrics_space["start_line"]), - "end_line": int(metrics_space["end_line"]), - } - ) + functions.append({ + "name": metrics_space["name"], + "start_line": int(metrics_space["start_line"]), + "end_line": int(metrics_space["end_line"]), + }) for space in metrics_space["spaces"]: functions += getSpaceFunctionsRecursive(space) return functions diff --git a/dom/quota/scripts/qm-try-analysis/qm_try_analysis/report.py b/dom/quota/scripts/qm-try-analysis/qm_try_analysis/report.py index cee3b0542e52b..f99a2ccdaba8c 100644 --- a/dom/quota/scripts/qm-try-analysis/qm_try_analysis/report.py +++ b/dom/quota/scripts/qm-try-analysis/qm_try_analysis/report.py @@ -191,9 +191,9 @@ def reduce(search_results, by: str) -> Union[int, None]: continue search_string = " ".join(filter(None, match.groups())) - search_results = bugzilla_client.search_bugs( - [{"product": "Core", "summary": search_string}] - )["bugs"] + search_results = bugzilla_client.search_bugs([ + {"product": "Core", "summary": search_string} + ])["bugs"] if bug_id := reduce(search_results, by=anchor): info(f'Found bug {BUGZILLA_BUG_URL + str(bug_id)} for anchor "{anchor}".') diff --git a/dom/quota/scripts/qm-try-analysis/qm_try_analysis/stackanalysis.py b/dom/quota/scripts/qm-try-analysis/qm_try_analysis/stackanalysis.py index f0363c5e1fec4..f72fe583de6ff 100644 --- a/dom/quota/scripts/qm-try-analysis/qm_try_analysis/stackanalysis.py +++ b/dom/quota/scripts/qm-try-analysis/qm_try_analysis/stackanalysis.py @@ -227,16 +227,14 @@ def collectRawStacks(rows): "frames": [], } - stack["frames"].append( - { - "location": row["location"], - "source_file": row["source_file"], - "source_line": row["source_line"], - "seq": row["seq"], - "severity": row["severity"], - "result": row["result"], - } - ) + stack["frames"].append({ + "location": row["location"], + "source_file": row["source_file"], + "source_line": row["source_line"], + "seq": row["seq"], + "severity": row["severity"], + "result": row["result"], + }) first = False return raw_stacks diff --git a/dom/security/sanitizer/update-safe-default-configuration.py b/dom/security/sanitizer/update-safe-default-configuration.py index 2255560761c16..8056d42de1549 100644 --- a/dom/security/sanitizer/update-safe-default-configuration.py +++ b/dom/security/sanitizer/update-safe-default-configuration.py @@ -114,44 +114,44 @@ def create_list_body(l): constexpr nsStaticAtom* kDefaultHTMLElements[] = {{ // clang-format off -{ xhtml_elements_body } +{xhtml_elements_body} // clang-format on }}; constexpr nsStaticAtom* kDefaultMathMLElements[] = {{ // clang-format off -{ mathml_elements_body } +{mathml_elements_body} // clang-format on }}; constexpr nsStaticAtom* kDefaultSVGElements[] = {{ // clang-format off -{ svg_elements_body } +{svg_elements_body} // clang-format on }}; constexpr nsStaticAtom* kDefaultAttributes[] = {{ // clang-format off -{ attributes_body } +{attributes_body} // clang-format on }}; // Data is encoded as: element, attributes..., nullptr constexpr nsStaticAtom* kHTMLElementWithAttributes[] = {{ // clang-format off -{ xhtml_element_with_attributes_body } +{xhtml_element_with_attributes_body} // clang-format on }}; constexpr nsStaticAtom* kMathMLElementWithAttributes[] = {{ // clang-format off -{ mathml_element_with_attributes_body } +{mathml_element_with_attributes_body} // clang-format on }}; constexpr nsStaticAtom* kSVGElementWithAttributes[] = {{ // clang-format off -{ svg_element_with_attributes_body } +{svg_element_with_attributes_body} // clang-format on }}; diff --git a/dom/workers/test/marionette/test_service_workers_disabled.py b/dom/workers/test/marionette/test_service_workers_disabled.py index 431392e381f1b..65a680823d8cf 100644 --- a/dom/workers/test/marionette/test_service_workers_disabled.py +++ b/dom/workers/test/marionette/test_service_workers_disabled.py @@ -23,11 +23,9 @@ def tearDown(self): def test_service_workers_disabled_at_startup(self): # self.marionette.set_pref sets preferences after startup. Using it # here causes intermittent failures. - self.marionette.instance.profile.set_preferences( - { - "dom.serviceWorkers.enabled": False, - } - ) + self.marionette.instance.profile.set_preferences({ + "dom.serviceWorkers.enabled": False, + }) self.marionette.restart() diff --git a/gfx/gl/GLConsts.py b/gfx/gl/GLConsts.py index 0c9a1949bbbbe..feee526f34fef 100755 --- a/gfx/gl/GLConsts.py +++ b/gfx/gl/GLConsts.py @@ -50,17 +50,13 @@ * * To generate this file, see tutorial in \'GLConsts.py\'. */ -"""[ - 1: -] +"""[1:] FOOTER = b""" #endif // GLCONSTS_H_ // clang-format on -"""[ - 1: -] +"""[1:] # - diff --git a/intl/icu_sources_data.py b/intl/icu_sources_data.py index 5dcc69526fec0..4ef7638400f53 100644 --- a/intl/icu_sources_data.py +++ b/intl/icu_sources_data.py @@ -211,9 +211,7 @@ def try_run(name, command, cwd=None, **kwargs): except subprocess.CalledProcessError: print( """Error running "{}" in directory {} - See output in {}""".format( - " ".join(command), cwd, f.name - ), + See output in {}""".format(" ".join(command), cwd, f.name), file=sys.stderr, ) return False @@ -232,21 +230,19 @@ def update_data_file(topsrcdir): configure = mozpath.join(topsrcdir, "intl/icu/source/configure") env = dict(os.environ) # bug 1262101 - these should be shared with the moz.build files - env.update( - { - "CPPFLAGS": ( - "-DU_NO_DEFAULT_INCLUDE_UTF_HEADERS=1 " - + "-DU_HIDE_OBSOLETE_UTF_OLD_H=1 " - + "-DUCONFIG_NO_LEGACY_CONVERSION " - + "-DUCONFIG_NO_TRANSLITERATION " - + "-DUCONFIG_NO_REGULAR_EXPRESSIONS " - + "-DUCONFIG_NO_BREAK_ITERATION " - + "-DUCONFIG_NO_IDNA " - + "-DUCONFIG_NO_MF2 " - + "-DU_CHARSET_IS_UTF8 " - ) - } - ) + env.update({ + "CPPFLAGS": ( + "-DU_NO_DEFAULT_INCLUDE_UTF_HEADERS=1 " + + "-DU_HIDE_OBSOLETE_UTF_OLD_H=1 " + + "-DUCONFIG_NO_LEGACY_CONVERSION " + + "-DUCONFIG_NO_TRANSLITERATION " + + "-DUCONFIG_NO_REGULAR_EXPRESSIONS " + + "-DUCONFIG_NO_BREAK_ITERATION " + + "-DUCONFIG_NO_IDNA " + + "-DUCONFIG_NO_MF2 " + + "-DU_CHARSET_IS_UTF8 " + ) + }) # Exclude data that we currently don't need. # diff --git a/ipc/ipdl/ipdl.py b/ipc/ipdl/ipdl.py index 15112b34041df..2e02d0a6022d7 100644 --- a/ipc/ipdl/ipdl.py +++ b/ipc/ipdl/ipdl.py @@ -31,7 +31,7 @@ def __init__( allsyncmessages, alljsonobjs, *, - processes=None + processes=None, ): if processes is None: processes = os.cpu_count() or 1 diff --git a/ipc/pull-chromium.py b/ipc/pull-chromium.py index 688098b511bc5..17a205df18fc1 100644 --- a/ipc/pull-chromium.py +++ b/ipc/pull-chromium.py @@ -36,16 +36,14 @@ def doexport(svnpath): localpath = os.path.join(chromiumsrc, svnpath) os.makedirs(os.path.dirname(localpath)) - check_call( - [ - "svn", - "export", - "-r", - "BASE", - os.path.join(chromiumtree, "src", svnpath), - localpath, - ] - ) + check_call([ + "svn", + "export", + "-r", + "BASE", + os.path.join(chromiumtree, "src", svnpath), + localpath, + ]) doexport("base") diff --git a/js/src/builtin/embedjs.py b/js/src/builtin/embedjs.py index 989b6cfbff45e..517028dc7ec1b 100644 --- a/js/src/builtin/embedjs.py +++ b/js/src/builtin/embedjs.py @@ -101,13 +101,11 @@ def embed( ) args = cppflags + ["-D%(k)s=%(v)s" % {"k": k, "v": env[k]} for k in env] preprocessed = preprocess(cxx, preprocessorOption, combinedSources, args) - processed = "\n".join( - [ - line - for line in preprocessed.splitlines() - if (line.strip() and not line.startswith("#")) - ] - ) + processed = "\n".join([ + line + for line in preprocessed.splitlines() + if (line.strip() and not line.startswith("#")) + ]) js_out.write(processed) import zlib diff --git a/js/src/builtin/intl/make_intl_data.py b/js/src/builtin/intl/make_intl_data.py index e4401bc0ab330..511d0a2c4f6c8 100755 --- a/js/src/builtin/intl/make_intl_data.py +++ b/js/src/builtin/intl/make_intl_data.py @@ -4,40 +4,40 @@ # 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/. -""" Usage: - make_intl_data.py langtags [cldr_common.zip] - make_intl_data.py tzdata - make_intl_data.py currency - make_intl_data.py units - make_intl_data.py numbering +"""Usage: +make_intl_data.py langtags [cldr_common.zip] +make_intl_data.py tzdata +make_intl_data.py currency +make_intl_data.py units +make_intl_data.py numbering - Target "langtags": - This script extracts information about 1) mappings between deprecated and - current Unicode BCP 47 locale identifiers, and 2) deprecated and current - BCP 47 Unicode extension value from CLDR, and converts it to C++ mapping - code in intl/components/LocaleGenerated.cpp. The code is used in - intl/components/Locale.cpp. +Target "langtags": +This script extracts information about 1) mappings between deprecated and +current Unicode BCP 47 locale identifiers, and 2) deprecated and current +BCP 47 Unicode extension value from CLDR, and converts it to C++ mapping +code in intl/components/LocaleGenerated.cpp. The code is used in +intl/components/Locale.cpp. - Target "tzdata": - This script computes which time zone informations are not up-to-date in ICU - and provides the necessary mappings to workaround this problem. - https://ssl.icu-project.org/trac/ticket/12044 +Target "tzdata": +This script computes which time zone informations are not up-to-date in ICU +and provides the necessary mappings to workaround this problem. +https://ssl.icu-project.org/trac/ticket/12044 - Target "currency": - Generates the mapping from currency codes to decimal digits used for them. +Target "currency": +Generates the mapping from currency codes to decimal digits used for them. - Target "units": - Generate source and test files using the list of so-called "sanctioned unit - identifiers" and verifies that the ICU data filter includes these units. +Target "units": +Generate source and test files using the list of so-called "sanctioned unit +identifiers" and verifies that the ICU data filter includes these units. - Target "numbering": - Generate source and test files using the list of numbering systems with - simple digit mappings and verifies that it's in sync with ICU/CLDR. +Target "numbering": +Generate source and test files using the list of numbering systems with +simple digit mappings and verifies that it's in sync with ICU/CLDR. """ import io @@ -121,9 +121,7 @@ def writeMappingsBinarySearch( println( """ -}""".lstrip( - "\n" - ) +}""".lstrip("\n") ) @@ -157,18 +155,14 @@ def write_array(subtags, name, length, fixed): println( f""" if ({source_name}.Length() == {length}) {{ -""".rstrip( - "\n" - ) +""".rstrip("\n") ) else: trailing_return = False println( """ { -""".rstrip( - "\n" - ) +""".rstrip("\n") ) # The subtags need to be sorted for binary search to work. @@ -187,17 +181,13 @@ def equals(subtag): return true; }} return false; -""".strip( - "\n" - ) +""".strip("\n") ) else: println( f""" return {equals(subtags[0])}; -""".strip( - "\n" - ) +""".strip("\n") ) elif len(subtags) <= 4: if type(mappings) is dict: @@ -208,17 +198,13 @@ def equals(subtag): {target_name}.Set("{mappings[subtag]}"); return true; }} -""".strip( - "\n" - ) +""".strip("\n") ) println( """ return false; -""".strip( - "\n" - ) +""".strip("\n") ) else: cond = (equals(subtag) for subtag in subtags) @@ -226,9 +212,7 @@ def equals(subtag): println( f""" return {cond}; -""".strip( - "\n" - ) +""".strip("\n") ) else: write_array(subtags, source_name + "s", length, True) @@ -255,9 +239,7 @@ def equals(subtag): println( """ } -""".strip( - "\n" - ) +""".strip("\n") ) if trailing_return: @@ -310,16 +292,12 @@ def writeComplexLanguageTagMappings( println( f""" - {if_kind} ({cond}) {{""".strip( - "\n" - ) + {if_kind} ({cond}) {{""".strip("\n") ) println( f""" - SetLanguage("{language}");""".strip( - "\n" - ) + SetLanguage("{language}");""".strip("\n") ) if script is not None: @@ -327,32 +305,24 @@ def writeComplexLanguageTagMappings( f""" if (Script().Missing()) {{ SetScript("{script}"); - }}""".strip( - "\n" - ) + }}""".strip("\n") ) if region is not None: println( f""" if (Region().Missing()) {{ SetRegion("{region}"); - }}""".strip( - "\n" - ) + }}""".strip("\n") ) println( """ - }""".strip( - "\n" - ) + }""".strip("\n") ) println( """ } -""".strip( - "\n" - ) +""".strip("\n") ) @@ -406,14 +376,12 @@ def hash_key(default, non_default_replacements): println( f""" - {if_kind} ({cond}) {{""".strip( - "\n" - ) + {if_kind} ({cond}) {{""".strip("\n") ) - replacement_regions = sorted( - {region for (_, _, region) in non_default_replacements} - ) + replacement_regions = sorted({ + region for (_, _, region) in non_default_replacements + }) first_case = True for replacement_region in replacement_regions: @@ -441,9 +409,7 @@ def compare_tags(language, script): f""" {if_kind} ({cond}) {{ SetRegion("{replacement_region}"); - }}""".rstrip().strip( - "\n" - ) + }}""".rstrip().strip("\n") ) println( @@ -451,17 +417,13 @@ def compare_tags(language, script): else {{ SetRegion("{default}"); }} - }}""".rstrip().strip( - "\n" - ) + }}""".rstrip().strip("\n") ) println( """ } -""".strip( - "\n" - ) +""".strip("\n") ) @@ -531,9 +493,7 @@ def writeVariantTagMappings(println, variant_mappings, description, source, url) if ({no_replacements}) {{ removeVariantAt(i); }} -""".strip( - "\n" - ) +""".strip("\n") ) for deprecated_variant, (type, replacement) in sorted( @@ -543,26 +503,20 @@ def writeVariantTagMappings(println, variant_mappings, description, source, url) f""" else if (variant.Span() == mozilla::MakeStringSpan("{deprecated_variant}")) {{ removeVariantAt(i); -""".strip( - "\n" - ) +""".strip("\n") ) if type == "language": println( f""" SetLanguage("{replacement}"); -""".strip( - "\n" - ) +""".strip("\n") ) elif type == "region": println( f""" SetRegion("{replacement}"); -""".strip( - "\n" - ) +""".strip("\n") ) else: assert type == "variant" @@ -571,17 +525,13 @@ def writeVariantTagMappings(println, variant_mappings, description, source, url) if (!insertVariantSortedIfNotPresent(mozilla::MakeStringSpan("{replacement}"))) {{ return false; }} -""".strip( - "\n" - ) +""".strip("\n") ) println( """ } -""".strip( - "\n" - ) +""".strip("\n") ) println( @@ -592,9 +542,7 @@ def writeVariantTagMappings(println, variant_mappings, description, source, url) } return true; } -""".strip( - "\n" - ) +""".strip("\n") ) @@ -732,9 +680,7 @@ def __eq__(self, obj): mRegion.Set(mozilla::MakeStringSpan("")); } } -""".rstrip().lstrip( - "\n" - ) +""".rstrip().lstrip("\n") ) # Finally handle all remaining cases. @@ -784,9 +730,7 @@ def hash_key(mappings): println( f""" else if ({cond}) {{ -""".rstrip().lstrip( - "\n" - ) +""".rstrip().lstrip("\n") ) mappings = legacy_mappings_by_language[langs[0]] @@ -820,9 +764,7 @@ def variant_size(m): println( f""" {" " * i}{maybe_else}if (auto* {variant} = findVariant(mozilla::MakeStringSpan("{variant}"))) {{ -""".rstrip().lstrip( - "\n" - ) +""".rstrip().lstrip("\n") ) indent = " " * len_variants @@ -832,26 +774,20 @@ def variant_size(m): {indent}removeVariant{"s" if len_variants > 1 else ""}({", ".join(sorted_variants)}); {indent}SetLanguage("{r_language}"); {indent}{"return true;" if not chain_if else ""} -""".rstrip().lstrip( - "\n" - ) +""".rstrip().lstrip("\n") ) for i in range(len_variants, 0, -1): println( f""" {" " * (i - 1)}}} -""".rstrip().lstrip( - "\n" - ) +""".rstrip().lstrip("\n") ) println( """ } -""".rstrip().lstrip( - "\n" - ) +""".rstrip().lstrip("\n") ) println( @@ -962,9 +898,9 @@ def bcp47_canonical(language, script, region, variants): # See UTS35, §Annex C, Definitions - 1. Multimap interpretation. def language_id_to_multimap(language_id): match = re_unicode_language_id.match(language_id) - assert ( - match is not None - ), f"{language_id} invalid Unicode BCP 47 locale identifier" + assert match is not None, ( + f"{language_id} invalid Unicode BCP 47 locale identifier" + ) canonical_language_id = bcp47_canonical( *match.group("language", "script", "region", "variants") @@ -1011,9 +947,9 @@ def language_id_to_multimap(language_id): language_id_to_multimap("und-" + r) for r in replacements ] - assert ( - type not in territory_exception_rules - ), f"Duplicate alias rule: {type}" + assert type not in territory_exception_rules, ( + f"Duplicate alias rule: {type}" + ) territory_exception_rules[type] = replacement_list @@ -1213,9 +1149,9 @@ def multi_map_size(locale_id): assert r_language is not None, "Can't remove a language subtag" # We don't yet support this case. - assert ( - r_variants is None - ), f"Unhandled variant replacement in language alias: {replacement}" + assert r_variants is None, ( + f"Unhandled variant replacement in language alias: {replacement}" + ) if replacement == (Any, None, None, None): language_mappings[language] = r_language @@ -1223,9 +1159,9 @@ def multi_map_size(locale_id): complex_language_mappings[language] = replacement[:-1] elif script is not None: # We don't support removing script subtags. - assert ( - r_script is not None - ), f"Can't remove a script subtag: {replacement}" + assert r_script is not None, ( + f"Can't remove a script subtag: {replacement}" + ) # We only support one-to-one script mappings for now. assert replacement == ( @@ -1238,9 +1174,9 @@ def multi_map_size(locale_id): script_mappings[script] = r_script elif region is not None: # We don't support removing region subtags. - assert ( - r_region is not None - ), f"Can't remove a region subtag: {replacement}" + assert r_region is not None, ( + f"Can't remove a region subtag: {replacement}" + ) # We only support one-to-one region mappings for now. assert replacement == ( @@ -1262,9 +1198,9 @@ def multi_map_size(locale_id): assert len(variants.split("-")) == 1 # We only support one-to-one variant mappings for now. - assert ( - multi_map_size(replacement) <= 1 - ), f"Unhandled replacement in variant alias: {replacement}" + assert multi_map_size(replacement) <= 1, ( + f"Unhandled replacement in variant alias: {replacement}" + ) if r_language is not None: variant_mappings[variants] = ("language", r_language) @@ -1311,21 +1247,21 @@ def multi_map_size(locale_id): for likely_subtag in tree.iterfind(".//likelySubtag"): from_tag = bcp47_id(likely_subtag.get("from")) from_match = re_unicode_language_id.match(from_tag) - assert ( - from_match is not None - ), f"{from_tag} invalid Unicode BCP 47 locale identifier" - assert ( - from_match.group("variants") is None - ), f"unexpected variant subtags in {from_tag}" + assert from_match is not None, ( + f"{from_tag} invalid Unicode BCP 47 locale identifier" + ) + assert from_match.group("variants") is None, ( + f"unexpected variant subtags in {from_tag}" + ) to_tag = bcp47_id(likely_subtag.get("to")) to_match = re_unicode_language_id.match(to_tag) - assert ( - to_match is not None - ), f"{to_tag} invalid Unicode BCP 47 locale identifier" - assert ( - to_match.group("variants") is None - ), f"unexpected variant subtags in {to_tag}" + assert to_match is not None, ( + f"{to_tag} invalid Unicode BCP 47 locale identifier" + ) + assert to_match.group("variants") is None, ( + f"unexpected variant subtags in {to_tag}" + ) from_canonical = bcp47_canonical( *from_match.group("language", "script", "region", "variants") @@ -1472,9 +1408,9 @@ def readBCP47File(file): continue # All other names should match the 'type' production. - assert ( - typeRE.match(name) is not None - ), f"{name} matches the 'type' production" + assert typeRE.match(name) is not None, ( + f"{name} matches the 'type' production" + ) # : # @@ -1548,9 +1484,9 @@ def readSupplementalMetadata(file): tree = ET.parse(file) for alias in tree.iterfind(".//subdivisionAlias"): type = alias.get("type") - assert ( - typeRE.match(type) is not None - ), f"{type} matches the 'type' production" + assert typeRE.match(type) is not None, ( + f"{type} matches the 'type' production" + ) # Take the first replacement when multiple ones are present. replacement = alias.get("replacement").split(" ")[0].lower() @@ -1560,9 +1496,9 @@ def readSupplementalMetadata(file): replacement += "zzzz" # Assert the replacement is syntactically correct. - assert ( - typeRE.match(replacement) is not None - ), f"replacement {replacement} matches the 'type' production" + assert typeRE.match(replacement) is not None, ( + f"replacement {replacement} matches the 'type' production" + ) # 'subdivisionAlias' applies to 'rg' and 'sd' keys. mapping["u"].setdefault("rg", {})[type] = replacement @@ -1851,9 +1787,9 @@ def canonical(tag): region = region_mappings[region] else: # Assume no complex region mappings are needed for now. - assert ( - region not in complex_region_mappings - ), f"unexpected region with complex mappings: {region}" + assert region not in complex_region_mappings, ( + f"unexpected region with complex mappings: {region}" + ) return (language, script, region) @@ -3228,9 +3164,7 @@ def writeUnicodeExtensionsMappings(println, mapping, extension): return type.size() == (Length - 1) && memcmp(type.data(), str, Length - 1) == 0; }} -""".rstrip( - "\n" - ) +""".rstrip("\n") ) linear_search_max_length = 4 @@ -3276,9 +3210,7 @@ def writeUnicodeExtensionsMappings(println, mapping, extension): }} return nullptr; }} -""".rstrip( - "\n" - ) +""".rstrip("\n") ) println( @@ -3337,9 +3269,7 @@ def write_array(subtags, name, length): cond = (" ||\n" + " " * (2 + len(if_kind) + 2)).join(cond) println( f""" - {if_kind} ({cond}) {{""".strip( - "\n" - ) + {if_kind} ({cond}) {{""".strip("\n") ) first_key = False @@ -3355,9 +3285,7 @@ def write_array(subtags, name, length): println( f""" return Search{extension}Replacement(types, aliases, type); -""".strip( - "\n" - ) +""".strip("\n") ) else: for type, replacement in replacements: @@ -3365,25 +3293,19 @@ def write_array(subtags, name, length): f""" if (Is{extension}Type(type, "{type}")) {{ return "{replacement}"; - }}""".strip( - "\n" - ) + }}""".strip("\n") ) println( """ - }""".lstrip( - "\n" - ) + }""".lstrip("\n") ) println( """ return nullptr; } -""".strip( - "\n" - ) +""".strip("\n") ) @@ -3626,9 +3548,7 @@ def find_unit_type(unit): } // namespace mozilla::intl #endif -""".strip( - "\n" - ) +""".strip("\n") ) writeUnitTestFiles(all_units, sanctioned_units) @@ -3667,9 +3587,7 @@ def write_test(file_name, test_content, indent=4): println( """ if (typeof reportCompare === "function") -{}reportCompare(true, true);""".format( - " " * indent - ) +{}reportCompare(true, true);""".format(" " * indent) ) write_test( @@ -3999,16 +3917,16 @@ def updateNumberingSystems(topsrcdir, args): # Assert ICU includes support for all required numbering systems. If this assertion fails, # something is broken in ICU. - assert all_numbering_systems_simple_digits.issuperset( - numbering_systems - ), f"{numbering_systems.difference(all_numbering_systems_simple_digits)}" + assert all_numbering_systems_simple_digits.issuperset(numbering_systems), ( + f"{numbering_systems.difference(all_numbering_systems_simple_digits)}" + ) # Assert the spec requires support for all numbering systems with simple digit mappings. If # this assertion fails, file a PR at to include any new # numbering systems. - assert all_numbering_systems_simple_digits.issubset( - numbering_systems - ), f"{all_numbering_systems_simple_digits.difference(numbering_systems)}" + assert all_numbering_systems_simple_digits.issubset(numbering_systems), ( + f"{all_numbering_systems_simple_digits.difference(numbering_systems)}" + ) writeNumberingSystemFiles(all_numbering_systems) @@ -4077,8 +3995,7 @@ def EnsureHttps(v): metavar="URL", default="https://www.six-group.com/dam/download/financial-information/data-center/iso-currrency/lists/list-one.xml", # NOQA: E501 type=EnsureHttps, - help="Download url for the currency & funds code list (default: " - "%(default)s)", + help="Download url for the currency & funds code list (default: %(default)s)", ) parser_currency.add_argument( "--out", diff --git a/js/src/devtools/automation/autospider.py b/js/src/devtools/automation/autospider.py index c4fd674aea1a5..38de07bf778e6 100755 --- a/js/src/devtools/automation/autospider.py +++ b/js/src/devtools/automation/autospider.py @@ -30,8 +30,7 @@ def directories(pathmodule, cwd, fixup=lambda s: s): source = pathmodule.abspath(pathmodule.join(js_src, "..", "..")) mozbuild = pathmodule.abspath( # os.path.expanduser does not work on Windows. - env.get("MOZBUILD_STATE_PATH") - or pathmodule.join(Path.home(), ".mozbuild") + env.get("MOZBUILD_STATE_PATH") or pathmodule.join(Path.home(), ".mozbuild") ) fetches = pathmodule.abspath(env.get("MOZ_FETCHES_DIR", mozbuild)) return Dirs(scripts, js_src, source, fetches) @@ -148,8 +147,7 @@ def quote(s): type=str, metavar="TESTSUITE", default="", - help="comma-separated set of test suites to remove from the variant's default " - "set", + help="comma-separated set of test suites to remove from the variant's default set", ) parser.add_argument( "--build-only", @@ -591,12 +589,10 @@ def normalize_tests(tests): "--timeout=300", "--jitflags=all", ] - results.append( - ( - "mach jit-test", - run_mach_command(["jit-test", "--", *auto_args, *extra_args["jit-test"]]), - ) - ) + results.append(( + "mach jit-test", + run_mach_command(["jit-test", "--", *auto_args, *extra_args["jit-test"]]), + )) if "jsapitests" in test_suites: st = run_jsapitests([]) if st == 0: @@ -606,23 +602,17 @@ def normalize_tests(tests): auto_args = [] if AUTOMATION: auto_args = ["--no-progress", "--format=automation", "--timeout=300"] - results.append( - ( - "mach jstests", - run_mach_command(["jstests", "--", *auto_args, *extra_args["jstests"]]), - ) - ) + results.append(( + "mach jstests", + run_mach_command(["jstests", "--", *auto_args, *extra_args["jstests"]]), + )) if "gdb" in test_suites: test_script = os.path.join(DIR.js_src, "gdb", "run-tests.py") auto_args = ["-s", "-o", "--no-progress"] if AUTOMATION else [] - results.append( - ( - "gdb", - run_test_command( - [PYTHON, test_script, *auto_args, *extra_args["gdb"], OBJDIR] - ), - ) - ) + results.append(( + "gdb", + run_test_command([PYTHON, test_script, *auto_args, *extra_args["gdb"], OBJDIR]), + )) # FIXME bug 1291449: This would be unnecessary if we could run msan with -mllvm # -msan-keep-going, but in clang 3.8 it causes a hang during compilation. @@ -691,15 +681,13 @@ def normalize_tests(tests): # Generate stacks from minidumps. if use_minidump: - run_mach_command( - [ - "python", - "--virtualenv=build", - os.path.join(DIR.source, "testing/mozbase/mozcrash/mozcrash/mozcrash.py"), - os.getenv("TMPDIR", "/tmp"), - os.path.join(OBJDIR, "dist/crashreporter-symbols"), - ] - ) + run_mach_command([ + "python", + "--virtualenv=build", + os.path.join(DIR.source, "testing/mozbase/mozcrash/mozcrash/mozcrash.py"), + os.getenv("TMPDIR", "/tmp"), + os.path.join(OBJDIR, "dist/crashreporter-symbols"), + ]) for name, st in results: print("exit status %d for '%s'" % (st, name)) diff --git a/js/src/devtools/gc/gc-test.py b/js/src/devtools/gc/gc-test.py index 23807fc432983..661171b3ef5fb 100644 --- a/js/src/devtools/gc/gc-test.py +++ b/js/src/devtools/gc/gc-test.py @@ -150,7 +150,7 @@ def compare(current, baseline): "--baseline", metavar="JSON_PATH", dest="baseline_path", - help="json file with baseline values to " "compare against", + help="json file with baseline values to compare against", ) (OPTIONS, args) = op.parse_args() diff --git a/js/src/devtools/rootAnalysis/analyze.py b/js/src/devtools/rootAnalysis/analyze.py index 961d2d36ad36f..d5c45aacddfd6 100755 --- a/js/src/devtools/rootAnalysis/analyze.py +++ b/js/src/devtools/rootAnalysis/analyze.py @@ -358,7 +358,7 @@ def max_parallel_jobs(job_size=4 * 2**30): "--expect-file", type=str, nargs="?", - help="deprecated option, temporarily still present for backwards " "compatibility", + help="deprecated option, temporarily still present for backwards compatibility", ) parser.add_argument( "--verbose", @@ -434,12 +434,13 @@ def max_parallel_jobs(job_size=4 * 2**30): # Trim the {curly brackets} off of the output keys. data[name[1:-1]] = outfiles[i] num_outputs += 1 - assert ( - len(outfiles) == num_outputs - ), 'step "%s": mismatched number of output files (%d) and params (%d)' % ( - step, - num_outputs, - len(outfiles), + assert len(outfiles) == num_outputs, ( + 'step "%s": mismatched number of output files (%d) and params (%d)' + % ( + step, + num_outputs, + len(outfiles), + ) ) # NOQA: E501 if args.step: diff --git a/js/src/devtools/rootAnalysis/mach_commands.py b/js/src/devtools/rootAnalysis/mach_commands.py index bd8426f29f340..649eff7b3b92c 100644 --- a/js/src/devtools/rootAnalysis/mach_commands.py +++ b/js/src/devtools/rootAnalysis/mach_commands.py @@ -159,8 +159,9 @@ def bootstrap(command_context, **kwargs): "what", default=["objdir", "work"], nargs="*", - help="Target to clobber, must be one of {{{}}} (default " - "objdir and work).".format(", ".join(CLOBBER_CHOICES)), + help="Target to clobber, must be one of {{{}}} (default objdir and work).".format( + ", ".join(CLOBBER_CHOICES) + ), ) def clobber(command_context, what, **kwargs): from mozbuild.controller.clobber import Clobberer @@ -344,15 +345,13 @@ def gather_hazard_data(command_context, **kwargs): ) fh.write(data) - buildscript = " ".join( - [ - command_context.topsrcdir + "/mach hazards compile", - *kwargs.get("what", []), - "--job-size=3.0", # Conservatively estimate 3GB/process - "--project=" + project, - "--haz-objdir=" + objdir, - ] - ) + buildscript = " ".join([ + command_context.topsrcdir + "/mach hazards compile", + *kwargs.get("what", []), + "--job-size=3.0", # Conservatively estimate 3GB/process + "--project=" + project, + "--haz-objdir=" + objdir, + ]) args = [ os.path.join(script_dir(command_context), "run_complete"), "--foreground", diff --git a/js/src/devtools/rootAnalysis/run-test.py b/js/src/devtools/rootAnalysis/run-test.py index 9301fd8fbcc60..b985aa67a4d36 100755 --- a/js/src/devtools/rootAnalysis/run-test.py +++ b/js/src/devtools/rootAnalysis/run-test.py @@ -84,9 +84,11 @@ cfg.sixgill, "usr", "libexec", "sixgill", "gcc", "xgill.so" ) -subprocess.check_call( - [cfg.js, "-e", 'if (!getBuildConfiguration("has-ctypes")) quit(1)'] -) +subprocess.check_call([ + cfg.js, + "-e", + 'if (!getBuildConfiguration("has-ctypes")) quit(1)', +]) def binpath(prog): diff --git a/js/src/devtools/rootAnalysis/t/graph/test.py b/js/src/devtools/rootAnalysis/t/graph/test.py index 5589b784bfdf0..bc7d84f44f597 100644 --- a/js/src/devtools/rootAnalysis/t/graph/test.py +++ b/js/src/devtools/rootAnalysis/t/graph/test.py @@ -42,13 +42,11 @@ assert callgraph.calleeGraph[node[src]][node[dst]] funcInfo = test.load_funcInfo() -rroots = set( - [ - callgraph.mangledToUnmangled[f] - for f in funcInfo - if funcInfo[f].get("recursive_root") - ] -) +rroots = set([ + callgraph.mangledToUnmangled[f] + for f in funcInfo + if funcInfo[f].get("recursive_root") +]) assert len(set([node[1], node[2]]) & rroots) == 1 assert len(set([node[4], node[5]]) & rroots) == 1 assert len(rroots) == 4, f"rroots = {rroots}" # n1, n4, f, self_recursive diff --git a/js/src/frontend/align_stack_comment.py b/js/src/frontend/align_stack_comment.py index 60895f9630ff4..5350b7fc57439 100755 --- a/js/src/frontend/align_stack_comment.py +++ b/js/src/frontend/align_stack_comment.py @@ -4,13 +4,13 @@ # You can obtain one at http://mozilla.org/MPL/2.0/. -""" Usage: align_stack_comment.py FILE +"""Usage: align_stack_comment.py FILE - This script aligns the stack transition comment in BytecodeEmitter and - its helper classes. +This script aligns the stack transition comment in BytecodeEmitter and +its helper classes. - The stack transition comment looks like the following: - // [stack] VAL1 VAL2 VAL3 +The stack transition comment looks like the following: + // [stack] VAL1 VAL2 VAL3 """ import re diff --git a/js/src/gdb/run-tests.py b/js/src/gdb/run-tests.py index 33efa7d83017c..7474271e50a42 100644 --- a/js/src/gdb/run-tests.py +++ b/js/src/gdb/run-tests.py @@ -252,14 +252,12 @@ def run_tests(tests, summary): # python 3.3 fixed a bug with concurrently writing .pyc files. # https://bugs.python.org/issue13146 embedded_version = ( - subprocess.check_output( - [ - OPTIONS.gdb_executable, - "--batch", - "--ex", - "python import sys; print(sys.hexversion)", - ] - ) + subprocess.check_output([ + OPTIONS.gdb_executable, + "--batch", + "--ex", + "python import sys; print(sys.hexversion)", + ]) .decode("ascii") .strip() ) diff --git a/js/src/jit-test/jit_test.py b/js/src/jit-test/jit_test.py index 6b49fa0412714..2381ec8672988 100755 --- a/js/src/jit-test/jit_test.py +++ b/js/src/jit-test/jit_test.py @@ -107,13 +107,13 @@ def main(argv): "--failed-only", dest="failed_only", action="store_true", - help="if --show-output is given, only print output for" " failed tests", + help="if --show-output is given, only print output for failed tests", ) op.add_argument( "--no-show-failed", dest="no_show_failed", action="store_true", - help="don't print output for failed tests" " (no-op with --show-output)", + help="don't print output for failed tests (no-op with --show-output)", ) op.add_argument( "-x", @@ -327,14 +327,14 @@ def main(argv): action="store", type=str, default="/data/local/tmp/test_root", - help="The remote directory to use as test root" " (e.g. %(default)s)", + help="The remote directory to use as test root (e.g. %(default)s)", ) op.add_argument( "--localLib", dest="local_lib", action="store", type=str, - help="The location of libraries to push -- preferably" " stripped", + help="The location of libraries to push -- preferably stripped", ) op.add_argument( "--repeat", type=int, default=1, help="Repeat tests the given number of times." @@ -536,8 +536,7 @@ def repeat_copy(job_list_generator, repeat): elif options.debugger: if job_count > 1: print( - "Multiple tests match command line" - " arguments, debugger can only run one" + "Multiple tests match command line arguments, debugger can only run one" ) jobs = list(job_list) @@ -589,7 +588,7 @@ def repeat_copy(job_list_generator, repeat): except OSError: if not os.path.exists(prefix[0]): print( - "JS shell argument: file does not exist:" f" '{prefix[0]}'", + f"JS shell argument: file does not exist: '{prefix[0]}'", file=sys.stderr, ) sys.exit(1) diff --git a/js/src/jit/GenerateABIFunctionType.py b/js/src/jit/GenerateABIFunctionType.py index bfa38b2d673bd..04be10d1de2a7 100644 --- a/js/src/jit/GenerateABIFunctionType.py +++ b/js/src/jit/GenerateABIFunctionType.py @@ -106,7 +106,7 @@ def arm32_soft_fp_args(func_type): contents += f"MakeInt64(stack_pointer[{stackOffset}], stack_pointer[{stackOffset + 1}])" stackOffset += 2 else: - contents += f"MakeInt64(a{intRegIndex}, a{intRegIndex+1})" + contents += f"MakeInt64(a{intRegIndex}, a{intRegIndex + 1})" intRegIndex += 2 elif arg == "Float32": if intRegIndex == numIntArgRegs: @@ -162,7 +162,7 @@ def arm32_hard_fp_args(func_type): contents += f"MakeInt64(stack_pointer[{stackOffset}], stack_pointer[{stackOffset + 1}])" stackOffset += 2 else: - contents += f"MakeInt64(a{intRegIndex}, a{intRegIndex+1})" + contents += f"MakeInt64(a{intRegIndex}, a{intRegIndex + 1})" intRegIndex += 2 elif arg == "Float32": if floatRegIndex == numFloatArgRegs: diff --git a/js/src/shell/js-gdb.py b/js/src/shell/js-gdb.py index dd4ae7b0cd1f1..dbe83fdb93f38 100644 --- a/js/src/shell/js-gdb.py +++ b/js/src/shell/js-gdb.py @@ -2,7 +2,7 @@ # 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/. -""" GDB Python customization auto-loader for JS shell binary """ +"""GDB Python customization auto-loader for JS shell binary""" # This script will be installed into $objdir/dist/bin. Add $objdir to gdb's # source search path and load in the Gecko+JS init file. diff --git a/js/src/tests/compare_bench.py b/js/src/tests/compare_bench.py index ec741682bbae1..bfb8e6c680d1f 100644 --- a/js/src/tests/compare_bench.py +++ b/js/src/tests/compare_bench.py @@ -1,6 +1,5 @@ #!/usr/bin/env python2.4 -"""usage: %progname candidate_path baseline_path -""" +"""usage: %progname candidate_path baseline_path""" import json import optparse diff --git a/js/src/tests/jstests.py b/js/src/tests/jstests.py index 91ab01ad57bc1..9d970f0d518e1 100755 --- a/js/src/tests/jstests.py +++ b/js/src/tests/jstests.py @@ -112,7 +112,7 @@ def parse_args(): op.add_argument( "--xul-info", dest="xul_info_src", - help="config data for xulRuntime" " (avoids search for config/autoconf.mk)", + help="config data for xulRuntime (avoids search for config/autoconf.mk)", ) harness_og = op.add_argument_group("Harness Controls", "Control how tests are run.") @@ -121,19 +121,19 @@ def parse_args(): "--worker-count", type=int, default=max(1, get_cpu_count()), - help="Number of tests to run in parallel" " (default %(default)s)", + help="Number of tests to run in parallel (default %(default)s)", ) harness_og.add_argument( "-t", "--timeout", type=float, default=150.0, - help="Set maximum time a test is allows to run" " (in seconds).", + help="Set maximum time a test is allows to run (in seconds).", ) harness_og.add_argument( "--show-slow", action="store_true", - help="Show tests taking longer than a minimum time" " (in seconds).", + help="Show tests taking longer than a minimum time (in seconds).", ) harness_og.add_argument( "--slow-test-threshold", @@ -168,12 +168,12 @@ def parse_args(): harness_og.add_argument( "--tbpl", action="store_true", - help="Runs each test in all configurations tbpl" " tests.", + help="Runs each test in all configurations tbpl tests.", ) harness_og.add_argument( "--tbpl-debug", action="store_true", - help="Runs each test in some faster configurations" " tbpl tests.", + help="Runs each test in some faster configurations tbpl tests.", ) harness_og.add_argument( "-g", "--debug", action="store_true", help="Run a test in debugger." @@ -187,7 +187,7 @@ def parse_args(): harness_og.add_argument( "--passthrough", action="store_true", - help="Run tests with stdin/stdout attached to" " caller.", + help="Run tests with stdin/stdout attached to caller.", ) harness_og.add_argument( "--test-reflect-stringify", @@ -244,14 +244,14 @@ def parse_args(): action="store", type=str, default="/data/local/tmp/test_root", - help="The remote directory to use as test root" " (e.g. %(default)s)", + help="The remote directory to use as test root (e.g. %(default)s)", ) harness_og.add_argument( "--localLib", dest="local_lib", action="store", type=str, - help="The location of libraries to push -- preferably" " stripped", + help="The location of libraries to push -- preferably stripped", ) harness_og.add_argument( "--no-xdr", @@ -319,7 +319,7 @@ def parse_args(): input_og.add_argument( "--no-extensions", action="store_true", - help="Run only tests conforming to the ECMAScript 5" " standard.", + help="Run only tests conforming to the ECMAScript 5 standard.", ) input_og.add_argument( "--repeat", type=int, default=1, help="Repeat tests the given number of times." @@ -336,23 +336,23 @@ def parse_args(): "-o", "--show-output", action="store_true", - help="Print each test's output to the file given by" " --output-file.", + help="Print each test's output to the file given by --output-file.", ) output_og.add_argument( "-F", "--failed-only", action="store_true", - help="If a --show-* option is given, only print" " output for failed tests.", + help="If a --show-* option is given, only print output for failed tests.", ) output_og.add_argument( "--no-show-failed", action="store_true", - help="Don't print output for failed tests" " (no-op with --show-output).", + help="Don't print output for failed tests (no-op with --show-output).", ) output_og.add_argument( "-O", "--output-file", - help="Write all output to the given file" " (default: stdout).", + help="Write all output to the given file (default: stdout).", ) output_og.add_argument( "--failure-file", help="Write all not-passed tests to the given file." @@ -375,7 +375,7 @@ def parse_args(): dest="format", default="none", choices=["automation", "none"], - help="Output format. Either automation or none" " (default %(default)s).", + help="Output format. Either automation or none (default %(default)s).", ) output_og.add_argument( "--log-wptreport", @@ -458,9 +458,9 @@ def parse_args(): # requested tests set. if options.test_file: for test_file in options.test_file: - requested_paths |= set( - [line.strip() for line in open(test_file).readlines()] - ) + requested_paths |= set([ + line.strip() for line in open(test_file).readlines() + ]) excluded_paths = set(options.excluded_paths) @@ -556,17 +556,15 @@ def load_wpt_tests(xul_tester, requested_paths, excluded_paths, update_manifest= ) kwargs = vars(wptcommandline.create_parser().parse_args([])) - kwargs.update( - { - "config": os.path.join( - manifest_root, "_tests", "web-platform", "wptrunner.local.ini" - ), - "gecko_e10s": False, - "product": "firefox", - "verify": False, - "wasm": xul_tester.test("wasmIsSupported()"), - } - ) + kwargs.update({ + "config": os.path.join( + manifest_root, "_tests", "web-platform", "wptrunner.local.ini" + ), + "gecko_e10s": False, + "product": "firefox", + "verify": False, + "wasm": xul_tester.test("wasmIsSupported()"), + }) wptcommandline.set_from_config(kwargs) def filter_jsshell_tests(it): @@ -793,8 +791,7 @@ def main(): if options.debug: if test_count > 1: print( - "Multiple tests match command line arguments," - " debugger can only run one" + "Multiple tests match command line arguments, debugger can only run one" ) for tc in test_gen: print(f" {tc.path}") diff --git a/js/src/tests/lib/jittests.py b/js/src/tests/lib/jittests.py index 209f167bcd0ff..e2ebbd3895a1c 100755 --- a/js/src/tests/lib/jittests.py +++ b/js/src/tests/lib/jittests.py @@ -288,12 +288,12 @@ def from_file(cls, path, options): else: test.expect_status = status except ValueError: - print("warning: couldn't parse exit status" f" {value}") + print(f"warning: couldn't parse exit status {value}") elif name == "thread-count": try: test.jitflags.append(f"--thread-count={int(value, 0)}") except ValueError: - print("warning: couldn't parse thread-count" f" {value}") + print(f"warning: couldn't parse thread-count {value}") elif name == "include": test.other_lib_includes.append(value) elif name == "local-include": @@ -310,8 +310,7 @@ def from_file(cls, path, options): print("warning: couldn't parse skip-variant-if") else: print( - f"{path}: warning: unrecognized |jit-test| attribute" - f" {part}" + f"{path}: warning: unrecognized |jit-test| attribute {part}" ) elif name == "slow": test.slow = True @@ -339,9 +338,9 @@ def from_file(cls, path, options): # works, and not meant as a way to accept temporary # failing tests. These tests should either be fixed or # skipped. - assert ( - "self-test" in path - ), f"{path}: has an unexpected crash annotation." + assert "self-test" in path, ( + f"{path}: has an unexpected crash annotation." + ) test.expect_crash = True elif name.startswith("--"): # // |jit-test| --ion-gvn=off; --no-sse4 @@ -352,9 +351,7 @@ def from_file(cls, path, options): # // |jit-test| -P pref(=value)? test.jitflags.append("--setpref=" + prefAndValue[1]) else: - print( - f"{path}: warning: unrecognized |jit-test| attribute" f" {part}" - ) + print(f"{path}: warning: unrecognized |jit-test| attribute {part}") if options.valgrind_all: test.valgrind = True diff --git a/js/src/tests/lib/manifest.py b/js/src/tests/lib/manifest.py index 20a704fd6aea4..2cfd3e40fae99 100644 --- a/js/src/tests/lib/manifest.py +++ b/js/src/tests/lib/manifest.py @@ -42,9 +42,7 @@ def as_js(self): var release_or_beta = getBuildConfiguration('release_or_beta'); var isDebugBuild={str(self.isdebug).lower()}; var Android={str(self.os == "Android").lower()}; -""".replace( - "\n", "" - ) +""".replace("\n", "") @classmethod def create(cls, jsdir): @@ -283,18 +281,16 @@ def _build_manifest_script_entry(script_name, test): properties = [] if test.terms: # Remove jsreftest internal terms. - terms = " ".join( - [ - term - for term in test.terms.split() - if not ( - term in {"module", "async", "test262-raw"} - or term.startswith("error:") - or term.startswith("ignore-flag(") - or term.startswith("shell-option(") - ) - ] - ) + terms = " ".join([ + term + for term in test.terms.split() + if not ( + term in {"module", "async", "test262-raw"} + or term.startswith("error:") + or term.startswith("ignore-flag(") + or term.startswith("shell-option(") + ) + ]) if terms: line.append(terms) if test.error: @@ -512,7 +508,7 @@ def _parse_external_manifest(filename, relpath): if not matches: matches = include_re.match(line) if not matches: - print("warning: unrecognized line in jstests.list:" f" {line}") + print(f"warning: unrecognized line in jstests.list: {line}") continue include_file = matches.group("path") @@ -533,13 +529,11 @@ def _parse_external_manifest(filename, relpath): assert path.endswith("jstests.list") path = path[: -len("jstests.list")] - entries.append( - { - "path": path, - "terms": matches.group("terms"), - "comment": comment.strip(), - } - ) + entries.append({ + "path": path, + "terms": matches.group("terms"), + "comment": comment.strip(), + }) # if one directory name is a prefix of another, we want the shorter one # first @@ -566,16 +560,14 @@ def _apply_external_manifests(filename, testcase, entries, xul_tester): def _is_test_file(path_from_root, basename, filename, path_options): # Any file whose basename matches something in this set is ignored. - EXCLUDED = set( - ( - "browser.js", - "shell.js", - "template.js", - "user.js", - "js-test-driver-begin.js", - "js-test-driver-end.js", - ) - ) + EXCLUDED = set(( + "browser.js", + "shell.js", + "template.js", + "user.js", + "js-test-driver-begin.js", + "js-test-driver-end.js", + )) # Skip js files in the root test directory. if not path_from_root: diff --git a/js/src/tests/lib/results.py b/js/src/tests/lib/results.py index f567c6390b3b8..4907e7945c0bd 100644 --- a/js/src/tests/lib/results.py +++ b/js/src/tests/lib/results.py @@ -121,14 +121,12 @@ def from_wpt_output(cls, output): test_output += "expected %s, found %s" % (expected, test.status) if test.message: test_output += ' (with message: "%s")' % (test.message,) - subtests.append( - { - "test": output.test.wpt.id, - "subtest": test.name, - "status": test.status, - "expected": expected, - } - ) + subtests.append({ + "test": output.test.wpt.id, + "subtest": test.name, + "status": test.status, + "expected": expected, + }) results.append(test_result) stdout.append(test_output) @@ -172,8 +170,7 @@ def from_output(cls, output): results.append((cls.PASS, msg)) else: m = re.match( - "--- NOTE: IN THIS TESTCASE, WE EXPECT EXIT CODE" - " ((?:-|\\d)+) ---", + "--- NOTE: IN THIS TESTCASE, WE EXPECT EXIT CODE ((?:-|\\d)+) ---", line, ) if m: diff --git a/js/src/tests/lib/wptreport.py b/js/src/tests/lib/wptreport.py index 39aeea212f8f3..2f4e7c6df6a37 100644 --- a/js/src/tests/lib/wptreport.py +++ b/js/src/tests/lib/wptreport.py @@ -26,23 +26,19 @@ def suite_start(self): """ Produce the "suite_start" message at the present time. """ - self.formatter.suite_start( - { - "time": time(), - "run_info": {}, - } - ) + self.formatter.suite_start({ + "time": time(), + "run_info": {}, + }) def suite_end(self): """ Produce the "suite_end" message at the present time and write the results to the file path given in the constructor. """ - result = self.formatter.suite_end( - { - "time": time(), - } - ) + result = self.formatter.suite_end({ + "time": time(), + }) with open(self.out, "w") as fp: fp.write(result) @@ -65,21 +61,17 @@ def test(self, result, duration): end_time = time() start_time = end_time - duration - self.formatter.test_start( - { - "test": testname, - "time": start_time, - } - ) + self.formatter.test_start({ + "test": testname, + "time": start_time, + }) for subtest in result["subtests"]: self.formatter.test_status(subtest) - self.formatter.test_end( - { - "test": testname, - "time": end_time, - "status": result["status"], - "expected": result["expected"], - } - ) + self.formatter.test_end({ + "test": testname, + "time": end_time, + "status": result["status"], + "expected": result["expected"], + }) diff --git a/js/src/tests/non262/String/make-normalize-generateddata-input.py b/js/src/tests/non262/String/make-normalize-generateddata-input.py index 3fe19b55216ef..554d1ddebff53 100644 --- a/js/src/tests/non262/String/make-normalize-generateddata-input.py +++ b/js/src/tests/non262/String/make-normalize-generateddata-input.py @@ -1,10 +1,10 @@ #!/usr/bin/python -B -""" Usage: make-normalize-generateddata-input.py PATH_TO_MOZILLA_CENTRAL +"""Usage: make-normalize-generateddata-input.py PATH_TO_MOZILLA_CENTRAL - This script generates test input data for String.prototype.normalize - from intl/icu/source/data/unidata/NormalizationTest.txt - to js/src/tests/non262/String/normalize-generateddata-input.js +This script generates test input data for String.prototype.normalize +from intl/icu/source/data/unidata/NormalizationTest.txt +to js/src/tests/non262/String/normalize-generateddata-input.js """ import re diff --git a/js/src/tests/parsemark.py b/js/src/tests/parsemark.py index 4723814f8c912..00574ce3c60e5 100644 --- a/js/src/tests/parsemark.py +++ b/js/src/tests/parsemark.py @@ -134,20 +134,20 @@ def main(): metavar="COUNT", type=int, default=50, - help="timed data runs that count towards the average" " [%default]", + help="timed data runs that count towards the average [%default]", ) parser.add_option( "-s", "--shell", metavar="PATH", - help="explicit shell location; when omitted, will look" " in likely places", + help="explicit shell location; when omitted, will look in likely places", ) parser.add_option( "-b", "--baseline", metavar="JSON_PATH", dest="baseline_path", - help="json file with baseline values to " "compare against", + help="json file with baseline values to compare against", ) parser.add_option( "--mode", diff --git a/js/src/tests/test/run.py b/js/src/tests/test/run.py index 7bf2021002376..9a92a9d38dff2 100755 --- a/js/src/tests/test/run.py +++ b/js/src/tests/test/run.py @@ -51,28 +51,35 @@ def importLocal(self): subprocess.check_call(["git", "-C", cloneDir, "checkout", "-b", branch]) # Make changes on the new branch # Remove test/language/export/escaped-from.js - subprocess.check_call( - ["git", "-C", cloneDir, "rm", "test/language/export/escaped-from.js"] - ) + subprocess.check_call([ + "git", + "-C", + cloneDir, + "rm", + "test/language/export/escaped-from.js", + ]) # Rename test/language/export/escaped-default.js - subprocess.check_call( - [ - "git", - "-C", - cloneDir, - "mv", - "test/language/export/escaped-default.js", - "test/language/export/escaped-foobarbaz.js", - ] - ) + subprocess.check_call([ + "git", + "-C", + cloneDir, + "mv", + "test/language/export/escaped-default.js", + "test/language/export/escaped-foobarbaz.js", + ]) # Copy fixtures files fixturesDir = os.path.join(testDir, "fixtures", "import", "files") shutil.copytree(fixturesDir, os.path.join(cloneDir, "test", "temp42")) # Stage and Commit changes subprocess.check_call(["git", "-C", cloneDir, "add", "."]) - subprocess.check_call( - ["git", "-C", cloneDir, "commit", "-m", '"local foo"'] - ) + subprocess.check_call([ + "git", + "-C", + cloneDir, + "commit", + "-m", + '"local foo"', + ]) # Run import script print( diff --git a/js/src/tests/test262-export.py b/js/src/tests/test262-export.py index e5095a09e1c50..b4dd0a8e257e3 100755 --- a/js/src/tests/test262-export.py +++ b/js/src/tests/test262-export.py @@ -17,16 +17,14 @@ # Skip all common files used to support tests for jstests # These files are listed in the README.txt -SUPPORT_FILES = set( - [ - "browser.js", - "shell.js", - "template.js", - "user.js", - "js-test-driver-begin.js", - "js-test-driver-end.js", - ] -) +SUPPORT_FILES = set([ + "browser.js", + "shell.js", + "template.js", + "user.js", + "js-test-driver-begin.js", + "js-test-driver-end.js", +]) # Run once per subdirectory diff --git a/js/src/tests/test262-update.py b/js/src/tests/test262-update.py index 634f59c02147f..d528e9a9910f2 100755 --- a/js/src/tests/test262-update.py +++ b/js/src/tests/test262-update.py @@ -14,16 +14,14 @@ from operator import itemgetter # Skip all tests which use features not supported in SpiderMonkey. -UNSUPPORTED_FEATURES = set( - [ - "tail-call-optimization", - "Intl.Locale-info", # Bug 1693576 - "source-phase-imports", - "source-phase-imports-module-source", - "import-defer", - "nonextensible-applies-to-private", # Bug 1991478 - ] -) +UNSUPPORTED_FEATURES = set([ + "tail-call-optimization", + "Intl.Locale-info", # Bug 1693576 + "source-phase-imports", + "source-phase-imports-module-source", + "import-defer", + "nonextensible-applies-to-private", # Bug 1991478 +]) FEATURE_CHECK_NEEDED = { "Atomics": "!this.hasOwnProperty('Atomics')", "SharedArrayBuffer": "!this.hasOwnProperty('SharedArrayBuffer')", @@ -318,7 +316,7 @@ def convertTestFile(test262parser, testSource, testName, includeSet, strictTests or isAsync or isNegative or testName.split(os.path.sep)[0] == "harness" - ), ("Missing async attribute in: %s" % testName) + ), "Missing async attribute in: %s" % testName # When the "module" attribute is set, the source code is module code. isModule = "module" in testRec @@ -341,38 +339,29 @@ def convertTestFile(test262parser, testSource, testName, includeSet, strictTests else: releaseOrBeta = [f for f in testRec["features"] if f in RELEASE_OR_BETA] if releaseOrBeta: - refTestSkipIf.append( - ( - "release_or_beta", - "%s is not released yet" % ",".join(releaseOrBeta), - ) - ) + refTestSkipIf.append(( + "release_or_beta", + "%s is not released yet" % ",".join(releaseOrBeta), + )) featureCheckNeeded = [ f for f in testRec["features"] if f in FEATURE_CHECK_NEEDED ] if featureCheckNeeded: - refTestSkipIf.append( - ( - "||".join( - [FEATURE_CHECK_NEEDED[f] for f in featureCheckNeeded] - ), - "%s is not enabled unconditionally" - % ",".join(featureCheckNeeded), - ) - ) + refTestSkipIf.append(( + "||".join([FEATURE_CHECK_NEEDED[f] for f in featureCheckNeeded]), + "%s is not enabled unconditionally" % ",".join(featureCheckNeeded), + )) if ( "Atomics" in testRec["features"] and "SharedArrayBuffer" in testRec["features"] ): - refTestSkipIf.append( - ( - "(this.hasOwnProperty('getBuildConfiguration')" - "&&getBuildConfiguration('arm64-simulator'))", - "ARM64 Simulator cannot emulate atomics", - ) - ) + refTestSkipIf.append(( + "(this.hasOwnProperty('getBuildConfiguration')" + "&&getBuildConfiguration('arm64-simulator'))", + "ARM64 Simulator cannot emulate atomics", + )) shellOptions = { SHELL_OPTIONS[f] for f in testRec["features"] if f in SHELL_OPTIONS @@ -577,12 +566,10 @@ def process_test262(test262Dir, test262OutDir, strictTests, externManifests): writeTestFile(test262OutDir, newFileName, newSource) if externRefTest is not None: - externManifests.append( - { - "name": newFileName, - "reftest": externRefTest, - } - ) + externManifests.append({ + "name": newFileName, + "reftest": externRefTest, + }) # Remove "sm/non262.js" because it overwrites our test harness with stub # functions. @@ -873,13 +860,23 @@ def update_test262(args): return fetch_local_changes(inDir, outDir, srcDir, strictTests) if revision == "HEAD": - subprocess.check_call( - ["git", "clone", "--depth=1", "--branch=%s" % branch, url, inDir] - ) + subprocess.check_call([ + "git", + "clone", + "--depth=1", + "--branch=%s" % branch, + url, + inDir, + ]) else: - subprocess.check_call( - ["git", "clone", "--single-branch", "--branch=%s" % branch, url, inDir] - ) + subprocess.check_call([ + "git", + "clone", + "--single-branch", + "--branch=%s" % branch, + url, + inDir, + ]) subprocess.check_call(["git", "-C", inDir, "reset", "--hard", revision]) # If a PR number is provided, fetches only the new and modified files diff --git a/js/src/util/make_unicode.py b/js/src/util/make_unicode.py index 4145433fb9e34..0e30703f4665f 100755 --- a/js/src/util/make_unicode.py +++ b/js/src/util/make_unicode.py @@ -571,15 +571,13 @@ def is_equals(iter1, iter2): ) # Ensure all case mapping contexts are known (see Unicode 9.0, §3.13 Default Case Algorithms). - assert set( - [ - "After_I", - "After_Soft_Dotted", - "Final_Sigma", - "More_Above", - "Not_Before_Dot", - ] - ).issuperset( + assert set([ + "After_I", + "After_Soft_Dotted", + "Final_Sigma", + "More_Above", + "Not_Before_Dot", + ]).issuperset( set( filter( partial(is_not, None), diff --git a/js/src/vm/jsopcode.py b/js/src/vm/jsopcode.py index e64ec246dfe77..6c5dbf2cdfe1d 100644 --- a/js/src/vm/jsopcode.py +++ b/js/src/vm/jsopcode.py @@ -149,12 +149,12 @@ def find_by_name(list, name): def add_to_index(index, opcode): types = find_by_name(index, opcode.category_name) if types is None: - raise Exception("Category is not listed in index: " f"{opcode.category_name}") + raise Exception(f"Category is not listed in index: {opcode.category_name}") opcodes = find_by_name(types, opcode.type_name) if opcodes is None: if opcode.type_name: raise Exception( - f"Type is not listed in {opcode.category_name}: " f"{opcode.type_name}" + f"Type is not listed in {opcode.category_name}: {opcode.type_name}" ) types.append((opcode.type_name, [opcode])) return @@ -302,7 +302,7 @@ def get_opcodes(dir): opcode.sort_key = opcode.op if opcode.category_name == "": - raise Exception("Category is not specified for " f"{opcode.op}") + raise Exception(f"Category is not specified for {opcode.op}") add_to_index(index, opcode) else: if group_head.length != opcode.length: diff --git a/js/src/vm/make_opcode_doc.py b/js/src/vm/make_opcode_doc.py index 80547a18f09ba..7eefabb2ee4ce 100755 --- a/js/src/vm/make_opcode_doc.py +++ b/js/src/vm/make_opcode_doc.py @@ -4,14 +4,14 @@ # You can obtain one at http://mozilla.org/MPL/2.0/. -""" Usage: python make_opcode_doc.py +"""Usage: python make_opcode_doc.py - This script generates SpiderMonkey bytecode documentation - from js/src/vm/Opcodes.h. +This script generates SpiderMonkey bytecode documentation +from js/src/vm/Opcodes.h. - Output is written to stdout and should be pasted into the following - MDN page: - https://developer.mozilla.org/en-US/docs/SpiderMonkey/Internals/Bytecode +Output is written to stdout and should be pasted into the following +MDN page: +https://developer.mozilla.org/en-US/docs/SpiderMonkey/Internals/Bytecode """ import os diff --git a/js/src/wasm/GenerateBuiltinModules.py b/js/src/wasm/GenerateBuiltinModules.py index f8a137049486c..e263313770892 100644 --- a/js/src/wasm/GenerateBuiltinModules.py +++ b/js/src/wasm/GenerateBuiltinModules.py @@ -122,7 +122,7 @@ def main(c_out, yaml_path): if "inline_op" in op: inlineOp = f"BuiltinInlineOp::{op['inline_op']}" contents += ( - f" M({op['op']}, \"{op['export']}\", " + f' M({op["op"]}, "{op["export"]}", ' f"{sa['name']}, {sa['type']}, {cppBool(sa['needs_thunk'])}, {op['entry']}, {cppBool(op['uses_memory'])}, {inlineOp}, {i})\\\n" ) contents += "\n" diff --git a/layout/tools/reftest/reftest/__init__.py b/layout/tools/reftest/reftest/__init__.py index 8fbac7c3d3986..02b828ac2f9a6 100644 --- a/layout/tools/reftest/reftest/__init__.py +++ b/layout/tools/reftest/reftest/__init__.py @@ -125,9 +125,9 @@ def add_test(file, annotations, referenced_test=None, skip_if=""): for annotation in annotations: key, condition = self.translate_condition_for_mozinfo(annotation) - test_dict[key] = "\n".join( - [t for t in [test_dict.get(key, ""), condition] if t] - ) + test_dict[key] = "\n".join([ + t for t in [test_dict.get(key, ""), condition] if t + ]) self.tests.append(test_dict) diff --git a/layout/tools/reftest/reftestcommandline.py b/layout/tools/reftest/reftestcommandline.py index 72c9316e31a80..40e4f1efc2e68 100644 --- a/layout/tools/reftest/reftestcommandline.py +++ b/layout/tools/reftest/reftestcommandline.py @@ -152,8 +152,7 @@ def __init__(self, **kwargs): dest="ignoreWindowSize", action="store_true", default=False, - help="ignore the window size, which may cause spurious " - "failures and passes", + help="ignore the window size, which may cause spurious failures and passes", ) self.add_argument( @@ -188,7 +187,7 @@ def __init__(self, **kwargs): default=[], dest="environment", metavar="NAME=VALUE", - help="sets the given variable in the application's " "environment", + help="sets the given variable in the application's environment", ) self.add_argument( @@ -368,13 +367,11 @@ def get_ip(self): return moznetwork.get_ip() def set_default_suite(self, options): - manifests = OrderedDict( - [ - ("reftest.list", "reftest"), - ("crashtests.list", "crashtest"), - ("jstests.list", "jstestbrowser"), - ] - ) + manifests = OrderedDict([ + ("reftest.list", "reftest"), + ("crashtests.list", "crashtest"), + ("jstests.list", "jstestbrowser"), + ]) for test_path in options.tests: file_name = os.path.basename(test_path) diff --git a/layout/tools/reftest/remotereftest.py b/layout/tools/reftest/remotereftest.py index d653e1f57776a..6d08eb7c9361c 100644 --- a/layout/tools/reftest/remotereftest.py +++ b/layout/tools/reftest/remotereftest.py @@ -329,7 +329,7 @@ def createReftestProfile(self, options, **kwargs): options, server=options.remoteWebServer, port=options.httpPort, - **kwargs + **kwargs, ) profileDir = profile.profile prefs = {} @@ -407,7 +407,7 @@ def runApp( valgrindPath=None, valgrindArgs=None, valgrindSuppFiles=None, - **profileArgs + **profileArgs, ): if cmdargs is None: cmdargs = [] diff --git a/layout/tools/reftest/runreftest.py b/layout/tools/reftest/runreftest.py index d25bfc35d0629..7f94282cbf08d 100644 --- a/layout/tools/reftest/runreftest.py +++ b/layout/tools/reftest/runreftest.py @@ -5,6 +5,7 @@ """ Runs the reftest test harness. """ + import json import os import platform @@ -763,12 +764,10 @@ def runTests(self, tests, options, cmdargs=None): print("REFTEST INFO | Result summary:") for summaryObj, (text, categories) in zip(summaryObjects, summaryLines): - details = ", ".join( - [ - "%d %s" % (summaryObj[attribute], description) - for (attribute, description) in categories - ] - ) + details = ", ".join([ + "%d %s" % (summaryObj[attribute], description) + for (attribute, description) in categories + ]) print( "REFTEST INFO | " + text diff --git a/layout/tools/reftest/selftest/conftest.py b/layout/tools/reftest/selftest/conftest.py index f29fdbb003e1b..48fe0447560ef 100644 --- a/layout/tools/reftest/selftest/conftest.py +++ b/layout/tools/reftest/selftest/conftest.py @@ -51,40 +51,32 @@ def get_reftest(setup_test_harness, binary, parser): build = parser.build_obj options = vars(parser.parse_args([])) - options.update( - { - "app": binary, - "focusFilterMode": "non-needs-focus", - "suite": "reftest", - } - ) + options.update({ + "app": binary, + "focusFilterMode": "non-needs-focus", + "suite": "reftest", + }) if not os.path.isdir(build.bindir): package_root = os.path.dirname(harness_root) - options.update( - { - "extraProfileFiles": [os.path.join(package_root, "bin", "plugins")], - "reftestExtensionPath": os.path.join(harness_root, "reftest"), - "sandboxReadWhitelist": [here, os.environ["PYTHON_TEST_TMP"]], - "utilityPath": os.path.join(package_root, "bin"), - "specialPowersExtensionPath": os.path.join( - harness_root, "specialpowers" - ), - } - ) + options.update({ + "extraProfileFiles": [os.path.join(package_root, "bin", "plugins")], + "reftestExtensionPath": os.path.join(harness_root, "reftest"), + "sandboxReadWhitelist": [here, os.environ["PYTHON_TEST_TMP"]], + "utilityPath": os.path.join(package_root, "bin"), + "specialPowersExtensionPath": os.path.join(harness_root, "specialpowers"), + }) if "MOZ_FETCHES_DIR" in os.environ: options["sandboxReadWhitelist"].append(os.environ["MOZ_FETCHES_DIR"]) else: - options.update( - { - "extraProfileFiles": [os.path.join(build.topobjdir, "dist", "plugins")], - "sandboxReadWhitelist": [build.topobjdir, build.topsrcdir], - "specialPowersExtensionPath": os.path.join( - build.distdir, "xpi-stage", "specialpowers" - ), - } - ) + options.update({ + "extraProfileFiles": [os.path.join(build.topobjdir, "dist", "plugins")], + "sandboxReadWhitelist": [build.topobjdir, build.topsrcdir], + "specialPowersExtensionPath": os.path.join( + build.distdir, "xpi-stage", "specialpowers" + ), + }) def inner(**opts): options.update(opts) diff --git a/memory/replace/dmd/block_analyzer.py b/memory/replace/dmd/block_analyzer.py index 25b42054d6dd8..b4ddb09c925e0 100644 --- a/memory/replace/dmd/block_analyzer.py +++ b/memory/replace/dmd/block_analyzer.py @@ -117,8 +117,7 @@ def range_1_24(string): "-c", "--chain-reports", action="store_true", - help="if only one block is found to hold onto the object, report " - "the next one, too", + help="if only one block is found to hold onto the object, report the next one, too", ) diff --git a/mobile/android/android-components/automation/publish_to_maven_local_if_modified.py b/mobile/android/android-components/automation/publish_to_maven_local_if_modified.py index 23dde50635c9c..cd296b4e26702 100755 --- a/mobile/android/android-components/automation/publish_to_maven_local_if_modified.py +++ b/mobile/android/android-components/automation/publish_to_maven_local_if_modified.py @@ -124,9 +124,11 @@ def find_project_root(): shell=True, ) else: - run_cmd_checked( - ["./gradlew", "publishToMavenLocal", f"-Plocal={time.time_ns()}"] - ) + run_cmd_checked([ + "./gradlew", + "publishToMavenLocal", + f"-Plocal={time.time_ns()}", + ]) with open(LAST_CONTENTS_HASH_FILE, "w") as f: f.write(contents_hash) f.write("\n") diff --git a/mobile/android/android-components/plugins/dependencies/src/main/java/appservices_version_bump.py b/mobile/android/android-components/plugins/dependencies/src/main/java/appservices_version_bump.py index eaf0a523cebe5..d3b3f9276bf31 100755 --- a/mobile/android/android-components/plugins/dependencies/src/main/java/appservices_version_bump.py +++ b/mobile/android/android-components/plugins/dependencies/src/main/java/appservices_version_bump.py @@ -167,8 +167,7 @@ def update_application_services(revision): json = get_as_nightly_json(f"revision.{revision}") target_as_version = json["version"] log.info( - f"Target app-services {as_channel.capitalize()} version " - f"is {target_as_version}" + f"Target app-services {as_channel.capitalize()} version is {target_as_version}" ) if compare_as_versions(current_as_version, target_as_version) >= 0: diff --git a/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/experimentintegration/generate_smoke_tests.py b/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/experimentintegration/generate_smoke_tests.py index 60c9b7920177a..a598ef0f7bec7 100644 --- a/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/experimentintegration/generate_smoke_tests.py +++ b/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/experimentintegration/generate_smoke_tests.py @@ -42,7 +42,7 @@ def search_for_smoke_tests(tests_name): locations.append(count) for location in locations: - test_names.append(f"{class_name}#{code[location+3].strip('()')}") + test_names.append(f"{class_name}#{code[location + 3].strip('()')}") return test_names diff --git a/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/syncintegration/conftest.py b/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/syncintegration/conftest.py index 63ea600f0aa16..c1eedf7b86138 100644 --- a/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/syncintegration/conftest.py +++ b/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/syncintegration/conftest.py @@ -156,11 +156,11 @@ def gradlewbuild(fxa_account, monkeypatch, gradlewbuild_log): def pytest_addoption(parser): parser.addoption( "--firefox", - help="path to firefox binary (defaults to " "downloading latest nightly build)", + help="path to firefox binary (defaults to downloading latest nightly build)", ) parser.addoption( "--tps", - help="path to tps add-on (defaults to " "downloading latest nightly build)", + help="path to tps add-on (defaults to downloading latest nightly build)", ) diff --git a/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/syncintegration/tps.py b/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/syncintegration/tps.py index 1ea224dae1398..93dd8880f1a2f 100644 --- a/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/syncintegration/tps.py +++ b/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/syncintegration/tps.py @@ -21,13 +21,11 @@ def _log(self, line): self.firefox_log.write(line + "\n") def run(self, test, phase="phase1", ignore_unused_engines=True): - self.profile.set_preferences( - { - "testing.tps.testFile": os.path.abspath(test), - "testing.tps.testPhase": phase, - "testing.tps.ignoreUnusedEngines": ignore_unused_engines, - } - ) + self.profile.set_preferences({ + "testing.tps.testFile": os.path.abspath(test), + "testing.tps.testPhase": phase, + "testing.tps.ignoreUnusedEngines": ignore_unused_engines, + }) args = ["-marionette"] process_args = {"processOutputLine": [self._log]} self.logger.info("Running: {} {}".format(self.firefox, " ".join(args))) diff --git a/mobile/android/fenix/tools/data_renewal_request.py b/mobile/android/fenix/tools/data_renewal_request.py index 9d23a788130a4..cdec3fe6a8f5b 100755 --- a/mobile/android/fenix/tools/data_renewal_request.py +++ b/mobile/android/fenix/tools/data_renewal_request.py @@ -29,19 +29,19 @@ if row["keep(Y/N)"] == "n": continue total_count += 1 - output_string += f'` {row["name"]}`\n' + output_string += f"` {row['name']}`\n" output_string += "1) Provide a link to the initial Data Collection Review Request for this collection.\n" - output_string += f' - {eval(row["data_reviews"])[0]}\n' + output_string += f" - {eval(row['data_reviews'])[0]}\n" output_string += "\n" output_string += "2) When will this collection now expire?\n" if len(row["new expiry version"]) == 0: output_string += f" - {updated_version}\n" else: - output_string += f' - {row["new expiry version"]}\n' + output_string += f" - {row['new expiry version']}\n" output_string += "\n" output_string += "3) Why was the initial period of collection insufficient?\n" - output_string += f' - {row["reason to extend"]}\n' + output_string += f" - {row['reason to extend']}\n" output_string += "\n" output_string += "———\n" diff --git a/mobile/android/fenix/tools/update-glean-tags.py b/mobile/android/fenix/tools/update-glean-tags.py index b9e9e7e08e768..e8863a0497bfe 100755 --- a/mobile/android/fenix/tools/update-glean-tags.py +++ b/mobile/android/fenix/tools/update-glean-tags.py @@ -5,6 +5,7 @@ See https://mozilla.github.io/glean/book/reference/yaml/tags.html """ + import urllib from pathlib import Path diff --git a/mobile/android/focus-android/tools/data_renewal_request.py b/mobile/android/focus-android/tools/data_renewal_request.py index 9d23a788130a4..cdec3fe6a8f5b 100755 --- a/mobile/android/focus-android/tools/data_renewal_request.py +++ b/mobile/android/focus-android/tools/data_renewal_request.py @@ -29,19 +29,19 @@ if row["keep(Y/N)"] == "n": continue total_count += 1 - output_string += f'` {row["name"]}`\n' + output_string += f"` {row['name']}`\n" output_string += "1) Provide a link to the initial Data Collection Review Request for this collection.\n" - output_string += f' - {eval(row["data_reviews"])[0]}\n' + output_string += f" - {eval(row['data_reviews'])[0]}\n" output_string += "\n" output_string += "2) When will this collection now expire?\n" if len(row["new expiry version"]) == 0: output_string += f" - {updated_version}\n" else: - output_string += f' - {row["new expiry version"]}\n' + output_string += f" - {row['new expiry version']}\n" output_string += "\n" output_string += "3) Why was the initial period of collection insufficient?\n" - output_string += f' - {row["reason to extend"]}\n' + output_string += f" - {row['reason to extend']}\n" output_string += "\n" output_string += "———\n" diff --git a/mobile/android/focus-android/tools/update-glean-tags.py b/mobile/android/focus-android/tools/update-glean-tags.py index 0096f3a939ee8..e4acf433f8445 100755 --- a/mobile/android/focus-android/tools/update-glean-tags.py +++ b/mobile/android/focus-android/tools/update-glean-tags.py @@ -5,6 +5,7 @@ See https://mozilla.github.io/glean/book/reference/yaml/tags.html """ + import urllib from pathlib import Path diff --git a/mobile/android/gradle/plugins/apilint/apidoc-plugin/src/test/resources/apidoc_test.py b/mobile/android/gradle/plugins/apilint/apidoc-plugin/src/test/resources/apidoc_test.py index 2f579f517c910..19b1fa94fe5da 100644 --- a/mobile/android/gradle/plugins/apilint/apidoc-plugin/src/test/resources/apidoc_test.py +++ b/mobile/android/gradle/plugins/apilint/apidoc-plugin/src/test/resources/apidoc_test.py @@ -20,47 +20,41 @@ output = args.out_dir + "/api.txt" -sp.check_call( - [ - args.javadoc, - "-doclet", - "org.mozilla.doclet.ApiDoclet", - "-docletpath", - args.doclet_jar, - "-subpackages", - "org.mozilla.test", - "-sourcepath", - args.java_root, - "-root-dir", - args.java_root, - "-skip-class-regex", - "TestSkippedClass$:^org.mozilla.test.TestClass.TestSkippedClass2$", - "-output", - output, - ] -) - -result = sp.call( - [ - "python3", - "../apilint/src/main/resources/diff.py", - "--existing", - args.expected, - "--local", - output, - ] -) - -result_map = sp.call( - [ - "python3", - "../apilint/src/main/resources/diff.py", - "--existing", - args.expected_map, - "--local", - output + ".map", - ] -) +sp.check_call([ + args.javadoc, + "-doclet", + "org.mozilla.doclet.ApiDoclet", + "-docletpath", + args.doclet_jar, + "-subpackages", + "org.mozilla.test", + "-sourcepath", + args.java_root, + "-root-dir", + args.java_root, + "-skip-class-regex", + "TestSkippedClass$:^org.mozilla.test.TestClass.TestSkippedClass2$", + "-output", + output, +]) + +result = sp.call([ + "python3", + "../apilint/src/main/resources/diff.py", + "--existing", + args.expected, + "--local", + output, +]) + +result_map = sp.call([ + "python3", + "../apilint/src/main/resources/diff.py", + "--existing", + args.expected_map, + "--local", + output + ".map", +]) # result == 0 from `diff` means that the files are identical if result != 0 or result_map != 0: diff --git a/mobile/android/gradle/plugins/apilint/apilint/src/main/resources/apilint.py b/mobile/android/gradle/plugins/apilint/apilint/src/main/resources/apilint.py index 3b151ee2689b6..5fe34044959c6 100644 --- a/mobile/android/gradle/plugins/apilint/apilint/src/main/resources/apilint.py +++ b/mobile/android/gradle/plugins/apilint/apilint/src/main/resources/apilint.py @@ -449,9 +449,12 @@ def __init__(self, pkg, location, raw, blame, imports): self.name = self.fullname[self.fullname.rindex(".") + 1 :] def __hash__(self): - return hash( - (self.raw, tuple(self.ctors), tuple(self.fields), tuple(self.methods)) - ) + return hash(( + self.raw, + tuple(self.ctors), + tuple(self.fields), + tuple(self.methods), + )) def __repr__(self): return self.raw diff --git a/mobile/android/gradle/plugins/apilint/apilint/src/main/resources/changelog-check.py b/mobile/android/gradle/plugins/apilint/apilint/src/main/resources/changelog-check.py index 501cfc7231cc1..4fa15ef813042 100644 --- a/mobile/android/gradle/plugins/apilint/apilint/src/main/resources/changelog-check.py +++ b/mobile/android/gradle/plugins/apilint/apilint/src/main/resources/changelog-check.py @@ -73,16 +73,14 @@ def dumpJsonError(info): if args.result_json is None: return if info is not None: - results["failures"].append( - { - "column": info["column"], - "file": args.changelog_file.name, - "line": info["line"], - "msg": info["message"], - "rule": info["rule"], - "error": True, - } - ) + results["failures"].append({ + "column": info["column"], + "file": args.changelog_file.name, + "line": info["line"], + "msg": info["message"], + "rule": info["rule"], + "error": True, + }) args.result_json.seek(0) args.result_json.truncate(0) json.dump(results, args.result_json) @@ -90,16 +88,14 @@ def dumpJsonError(info): try: (lineNumber, expectedApiVersion) = findApiVersion(args.changelog_file) except MissingApiVersionError: - dumpJsonError( - { - "column": 0, - "line": 1, - "message": "The api changelog file does not have a version pin. " - "Please update the file and add the following line: " - f"[api-version]: {currentApiVersion}", - "rule": "missing_api_version", - } - ) + dumpJsonError({ + "column": 0, + "line": 1, + "message": "The api changelog file does not have a version pin. " + "Please update the file and add the following line: " + f"[api-version]: {currentApiVersion}", + "rule": "missing_api_version", + }) print( "ERROR: The api changelog file does not have a version pin. Please update" ) @@ -115,16 +111,14 @@ def dumpJsonError(info): sys.exit(11) if currentApiVersion != expectedApiVersion: - dumpJsonError( - { - "column": 14, - "line": lineNumber, - "message": "The api changelog file is out of date. Please update the " - "file and modify the [api-version] line as follows: " - f"[api-version]: {currentApiVersion}", - "rule": "wrong_api_version", - } - ) + dumpJsonError({ + "column": 14, + "line": lineNumber, + "message": "The api changelog file is out of date. Please update the " + "file and modify the [api-version] line as follows: " + f"[api-version]: {currentApiVersion}", + "rule": "wrong_api_version", + }) print("ERROR: The api changelog file is out of date. Please update the file at") print("") print(args.changelog_file.name) diff --git a/mobile/android/gradle/plugins/apilint/apilint/src/test/resources/apilint_test.py b/mobile/android/gradle/plugins/apilint/apilint/src/test/resources/apilint_test.py index 9b341d54b9186..4ac921bea5357 100644 --- a/mobile/android/gradle/plugins/apilint/apilint/src/test/resources/apilint_test.py +++ b/mobile/android/gradle/plugins/apilint/apilint/src/test/resources/apilint_test.py @@ -37,16 +37,14 @@ after_api = test_base + ".txt" if check_compat: - sp.call( - [ - "python3", - "src/main/resources/diff.py", - "--existing", - before_api, - "--local", - after_api, - ] - ) + sp.call([ + "python3", + "src/main/resources/diff.py", + "--existing", + before_api, + "--local", + after_api, + ]) json_file = "{}/{}-result.json".format(args.build_dir, t["test"]) test = [ diff --git a/mobile/android/mach_commands.py b/mobile/android/mach_commands.py index 020cc8f985994..4244dae4adbcf 100644 --- a/mobile/android/mach_commands.py +++ b/mobile/android/mach_commands.py @@ -569,15 +569,13 @@ def gradle(command_context, args, verbose=False, gradle_path=None, topsrcdir=Non env = os.environ.copy() - env.update( - { - "GRADLE_OPTS": "-Dfile.encoding=utf-8", - "JAVA_HOME": java_home, - "JAVA_TOOL_OPTIONS": "-Dfile.encoding=utf-8", - # Let Gradle get the right Python path on Windows - "GRADLE_MACH_PYTHON": sys.executable, - } - ) + env.update({ + "GRADLE_OPTS": "-Dfile.encoding=utf-8", + "JAVA_HOME": java_home, + "JAVA_TOOL_OPTIONS": "-Dfile.encoding=utf-8", + # Let Gradle get the right Python path on Windows + "GRADLE_MACH_PYTHON": sys.executable, + }) # Set ANDROID_SDK_ROOT if --with-android-sdk was set. # See https://bugzilla.mozilla.org/show_bug.cgi?id=1576471 android_sdk_root = command_context.substs.get("ANDROID_SDK_ROOT", "") diff --git a/modules/libpref/init/generate_static_pref_list.py b/modules/libpref/init/generate_static_pref_list.py index 06ac40372abec..d86607389faab 100644 --- a/modules/libpref/init/generate_static_pref_list.py +++ b/modules/libpref/init/generate_static_pref_list.py @@ -34,23 +34,21 @@ } VALID_TYPES = VALID_BOOL_TYPES.copy() -VALID_TYPES.update( - { - "int32_t": "int32_t", - "uint32_t": "uint32_t", - "float": "float", - # These ones are defined in StaticPrefsBase.h. - "RelaxedAtomicInt32": "int32_t", - "RelaxedAtomicUint32": "uint32_t", - "ReleaseAcquireAtomicInt32": "int32_t", - "ReleaseAcquireAtomicUint32": "uint32_t", - "SequentiallyConsistentAtomicInt32": "int32_t", - "SequentiallyConsistentAtomicUint32": "uint32_t", - "AtomicFloat": "float", - "String": None, - "DataMutexString": "nsACString", - } -) +VALID_TYPES.update({ + "int32_t": "int32_t", + "uint32_t": "uint32_t", + "float": "float", + # These ones are defined in StaticPrefsBase.h. + "RelaxedAtomicInt32": "int32_t", + "RelaxedAtomicUint32": "uint32_t", + "ReleaseAcquireAtomicInt32": "int32_t", + "ReleaseAcquireAtomicUint32": "uint32_t", + "SequentiallyConsistentAtomicInt32": "int32_t", + "SequentiallyConsistentAtomicUint32": "uint32_t", + "AtomicFloat": "float", + "String": None, + "DataMutexString": "nsACString", +}) # Map non-atomic C++ types to equivalent Rust types. RUST_TYPES = { diff --git a/modules/libpref/test/test_generate_static_pref_list.py b/modules/libpref/test/test_generate_static_pref_list.py index 503572e43d9a6..0062c0b049f63 100644 --- a/modules/libpref/test/test_generate_static_pref_list.py +++ b/modules/libpref/test/test_generate_static_pref_list.py @@ -108,18 +108,14 @@ # The corresponding code for good_input. good = {} -good[ - "static_pref_list_all_h" -] = """\ +good["static_pref_list_all_h"] = """\ // This file was generated by generate_static_pref_list.py from (string input). DO NOT EDIT. #include "mozilla/StaticPrefList_my.h" #include "mozilla/StaticPrefList_my_dashed.h" """ -good[ - "static_prefs_all_h" -] = """\ +good["static_prefs_all_h"] = """\ // This file was generated by generate_static_pref_list.py from (string input). DO NOT EDIT. #include "mozilla/StaticPrefs_my.h" @@ -217,9 +213,7 @@ """ } -good[ - "static_prefs_c_getters_cpp" -] = """\ +good["static_prefs_c_getters_cpp"] = """\ // This file was generated by generate_static_pref_list.py from (string input). DO NOT EDIT. extern "C" uint32_t StaticPrefs_my_uint() { @@ -240,9 +234,7 @@ } """ -good[ - "static_prefs_rs" -] = """\ +good["static_prefs_rs"] = """\ // This file was generated by generate_static_pref_list.py from (string input). DO NOT EDIT. pub use nsstring::nsCString; diff --git a/moz.configure b/moz.configure index 2babb391317ad..e7f32df5db54f 100755 --- a/moz.configure +++ b/moz.configure @@ -131,8 +131,7 @@ set_define("FMT_USE_LOCALE", 0) option( "--enable-debug", nargs="?", - help="Enable building with developer debug info " - "(using the given compiler flags)", + help="Enable building with developer debug info (using the given compiler flags)", ) diff --git a/mozglue/baseprofiler/build/generate_profiling_categories.py b/mozglue/baseprofiler/build/generate_profiling_categories.py index 2d1fc6d6481d2..19c4c9e74b31e 100644 --- a/mozglue/baseprofiler/build/generate_profiling_categories.py +++ b/mozglue/baseprofiler/build/generate_profiling_categories.py @@ -145,9 +145,9 @@ def generate_macro_header(c_out, yaml_path): color = category["color"] assert isinstance(color, str) subcategories = category.get("subcategories", None) - assert ( - isinstance(subcategories, list) and len(subcategories) > 0 - ), f"At least one subcategory expected as default in {name}." + assert isinstance(subcategories, list) and len(subcategories) > 0, ( + f"At least one subcategory expected as default in {name}." + ) category_items.append( generate_category_macro(name, label, color, subcategories) @@ -270,9 +270,9 @@ def generate_rust_enums(c_out, yaml_path): # This will be used as our main enum field and sub category enum. cat_label = "".join(filter(str.isalnum, cat_label)) cat_subcategories = category.get("subcategories", None) - assert ( - isinstance(cat_subcategories, list) and len(cat_subcategories) > 0 - ), f"At least one subcategory expected as default in {cat_name}." + assert isinstance(cat_subcategories, list) and len(cat_subcategories) > 0, ( + f"At least one subcategory expected as default in {cat_name}." + ) # Create a new enum for this sub category and append it to the enums list. category_enum = RustEnum(cat_label) @@ -300,9 +300,9 @@ def generate_rust_enums(c_out, yaml_path): ) profiling_category_pair_value += 1 - assert ( - category_enum.default_category is not None - ), "There must be a default subcategory with the same name." + assert category_enum.default_category is not None, ( + "There must be a default subcategory with the same name." + ) # Append the main enums. profiling_category_pair_enum.append_optional_tuple_field(cat_label) diff --git a/netwerk/test/marionette/test_purge_http_cache_at_shutdown.py b/netwerk/test/marionette/test_purge_http_cache_at_shutdown.py index f138264b29e20..225eef90043b5 100644 --- a/netwerk/test/marionette/test_purge_http_cache_at_shutdown.py +++ b/netwerk/test/marionette/test_purge_http_cache_at_shutdown.py @@ -12,13 +12,11 @@ class PurgeHTTPCacheAtShutdownTestCase(MarionetteTestCase): def setUp(self): super().setUp() - self.marionette.enforce_gecko_prefs( - { - "privacy.sanitize.sanitizeOnShutdown": True, - "privacy.clearOnShutdown.cache": True, - "network.cache.shutdown_purge_in_background_task": True, - } - ) + self.marionette.enforce_gecko_prefs({ + "privacy.sanitize.sanitizeOnShutdown": True, + "privacy.clearOnShutdown.cache": True, + "network.cache.shutdown_purge_in_background_task": True, + }) self.profile_path = Path(self.marionette.profile_path) self.cache_path = self.profile_path.joinpath("cache2") diff --git a/netwerk/test/perf/hooks_throttling.py b/netwerk/test/perf/hooks_throttling.py index 5f46b3f0d35d3..2bfab52383c49 100644 --- a/netwerk/test/perf/hooks_throttling.py +++ b/netwerk/test/perf/hooks_throttling.py @@ -5,6 +5,7 @@ Drives the throttling feature when the test calls our controlled server. """ + import http.client import json import os diff --git a/python/mach/mach/commands/commandinfo.py b/python/mach/mach/commands/commandinfo.py index a3d6701db2413..e6b554dcb13d5 100644 --- a/python/mach/mach/commands/commandinfo.py +++ b/python/mach/mach/commands/commandinfo.py @@ -203,9 +203,9 @@ def run_completion(command_context, args): def _zsh_describe(value, description=None): value = '"' + value.replace(":", "\\:") if description: - description = subprocess.list2cmdline( - [re.sub(r'(["\'#&;`|*?~<>^()\[\]{}$\\\x0A\xFF])', r"\\\1", description)] - ).lstrip('"') + description = subprocess.list2cmdline([ + re.sub(r'(["\'#&;`|*?~<>^()\[\]{}$\\\x0A\xFF])', r"\\\1", description) + ]).lstrip('"') if description.endswith('"') and not description.endswith(r"\""): description = description[:-1] @@ -247,14 +247,12 @@ def completion_bash(command_context, outfile): if options: case_options.append( - "\n".join( - [ - f" ({cmd.name})", - ' opts="${{opts}} {}"'.format(" ".join(options)), - " ;;", - "", - ] - ) + "\n".join([ + f" ({cmd.name})", + ' opts="${{opts}} {}"'.format(" ".join(options)), + " ;;", + "", + ]) ) # Build case statement for subcommand options. @@ -266,14 +264,12 @@ def completion_bash(command_context, outfile): if options: case_options.append( - "\n".join( - [ - f' ("{sub.name} {sub.subcommand}")', - ' opts="${{opts}} {}"'.format(" ".join(options)), - " ;;", - "", - ] - ) + "\n".join([ + f' ("{sub.name} {sub.subcommand}")', + ' opts="${{opts}} {}"'.format(" ".join(options)), + " ;;", + "", + ]) ) # Build case statement for subcommands. @@ -281,25 +277,21 @@ def completion_bash(command_context, outfile): if subcommands: comsubs = " ".join([h.subcommand for h in cmd.subcommands]) case_commands_subcommands.append( - "\n".join( - [ - f" ({cmd.name})", - f' comsubs=" {comsubs} "', - " ;;", - "", - ] - ) + "\n".join([ + f" ({cmd.name})", + f' comsubs=" {comsubs} "', + " ;;", + "", + ]) ) case_subcommands.append( - "\n".join( - [ - f" ({cmd.name})", - ' subs="${{subs}} {}"'.format(" ".join(subcommands)), - " ;;", - "", - ] - ) + "\n".join([ + f" ({cmd.name})", + ' subs="${{subs}} {}"'.format(" ".join(subcommands)), + " ;;", + "", + ]) ) globalopts = [ @@ -345,14 +337,12 @@ def completion_zsh(command_context, outfile): if options: case_options.append( - "\n".join( - [ - f" ({cmd.name})", - " opts+=({})".format(" ".join(options)), - " ;;", - "", - ] - ) + "\n".join([ + f" ({cmd.name})", + " opts+=({})".format(" ".join(options)), + " ;;", + "", + ]) ) # Build case statement for subcommand options. @@ -364,14 +354,12 @@ def completion_zsh(command_context, outfile): if options: case_options.append( - "\n".join( - [ - f" ({sub.name} {sub.subcommand})", - " opts+=({})".format(" ".join(options)), - " ;;", - "", - ] - ) + "\n".join([ + f" ({sub.name} {sub.subcommand})", + " opts+=({})".format(" ".join(options)), + " ;;", + "", + ]) ) # Build case statement for subcommands. @@ -386,14 +374,12 @@ def completion_zsh(command_context, outfile): ) case_subcommands.append( - "\n".join( - [ - f" ({cmd.name})", - " subs+=({})".format(" ".join(subcommands)), - " ;;", - "", - ] - ) + "\n".join([ + f" ({cmd.name})", + " subs+=({})".format(" ".join(subcommands)), + " ;;", + "", + ]) ) globalopts = [] @@ -436,9 +422,8 @@ def _append_opt_strs(comp, opt_strs): globalopts = [] for opt_strs, description in global_options(command_context).items(): - comp = ( - "complete -c mach -n '__fish_mach_complete_no_command' " - "-d '{}'".format(description.replace("'", "\\'")) + comp = "complete -c mach -n '__fish_mach_complete_no_command' -d '{}'".format( + description.replace("'", "\\'") ) comp = _append_opt_strs(comp, opt_strs) globalopts.append(comp) diff --git a/python/mach/mach/decorators.py b/python/mach/mach/decorators.py index 9d9c229c13c97..d0dedd6cf704b 100644 --- a/python/mach/mach/decorators.py +++ b/python/mach/mach/decorators.py @@ -76,7 +76,7 @@ def __init__( self.hidden = hidden if ok_if_tests_disabled and category != "testing": raise ValueError( - "ok_if_tests_disabled should only be set for " "`testing` mach commands" + "ok_if_tests_disabled should only be set for `testing` mach commands" ) self.ok_if_tests_disabled = ok_if_tests_disabled diff --git a/python/mach/mach/dispatcher.py b/python/mach/mach/dispatcher.py index 54b0f9494f17e..0dfdff7952240 100644 --- a/python/mach/mach/dispatcher.py +++ b/python/mach/mach/dispatcher.py @@ -145,9 +145,10 @@ def __call__(self, parser, namespace, values, option_string=None): # If there are sub-commands, parse the intent out immediately. if handler.subcommand_handlers and args: # mach help - if set(args[: args.index("--")] if "--" in args else args).intersection( - ("help", "--help") - ): + if set(args[: args.index("--")] if "--" in args else args).intersection(( + "help", + "--help", + )): self._handle_subcommand_help(parser, handler, args) sys.exit(0) # mach ... diff --git a/python/mach/mach/main.py b/python/mach/mach/main.py index 9275def859b88..82a8f19ef5859 100644 --- a/python/mach/mach/main.py +++ b/python/mach/mach/main.py @@ -528,7 +528,7 @@ def get_argument_parser(context=None, action=CommandAction, topsrcdir=None): parser = ArgumentParser( add_help=False, - usage="%(prog)s [global arguments] " "command [command arguments]", + usage="%(prog)s [global arguments] command [command arguments]", ) # WARNING!!! If you add a global argument here, also add it to the diff --git a/python/mach/mach/registrar.py b/python/mach/mach/registrar.py index 20f9f4dd1d428..5dc6be33666ae 100644 --- a/python/mach/mach/registrar.py +++ b/python/mach/mach/registrar.py @@ -33,7 +33,7 @@ def register_command_handler(self, handler): if not handler.category: raise MachError( - "Cannot register a mach command without a " "category: %s" % name + "Cannot register a mach command without a category: %s" % name ) if handler.category not in self.categories: diff --git a/python/mach/mach/sentry.py b/python/mach/mach/sentry.py index b1a2513596c5b..0b59877df9baa 100644 --- a/python/mach/mach/sentry.py +++ b/python/mach/mach/sentry.py @@ -214,9 +214,9 @@ def _is_unmodified_mach_core(topsrcdir: Path): repo = _get_repository_object(topsrcdir) try: files = set(repo.get_outgoing_files()) | set(repo.get_changed_files()) - _is_unmodified_mach_core_result = not any( - [file for file in files if file == "mach" or file.endswith(".py")] - ) + _is_unmodified_mach_core_result = not any([ + file for file in files if file == "mach" or file.endswith(".py") + ]) except MissingUpstreamRepo: # If we don't know the upstream state, we don't know if the mach files # have been unmodified. diff --git a/python/mach/mach/site.py b/python/mach/mach/site.py index 99b3fc2634c36..32c0c0d0e9bf1 100644 --- a/python/mach/mach/site.py +++ b/python/mach/mach/site.py @@ -342,9 +342,9 @@ def from_environment( # yet, and the system isn't guaranteed to have the packages we need. For example, # "./mach bootstrap" can't have any dependencies. # So, all external dependencies of Mach's must be optional. - assert ( - not requirements.pypi_requirements - ), "Mach pip package requirements must be optional." + assert not requirements.pypi_requirements, ( + "Mach pip package requirements must be optional." + ) # external_python is the Python interpreter that invoked Mach for this process. external_python = ExternalPythonSite(sys.executable) @@ -607,9 +607,9 @@ def from_environment( should be created """ active_metadata = MozSiteMetadata.from_runtime() - assert ( - active_metadata - ), "A Mach-managed site must be active before doing work with command sites" + assert active_metadata, ( + "A Mach-managed site must be active before doing work with command sites" + ) mach_site_packages_source = active_metadata.mach_site_packages_source pip_restricted_site = site_name in PIP_NETWORK_INSTALL_RESTRICTED_VIRTUALENVS @@ -1044,12 +1044,10 @@ def pip_install_with_constraints(self, pip_args): constraints_path = os.path.join(tempdir, "site-constraints.txt") with open(constraints_path, "w") as file: file.write( - "\n".join( - [ - f"{name}=={version}" - for name, version in existing_packages.items() - ] - ) + "\n".join([ + f"{name}=={version}" + for name, version in existing_packages.items() + ]) ) self.pip_install(["--constraint", constraints_path] + pip_args) @@ -1536,9 +1534,11 @@ def _create_venv_with_pthfile( if populate_with_pip: for requirements_txt_file in requirements.requirements_txt_files: - target_venv.pip_install( - ["--requirement", requirements_txt_file.path, "--require-hashes"] - ) + target_venv.pip_install([ + "--requirement", + requirements_txt_file.path, + "--require-hashes", + ]) if requirements.pypi_requirements: requirements_list = [ str(req.requirement) for req in requirements.pypi_requirements diff --git a/python/mach/mach/test/script_site_activation.py b/python/mach/mach/test/script_site_activation.py index 8c23f1a19c92d..5e4278b7d36b4 100644 --- a/python/mach/mach/test/script_site_activation.py +++ b/python/mach/mach/test/script_site_activation.py @@ -54,13 +54,11 @@ def resolve_requirements(topsrcdir, site_name): ) command_site.activate() command_sys_path = sys.path.copy() - print( - [ - initial_sys_path, - mach_sys_path, - command_sys_path, - ] - ) + print([ + initial_sys_path, + mach_sys_path, + command_sys_path, + ]) if __name__ == "__main__": diff --git a/python/mach/mach/test/test_site.py b/python/mach/mach/test/test_site.py index 0e155dd321e07..2562ce379b252 100644 --- a/python/mach/mach/test/test_site.py +++ b/python/mach/mach/test/test_site.py @@ -142,9 +142,9 @@ def test_requirements_txt_install_requires_hashes( pytest.fail("Expected CalledProcessError to be raised due to missing hashes") except subprocess.CalledProcessError as e: error_output = e.stderr if e.stderr else "" - assert ( - "hash" in error_output.lower() - ), f"Expected hash error in stderr, got: {error_output}" + assert "hash" in error_output.lower(), ( + f"Expected hash error in stderr, got: {error_output}" + ) def test_requirements_txt_installs_with_hashes(run_create_venv_with_pthfile): diff --git a/python/mach/mach/test/test_site_activation.py b/python/mach/mach/test/test_site_activation.py index 5dd79d7dbc540..8e82436ed9759 100644 --- a/python/mach/mach/test/test_site_activation.py +++ b/python/mach/mach/test/test_site_activation.py @@ -63,14 +63,12 @@ def test_new_package_metadta_is_found(): pass with tempfile.TemporaryDirectory() as venv_dir: - subprocess.check_call( - [ - sys.executable, - "-m", - "venv", - venv_dir, - ] - ) + subprocess.check_call([ + sys.executable, + "-m", + "venv", + venv_dir, + ]) venv = PythonVirtualenv(venv_dir) venv.pip_install([f"{pkg}=={version}"]) diff --git a/python/mach/mach/util.py b/python/mach/mach/util.py index 6069219ba5161..f7f023567579c 100644 --- a/python/mach/mach/util.py +++ b/python/mach/mach/util.py @@ -121,4 +121,4 @@ def strtobool(value: str): if value in false_vals: return 0 - raise ValueError(f'Expected one of: {", ".join(true_vals + false_vals)}') + raise ValueError(f"Expected one of: {', '.join(true_vals + false_vals)}") diff --git a/python/mozboot/bin/bootstrap.py b/python/mozboot/bin/bootstrap.py index 84c25f92d92f3..6be38685493e9 100755 --- a/python/mozboot/bin/bootstrap.py +++ b/python/mozboot/bin/bootstrap.py @@ -444,7 +444,7 @@ def main(args): "--no-system-changes", dest="no_system_changes", action="store_true", - help="Only executes actions that leave the system " "configuration alone.", + help="Only executes actions that leave the system configuration alone.", ) options, leftover = parser.parse_args(args) diff --git a/python/mozboot/mozboot/base.py b/python/mozboot/mozboot/base.py index 323ab83c50049..1456bfdaa3529 100644 --- a/python/mozboot/mozboot/base.py +++ b/python/mozboot/mozboot/base.py @@ -667,18 +667,16 @@ def install_rust(self): rustup_init.chmod(mode | stat.S_IRWXU) print("Ok") print("Running rustup-init...") - subprocess.check_call( - [ - str(rustup_init), - "-y", - "--default-toolchain", - "stable", - "--default-host", - platform, - "--component", - "rustfmt", - ] - ) + subprocess.check_call([ + str(rustup_init), + "-y", + "--default-toolchain", + "stable", + "--default-host", + platform, + "--component", + "rustfmt", + ]) cargo_home, cargo_bin = self.cargo_home() self.print_rust_path_advice(RUST_INSTALL_COMPLETE, cargo_home, cargo_bin) finally: diff --git a/python/mozboot/mozboot/bootstrap.py b/python/mozboot/mozboot/bootstrap.py index 04e6a51a78a81..0036e37753efe 100644 --- a/python/mozboot/mozboot/bootstrap.py +++ b/python/mozboot/mozboot/bootstrap.py @@ -58,15 +58,13 @@ %s Your choice: """ -APPLICATIONS = OrderedDict( - [ - ("Firefox for Desktop Artifact Mode", "browser_artifact_mode"), - ("Firefox for Desktop", "browser"), - ("GeckoView/Firefox for Android Artifact Mode", "mobile_android_artifact_mode"), - ("GeckoView/Firefox for Android", "mobile_android"), - ("SpiderMonkey JavaScript engine", "js"), - ] -) +APPLICATIONS = OrderedDict([ + ("Firefox for Desktop Artifact Mode", "browser_artifact_mode"), + ("Firefox for Desktop", "browser"), + ("GeckoView/Firefox for Android Artifact Mode", "mobile_android_artifact_mode"), + ("GeckoView/Firefox for Android", "mobile_android"), + ("SpiderMonkey JavaScript engine", "js"), +]) FINISHED = """ Your system should be ready to build %s! @@ -320,7 +318,7 @@ def __init__( cls = WindowsBootstrapper if cls is None: raise NotImplementedError( - "Bootstrap support is not yet available " "for your OS." + "Bootstrap support is not yet available for your OS." ) self.instance = cls(**args) @@ -718,12 +716,10 @@ def current_firefox_checkout(env, hg: Optional[Path] = None): Returns one of None, ``git``, or ``hg``. """ - HG_ROOT_REVISIONS = set( - [ - # From mozilla-unified. - "8ba995b74e18334ab3707f27e9eb8f4e37ba3d29" - ] - ) + HG_ROOT_REVISIONS = set([ + # From mozilla-unified. + "8ba995b74e18334ab3707f27e9eb8f4e37ba3d29" + ]) path = Path.cwd() while path: diff --git a/python/mozboot/mozboot/linux_common.py b/python/mozboot/mozboot/linux_common.py index 3a21ce3ae1858..6bdb40aa5075b 100644 --- a/python/mozboot/mozboot/linux_common.py +++ b/python/mozboot/mozboot/linux_common.py @@ -56,17 +56,15 @@ def ensure_sccache_packages(self): pass def install_system_packages(self): - self.install_packages( - [ - "bash", - "findutils", # contains xargs - "gzip", - "make", - "perl", - "tar", - "unzip", - ] - ) + self.install_packages([ + "bash", + "findutils", # contains xargs + "gzip", + "make", + "perl", + "tar", + "unzip", + ]) # Optional packages try: self.install_packages(["watchman"]) diff --git a/python/mozboot/mozboot/mozconfig.py b/python/mozboot/mozboot/mozconfig.py index c6fedb049b52d..07d0f5361d5cb 100644 --- a/python/mozboot/mozboot/mozconfig.py +++ b/python/mozboot/mozboot/mozconfig.py @@ -117,7 +117,7 @@ def find_mozconfig(topsrcdir: Union[str, Path], env=os.environ): if not env_path.is_file(): raise MozconfigFindException( - "MOZCONFIG environment variable refers to a " f"non-file: {env_path}" + f"MOZCONFIG environment variable refers to a non-file: {env_path}" ) srcdir_paths = [topsrcdir / p for p in DEFAULT_TOPSRCDIR_PATHS] diff --git a/python/mozboot/mozboot/osx.py b/python/mozboot/mozboot/osx.py index 92f00098a2cc5..77fb4d2e5b121 100644 --- a/python/mozboot/mozboot/osx.py +++ b/python/mozboot/mozboot/osx.py @@ -215,18 +215,22 @@ def _ensure_homebrew_casks(self, casks): # Ensure that we can access old versions of packages. if b"homebrew/cask-versions" not in known_taps: - subprocess.check_output( - [to_optional_str(self.brew), "tap", "homebrew/cask-versions"] - ) + subprocess.check_output([ + to_optional_str(self.brew), + "tap", + "homebrew/cask-versions", + ]) # "caskroom/versions" has been renamed to "homebrew/cask-versions", so # it is safe to remove the old tap. Removing the old tap is necessary # to avoid the error "Cask [name of cask] exists in multiple taps". # See https://bugzilla.mozilla.org/show_bug.cgi?id=1544981 if b"caskroom/versions" in known_taps: - subprocess.check_output( - [to_optional_str(self.brew), "untap", "caskroom/versions"] - ) + subprocess.check_output([ + to_optional_str(self.brew), + "untap", + "caskroom/versions", + ]) self._ensure_homebrew_packages(casks, is_for_cask=True) diff --git a/python/mozbuild/mozbuild/action/check_binary.py b/python/mozbuild/mozbuild/action/check_binary.py index a58f8420b4948..86e5b5cde159f 100644 --- a/python/mozbuild/mozbuild/action/check_binary.py +++ b/python/mozbuild/mozbuild/action/check_binary.py @@ -208,43 +208,39 @@ def check_mozglue_order(binary): def check_networking(binary): retcode = 0 - networking_functions = set( - [ - # socketpair is not concerning; it is restricted to AF_UNIX - "recv", - "send", - # We would be concerned by recvmsg and sendmsg; but we believe - # they are okay as documented in 1376621#c23 - "gethostbyname", - "gethostbyaddr", - "gethostent", - "sethostent", - "endhostent", - "gethostent_r", - "gethostbyname2", - "gethostbyaddr_r", - "gethostbyname_r", - "gethostbyname2_r", - "getservent", - "getservbyname", - "getservbyport", - "setservent", - "getprotoent", - "getprotobyname", - "getprotobynumber", - "setprotoent", - "endprotoent", - ] - ) + networking_functions = set([ + # socketpair is not concerning; it is restricted to AF_UNIX + "recv", + "send", + # We would be concerned by recvmsg and sendmsg; but we believe + # they are okay as documented in 1376621#c23 + "gethostbyname", + "gethostbyaddr", + "gethostent", + "sethostent", + "endhostent", + "gethostent_r", + "gethostbyname2", + "gethostbyaddr_r", + "gethostbyname_r", + "gethostbyname2_r", + "getservent", + "getservbyname", + "getservbyport", + "setservent", + "getprotoent", + "getprotobyname", + "getprotobynumber", + "setprotoent", + "endprotoent", + ]) # These are used by the crash monitor & crash monitor client to talk with # the main process on Linux and macOS. - socket_functions = set( - [ - "connect", - "accept", - "listen", - ] - ) + socket_functions = set([ + "connect", + "accept", + "listen", + ]) if PLATFORM == "WINNT": networking_functions |= socket_functions diff --git a/python/mozbuild/mozbuild/action/exe_7z_archive.py b/python/mozbuild/mozbuild/action/exe_7z_archive.py index b0d35be2bf88e..9c358022fcac8 100644 --- a/python/mozbuild/mozbuild/action/exe_7z_archive.py +++ b/python/mozbuild/mozbuild/action/exe_7z_archive.py @@ -45,23 +45,21 @@ def archive_exe(pkg_dir, tagfile, sfx_package, package, use_upx): except BuildEnvironmentNotFoundException: # configure hasn't been run, just use the default sevenz = "7z" - subprocess.check_call( - [ - sevenz, - "a", - "-r", - "-t7z", - mozpath.join(tmpdir, "app.7z"), - "-mx", - "-m0=BCJ2", - "-m1=LZMA:d25", - "-m2=LZMA:d19", - "-m3=LZMA:d19", - "-mb0:1", - "-mb0s1:2", - "-mb0s2:3", - ] - ) + subprocess.check_call([ + sevenz, + "a", + "-r", + "-t7z", + mozpath.join(tmpdir, "app.7z"), + "-mx", + "-m0=BCJ2", + "-m1=LZMA:d25", + "-m2=LZMA:d19", + "-m3=LZMA:d19", + "-mb0:1", + "-mb0s1:2", + "-mb0s2:3", + ]) with open(package, "wb") as o: for i in [final_sfx, tagfile, mozpath.join(tmpdir, "app.7z")]: diff --git a/python/mozbuild/mozbuild/action/fat_aar.py b/python/mozbuild/mozbuild/action/fat_aar.py index be791f75f5160..520365bb5f8bb 100644 --- a/python/mozbuild/mozbuild/action/fat_aar.py +++ b/python/mozbuild/mozbuild/action/fat_aar.py @@ -34,21 +34,19 @@ def _download_zip(distdir, arch): } dest = mozpath.join(distdir, "input", arch) - subprocess.check_call( - [ - sys.executable, - mozpath.join(buildconfig.topsrcdir, "mach"), - "artifact", - "install", - "--job", - jobs[arch], - "--distdir", - dest, - "--no-tests", - "--no-process", - "--maven-zip", - ] - ) + subprocess.check_call([ + sys.executable, + mozpath.join(buildconfig.topsrcdir, "mach"), + "artifact", + "install", + "--job", + jobs[arch], + "--distdir", + dest, + "--no-tests", + "--no-process", + "--maven-zip", + ]) return mozpath.join(dest, "target.maven.zip") diff --git a/python/mozbuild/mozbuild/action/langpack_manifest.py b/python/mozbuild/mozbuild/action/langpack_manifest.py index 7182cb495bb48..28f6244656b6b 100644 --- a/python/mozbuild/mozbuild/action/langpack_manifest.py +++ b/python/mozbuild/mozbuild/action/langpack_manifest.py @@ -64,13 +64,13 @@ def get_build_date(): ### def get_dt_from_hg(path): with mozversioncontrol.get_repository_object(path=path) as repo: - phase = repo._run("log", "-r", ".", "-T" "{phase}") + phase = repo._run("log", "-r", ".", "-T{phase}") if phase.strip() != "public": return get_build_date() repo_url = repo._run("paths", "default") repo_url = repo_url.strip().replace("ssh://", "https://") repo_url = repo_url.replace("hg://", "https://") - cs = repo._run("log", "-r", ".", "-T" "{node}") + cs = repo._run("log", "-r", ".", "-T{node}") url = pushlog_api_url.format(repo_url, cs) session = requests.Session() @@ -354,15 +354,13 @@ def parse_chrome_manifest(path, base_path, chrome_entries): entry_path = os.path.join( os.path.relpath(os.path.dirname(path), base_path), entry.relpath ) - chrome_entries.append( - { - "type": "locale", - "alias": entry.name, - "locale": entry.id, - "platforms": convert_entry_flags_to_platform_codes(entry.flags), - "path": mozpath.normsep(entry_path), - } - ) + chrome_entries.append({ + "type": "locale", + "alias": entry.name, + "locale": entry.id, + "platforms": convert_entry_flags_to_platform_codes(entry.flags), + "path": mozpath.normsep(entry_path), + }) else: raise Exception(f"Unknown type {entry.name}") diff --git a/python/mozbuild/mozbuild/action/test_archive.py b/python/mozbuild/mozbuild/action/test_archive.py index 41256b572fae3..b81c6076ab68b 100644 --- a/python/mozbuild/mozbuild/action/test_archive.py +++ b/python/mozbuild/mozbuild/action/test_archive.py @@ -709,13 +709,11 @@ } if buildconfig.substs.get("MOZ_CODE_COVERAGE"): - ARCHIVE_FILES["common"].append( - { - "source": buildconfig.topsrcdir, - "base": "python/mozbuild/", - "patterns": ["mozpack/**", "mozbuild/codecoverage/**"], - } - ) + ARCHIVE_FILES["common"].append({ + "source": buildconfig.topsrcdir, + "base": "python/mozbuild/", + "patterns": ["mozpack/**", "mozbuild/codecoverage/**"], + }) if ( diff --git a/python/mozbuild/mozbuild/action/zip.py b/python/mozbuild/mozbuild/action/zip.py index 8b9d2e4dafb8f..b527d9b8f8590 100644 --- a/python/mozbuild/mozbuild/action/zip.py +++ b/python/mozbuild/mozbuild/action/zip.py @@ -25,7 +25,7 @@ def main(args): "-C", metavar="DIR", default=".", - help="Change to given directory before considering " "other paths", + help="Change to given directory before considering other paths", ) parser.add_argument("--strip", action="store_true", help="Strip executables") parser.add_argument( diff --git a/python/mozbuild/mozbuild/android_version_code.py b/python/mozbuild/mozbuild/android_version_code.py index 3b4025bec7586..443329d0f22e4 100644 --- a/python/mozbuild/mozbuild/android_version_code.py +++ b/python/mozbuild/mozbuild/android_version_code.py @@ -27,8 +27,7 @@ def android_version_code_v0(buildid, cpu_arch=None, min_sdk=0, max_sdk=0): return base + min_sdk + 3 else: raise ValueError( - "Don't know how to compute android:versionCode " - "for CPU arch %s" % cpu_arch + "Don't know how to compute android:versionCode for CPU arch %s" % cpu_arch ) @@ -129,8 +128,7 @@ def hours_since_cutoff(buildid): pass else: raise ValueError( - "Don't know how to compute android:versionCode " - "for CPU arch %s" % cpu_arch + "Don't know how to compute android:versionCode for CPU arch %s" % cpu_arch ) # 'p' bit is 1 for 64-bit architectures. @@ -140,8 +138,7 @@ def hours_since_cutoff(buildid): pass else: raise ValueError( - "Don't know how to compute android:versionCode " - "for CPU arch %s" % cpu_arch + "Don't know how to compute android:versionCode for CPU arch %s" % cpu_arch ) # 'g' bit is currently always 1, but may depend on `min_sdk` in the future. diff --git a/python/mozbuild/mozbuild/artifact_cache.py b/python/mozbuild/mozbuild/artifact_cache.py index 0c1e567a28ae3..f6ba037641e1c 100644 --- a/python/mozbuild/mozbuild/artifact_cache.py +++ b/python/mozbuild/mozbuild/artifact_cache.py @@ -20,7 +20,6 @@ A future need, perhaps. """ - import binascii import hashlib import logging diff --git a/python/mozbuild/mozbuild/artifacts.py b/python/mozbuild/mozbuild/artifacts.py index a5036a589935c..c4ab5eacf0548 100644 --- a/python/mozbuild/mozbuild/artifacts.py +++ b/python/mozbuild/mozbuild/artifacts.py @@ -31,7 +31,6 @@ consumers will need to arrange this themselves. """ - import collections import functools import glob @@ -277,8 +276,7 @@ def find_candidate_artifacts(self, artifacts): ) if self._tests_re and not tests_artifact: raise ValueError( - f'Expected tests archive matching "{self._tests_re}", but ' - "found none!" + f'Expected tests archive matching "{self._tests_re}", but found none!' ) if self._maven_zip_re and not maven_zip_artifact: raise ValueError( @@ -746,15 +744,13 @@ class MacArtifactJob(ArtifactJob): @property def _extra_archives(self): extra_archives = super()._extra_archives - extra_archives.update( - { - ".update_framework_artifacts.zip": { - "description": "Update-related macOS Framework Artifacts", - "src_prefix": "", - "dest_prefix": "update_framework_artifacts", - }, - } - ) + extra_archives.update({ + ".update_framework_artifacts.zip": { + "description": "Update-related macOS Framework Artifacts", + "src_prefix": "", + "dest_prefix": "update_framework_artifacts", + }, + }) return extra_archives @property @@ -919,12 +915,10 @@ class UnfilteredProjectPackageArtifactJob(ArtifactJob): """ # Can't yet handle `AndroidArtifactJob` uniformly, since the `product` is "mobile". - package_re = "|".join( - [ - f"({cls.package_re})" - for cls in (LinuxArtifactJob, MacArtifactJob, WinArtifactJob) - ] - ) + package_re = "|".join([ + f"({cls.package_re})" + for cls in (LinuxArtifactJob, MacArtifactJob, WinArtifactJob) + ]) job_configuration = GeckoJobConfiguration @property diff --git a/python/mozbuild/mozbuild/backend/base.py b/python/mozbuild/mozbuild/backend/base.py index 286f6500b04a5..0d376af4fff8e 100644 --- a/python/mozbuild/mozbuild/backend/base.py +++ b/python/mozbuild/mozbuild/backend/base.py @@ -305,12 +305,10 @@ def _get_preprocessor(self, obj): in the current environment.""" pp = Preprocessor() srcdir = mozpath.dirname(obj.input_path) - pp.context.update( - { - k: " ".join(v) if isinstance(v, list) else v - for k, v in obj.config.substs.items() - } - ) + pp.context.update({ + k: " ".join(v) if isinstance(v, list) else v + for k, v in obj.config.substs.items() + }) pp.context.update( top_srcdir=obj.topsrcdir, topobjdir=obj.topobjdir, diff --git a/python/mozbuild/mozbuild/backend/common.py b/python/mozbuild/mozbuild/backend/common.py index 214955c506375..aa875a5685943 100644 --- a/python/mozbuild/mozbuild/backend/common.py +++ b/python/mozbuild/mozbuild/backend/common.py @@ -162,9 +162,9 @@ def consume_object(self, obj): return False elif isinstance(obj, SandboxedWasmLibrary): - self._handle_generated_sources( - [mozpath.join(obj.relobjdir, f"{obj.basename}.h")] - ) + self._handle_generated_sources([ + mozpath.join(obj.relobjdir, f"{obj.basename}.h") + ]) return False elif isinstance(obj, (Sources, HostSources)): @@ -203,9 +203,9 @@ def consume_object(self, obj): for f in files: basename = FinalTargetPreprocessedFiles.get_obj_basename(f) relpath = mozpath.join(obj.install_target, path, basename) - self._handle_generated_sources( - [ObjDirPath(obj._context, "!/" + relpath).full_path] - ) + self._handle_generated_sources([ + ObjDirPath(obj._context, "!/" + relpath).full_path + ]) return False else: diff --git a/python/mozbuild/mozbuild/backend/configenvironment.py b/python/mozbuild/mozbuild/backend/configenvironment.py index 0e5ef3530c4b3..dda5b5e1ff65e 100644 --- a/python/mozbuild/mozbuild/backend/configenvironment.py +++ b/python/mozbuild/mozbuild/backend/configenvironment.py @@ -150,12 +150,10 @@ def __init__( self.bin_suffix = self.substs.get("BIN_SUFFIX", "") global_defines = [name for name in self.defines] - self.substs["ACDEFINES"] = " ".join( - [ - "-D%s=%s" % (name, shell_quote(self.defines[name]).replace("$", "$$")) - for name in sorted(global_defines) - ] - ) + self.substs["ACDEFINES"] = " ".join([ + "-D%s=%s" % (name, shell_quote(self.defines[name]).replace("$", "$$")) + for name in sorted(global_defines) + ]) def serialize(name, obj): if isinstance(obj, str): @@ -165,13 +163,11 @@ def serialize(name, obj): raise Exception("Unhandled type %s for %s", type(obj), str(name)) self.substs["ALLSUBSTS"] = "\n".join( - sorted( - [ - "%s = %s" % (name, serialize(name, self.substs[name])) - for name in self.substs - if self.substs[name] - ] - ) + sorted([ + "%s = %s" % (name, serialize(name, self.substs[name])) + for name in self.substs + if self.substs[name] + ]) ) self.substs["ALLEMPTYSUBSTS"] = "\n".join( sorted(["%s =" % name for name in self.substs if not self.substs[name]]) @@ -334,13 +330,10 @@ def write_vars(self, config): defines = config["defines"].copy() global_defines = [name for name in config["defines"]] - acdefines = " ".join( - [ - "-D%s=%s" - % (name, shell_quote(config["defines"][name]).replace("$", "$$")) - for name in sorted(global_defines) - ] - ) + acdefines = " ".join([ + "-D%s=%s" % (name, shell_quote(config["defines"][name]).replace("$", "$$")) + for name in sorted(global_defines) + ]) substs["ACDEFINES"] = acdefines all_defines = OrderedDict() diff --git a/python/mozbuild/mozbuild/backend/cpp_eclipse.py b/python/mozbuild/mozbuild/backend/cpp_eclipse.py index bafc37ace730a..805d5efd54c6a 100644 --- a/python/mozbuild/mozbuild/backend/cpp_eclipse.py +++ b/python/mozbuild/mozbuild/backend/cpp_eclipse.py @@ -210,18 +210,16 @@ def _import_project(self): self._write_noindex() try: - subprocess.check_call( - [ - "eclipse", - "-application", - "-nosplash", - "org.eclipse.cdt.managedbuilder.core.headlessbuild", - "-data", - self._workspace_dir, - "-importAll", - self._project_dir, - ] - ) + subprocess.check_call([ + "eclipse", + "-application", + "-nosplash", + "org.eclipse.cdt.managedbuilder.core.headlessbuild", + "-data", + self._workspace_dir, + "-importAll", + self._project_dir, + ]) except OSError as e: # Remove the workspace directory so we re-generate it and # try to import again when the backend is invoked again. diff --git a/python/mozbuild/mozbuild/backend/fastermake.py b/python/mozbuild/mozbuild/backend/fastermake.py index c40fd29020272..7a73e9d4f8ca8 100644 --- a/python/mozbuild/mozbuild/backend/fastermake.py +++ b/python/mozbuild/mozbuild/backend/fastermake.py @@ -86,9 +86,11 @@ def consume_object(self, obj): f, ) ) - self._l10n_dependencies[dep_target].append( - (merge, f.full_path, src) - ) + self._l10n_dependencies[dep_target].append(( + merge, + f.full_path, + src, + )) src = merge else: src = f.full_path @@ -220,12 +222,10 @@ def consume_finished(self): rule = mk.create_rule([merge]).add_dependencies( [ref_file, l10n_file] + python_deps ) - rule.add_commands( - [ - "$(PYTHON3) -m moz.l10n.bin.build_file " - f"--source {ref_file} --l10n {l10n_file} --target {merge}" - ] - ) + rule.add_commands([ + "$(PYTHON3) -m moz.l10n.bin.build_file " + f"--source {ref_file} --l10n {l10n_file} --target {merge}" + ]) # Add a dummy rule for the l10n file since it might not exist. mk.create_rule([l10n_file]) diff --git a/python/mozbuild/mozbuild/backend/recursivemake.py b/python/mozbuild/mozbuild/backend/recursivemake.py index 2fd8b8432278a..40a3508881362 100644 --- a/python/mozbuild/mozbuild/backend/recursivemake.py +++ b/python/mozbuild/mozbuild/backend/recursivemake.py @@ -181,10 +181,9 @@ def close(self): self.fh.write("NONRECURSIVE_TARGETS += export\n") self.fh.write("NONRECURSIVE_TARGETS_export += xpidl\n") self.fh.write( - "NONRECURSIVE_TARGETS_export_xpidl_DIRECTORY = " - "$(DEPTH)/xpcom/xpidl\n" + "NONRECURSIVE_TARGETS_export_xpidl_DIRECTORY = $(DEPTH)/xpcom/xpidl\n" ) - self.fh.write("NONRECURSIVE_TARGETS_export_xpidl_TARGETS += " "export\n") + self.fh.write("NONRECURSIVE_TARGETS_export_xpidl_TARGETS += export\n") return self.fh.close() @@ -1617,9 +1616,12 @@ def _process_final_target_files(self, obj, files, backend_file): else: install_manifest.add_pattern_link(f.srcdir, f, dest_dir) elif isinstance(f, AbsolutePath): - if not f.full_path.lower().endswith( - (".dll", ".pdb", ".so", ".dylib") - ): + if not f.full_path.lower().endswith(( + ".dll", + ".pdb", + ".so", + ".dylib", + )): raise Exception( "Absolute paths installed to FINAL_TARGET_FILES must" " only be shared libraries or associated debug" @@ -1761,16 +1763,16 @@ def _process_chrome_manifest_entry(self, obj, backend_file): mozpath.join("$(DEPTH)", top_level), make_quote(shell_quote("manifest %s" % path)), ] - rule.add_commands( - ["$(call py_action,buildlist %s,%s)" % (path, " ".join(args))] - ) + rule.add_commands([ + "$(call py_action,buildlist %s,%s)" % (path, " ".join(args)) + ]) args = [ mozpath.join("$(DEPTH)", obj.path), make_quote(shell_quote(str(obj.entry))), ] - rule.add_commands( - ["$(call py_action,buildlist %s,%s)" % (obj.entry.path, " ".join(args))] - ) + rule.add_commands([ + "$(call py_action,buildlist %s,%s)" % (obj.entry.path, " ".join(args)) + ]) fragment.dump(backend_file.fh, removal_guard=False) self._no_skip["misc"].add(obj.relsrcdir) @@ -1853,22 +1855,17 @@ def _handle_ipdl_sources( basename = os.path.basename(source) sorted_nonstatic_ipdl_basenames.append(basename) rule = mk.create_rule([basename]) - rule.add_dependencies( - [ - source, - "backend.mk", - "Makefile", - "$(DEPTH)/config/autoconf.mk", - "$(topsrcdir)/config/config.mk", - ] - ) - rule.add_commands( - [ - "$(RM) $@", - "$(call py_action,preprocessor $@,$(DEFINES) $(ACDEFINES) " - "$< -o $@)", - ] - ) + rule.add_dependencies([ + source, + "backend.mk", + "Makefile", + "$(DEPTH)/config/autoconf.mk", + "$(topsrcdir)/config/config.mk", + ]) + rule.add_commands([ + "$(RM) $@", + "$(call py_action,preprocessor $@,$(DEFINES) $(ACDEFINES) $< -o $@)", + ]) mk.add_statement( "ALL_IPDLSRCS := %s %s" @@ -1943,25 +1940,20 @@ def _handle_webidl_build( for source in sorted(webidls.all_preprocessed_sources()): basename = os.path.basename(source) rule = mk.create_rule([basename]) - rule.add_dependencies( - [ - source, - "backend.mk", - "Makefile", - "$(DEPTH)/config/autoconf.mk", - "$(topsrcdir)/config/config.mk", - ] - ) - rule.add_commands( - [ - # Remove the file before writing so bindings that go from - # static to preprocessed don't end up writing to a symlink, - # which would modify content in the source directory. - "$(RM) $@", - "$(call py_action,preprocessor $@,$(DEFINES) $(ACDEFINES) " - "$< -o $@)", - ] - ) + rule.add_dependencies([ + source, + "backend.mk", + "Makefile", + "$(DEPTH)/config/autoconf.mk", + "$(topsrcdir)/config/config.mk", + ]) + rule.add_commands([ + # Remove the file before writing so bindings that go from + # static to preprocessed don't end up writing to a symlink, + # which would modify content in the source directory. + "$(RM) $@", + "$(call py_action,preprocessor $@,$(DEFINES) $(ACDEFINES) $< -o $@)", + ]) self._add_unified_build_rules( mk, diff --git a/python/mozbuild/mozbuild/code_analysis/mach_commands.py b/python/mozbuild/mozbuild/code_analysis/mach_commands.py index e32a1d6dca280..6360ab52e9004 100644 --- a/python/mozbuild/mozbuild/code_analysis/mach_commands.py +++ b/python/mozbuild/mozbuild/code_analysis/mach_commands.py @@ -582,8 +582,7 @@ def _get_clang_tidy_command( @StaticAnalysisSubCommand( "static-analysis", "autotest", - "Run the auto-test suite in order to determine that" - " the analysis did not regress.", + "Run the auto-test suite in order to determine that the analysis did not regress.", ) @CommandArgument( "--dump-results", diff --git a/python/mozbuild/mozbuild/codecoverage/lcov_rewriter.py b/python/mozbuild/mozbuild/codecoverage/lcov_rewriter.py index b8d5d0b2050f9..64dc824799733 100644 --- a/python/mozbuild/mozbuild/codecoverage/lcov_rewriter.py +++ b/python/mozbuild/mozbuild/codecoverage/lcov_rewriter.py @@ -74,9 +74,9 @@ def resummarize(self): for fn_name, count in self.function_exec_counts.items() if fn_name in self.functions.values() } - self.covered_function_count = len( - [c for c in self.function_exec_counts.values() if c] - ) + self.covered_function_count = len([ + c for c in self.function_exec_counts.values() if c + ]) self.line_count = len(self.lines) self.covered_line_count = len([c for c, _ in self.lines.values() if c]) self.branch_count = len(self.branches) @@ -177,9 +177,9 @@ def _rewrite_branches(self, record): def rewrite_record(self, record, pp_info): # Rewrite the lines in the given record according to preprocessor info # and split to additional records when pp_info has included file info. - self._current_pp_info = dict( - [(tuple([int(l) for l in k.split(",")]), v) for k, v in pp_info.items()] - ) + self._current_pp_info = dict([ + (tuple([int(l) for l in k.split(",")]), v) for k, v in pp_info.items() + ]) self._ranges = sorted(self._current_pp_info.keys()) self._additions = {} self._rewrite_lines(record) diff --git a/python/mozbuild/mozbuild/compilation/database.py b/python/mozbuild/mozbuild/compilation/database.py index 7594be16ae407..5cb2acf661867 100644 --- a/python/mozbuild/mozbuild/compilation/database.py +++ b/python/mozbuild/mozbuild/compilation/database.py @@ -129,13 +129,11 @@ def consume_finished(self): per_source_flags = self._per_source_flags.get(filename) if per_source_flags is not None: c.extend(per_source_flags) - db.append( - { - "directory": directory, - "command": shell_quote(*c), - "file": mozpath.join(directory, filename), - } - ) + db.append({ + "directory": directory, + "command": shell_quote(*c), + "file": mozpath.join(directory, filename), + }) import json diff --git a/python/mozbuild/mozbuild/config_status.py b/python/mozbuild/mozbuild/config_status.py index 07bc0f8d4941c..2f81ede9e6982 100644 --- a/python/mozbuild/mozbuild/config_status.py +++ b/python/mozbuild/mozbuild/config_status.py @@ -106,17 +106,15 @@ def config_status( """ if "CONFIG_FILES" in os.environ: - raise Exception( - "Using the CONFIG_FILES environment variable is not " "supported." - ) + raise Exception("Using the CONFIG_FILES environment variable is not supported.") if "CONFIG_HEADERS" in os.environ: raise Exception( - "Using the CONFIG_HEADERS environment variable is not " "supported." + "Using the CONFIG_HEADERS environment variable is not supported." ) if not os.path.isabs(topsrcdir): raise Exception( - "topsrcdir must be defined as an absolute directory: " "%s" % topsrcdir + "topsrcdir must be defined as an absolute directory: %s" % topsrcdir ) default_backends = ["RecursiveMake"] diff --git a/python/mozbuild/mozbuild/configure/__init__.py b/python/mozbuild/mozbuild/configure/__init__.py index 494e1f541840c..4d8d692efa409 100644 --- a/python/mozbuild/mozbuild/configure/__init__.py +++ b/python/mozbuild/mozbuild/configure/__init__.py @@ -330,22 +330,20 @@ class ConfigureSandbox(dict): # Expose a limited set of functions from os.path OS = ReadOnlyNamespace( - path=ReadOnlyNamespace( - **{ - k: getattr(mozpath, k, getattr(os.path, k)) - for k in ( - "abspath", - "basename", - "dirname", - "isabs", - "join", - "normcase", - "normpath", - "realpath", - "relpath", - ) - } - ) + path=ReadOnlyNamespace(**{ + k: getattr(mozpath, k, getattr(os.path, k)) + for k in ( + "abspath", + "basename", + "dirname", + "isabs", + "join", + "normcase", + "normpath", + "realpath", + "relpath", + ) + }) ) def __init__( @@ -708,7 +706,7 @@ def _dependency(self, arg, callee_name, arg_name=None): raise ConfigureError("Option must not contain an '='") if name not in self._options: raise ConfigureError( - "'%s' is not a known option. " "Maybe it's declared too late?" % arg + "'%s' is not a known option. Maybe it's declared too late?" % arg ) arg = self._options[name] self._seen.add(arg) @@ -833,8 +831,7 @@ def depends_impl(self, *args, **kwargs): for c in conditions: if c != when: raise ConfigureError( - "@depends function needs the same `when` " - "as options it depends on" + "@depends function needs the same `when` as options it depends on" ) def decorator(func): @@ -1088,7 +1085,7 @@ def _resolve_and_set(self, data, name, value, when=None): raise TypeError("Unexpected type: '%s'" % type(name).__name__) if name in data: raise ConfigureError( - "Cannot add '%s' to configuration: Key already " "exists" % name + "Cannot add '%s' to configuration: Key already exists" % name ) value = self._resolve(value) if value is not None: @@ -1108,9 +1105,10 @@ def set_config_impl(self, name, value, when=None): """ when = self._normalize_when(when, "set_config") - self._execution_queue.append( - (self._resolve_and_set, (self._config, name, value, when)) - ) + self._execution_queue.append(( + self._resolve_and_set, + (self._config, name, value, when), + )) def set_define_impl(self, name, value, when=None): """Implementation of set_define(). @@ -1123,9 +1121,10 @@ def set_define_impl(self, name, value, when=None): when = self._normalize_when(when, "set_define") defines = self._config.setdefault("DEFINES", {}) - self._execution_queue.append( - (self._resolve_and_set, (defines, name, value, when)) - ) + self._execution_queue.append(( + self._resolve_and_set, + (defines, name, value, when), + )) def imply_option_impl(self, option, value, reason=None, when=None): """Implementation of imply_option(). diff --git a/python/mozbuild/mozbuild/configure/constants.py b/python/mozbuild/mozbuild/configure/constants.py index 25f43bb9f8fe3..4e6000408051b 100644 --- a/python/mozbuild/mozbuild/configure/constants.py +++ b/python/mozbuild/mozbuild/configure/constants.py @@ -111,30 +111,28 @@ class Abi(EnumString): # The order of those checks matter -CPU_preprocessor_checks = OrderedDict( - ( - ("x86", "__i386__ || _M_IX86"), - ("x86_64", "__x86_64__ || _M_X64"), - ("arm", "__arm__ || _M_ARM"), - ("aarch64", "__aarch64__ || _M_ARM64"), - ("ia64", "__ia64__"), - ("s390x", "__s390x__"), - ("s390", "__s390__"), - ("ppc64", "__powerpc64__"), - ("ppc", "__powerpc__"), - ("Alpha", "__alpha__"), - ("hppa", "__hppa__"), - ("sparc64", "__sparc__ && __arch64__"), - ("sparc", "__sparc__"), - ("m68k", "__m68k__"), - ("mips64", "__mips64"), - ("mips32", "__mips__"), - ("riscv64", "__riscv && __riscv_xlen == 64"), - ("loongarch64", "__loongarch64"), - ("sh4", "__sh__"), - ("wasm32", "__wasm32__"), - ) -) +CPU_preprocessor_checks = OrderedDict(( + ("x86", "__i386__ || _M_IX86"), + ("x86_64", "__x86_64__ || _M_X64"), + ("arm", "__arm__ || _M_ARM"), + ("aarch64", "__aarch64__ || _M_ARM64"), + ("ia64", "__ia64__"), + ("s390x", "__s390x__"), + ("s390", "__s390__"), + ("ppc64", "__powerpc64__"), + ("ppc", "__powerpc__"), + ("Alpha", "__alpha__"), + ("hppa", "__hppa__"), + ("sparc64", "__sparc__ && __arch64__"), + ("sparc", "__sparc__"), + ("m68k", "__m68k__"), + ("mips64", "__mips64"), + ("mips32", "__mips__"), + ("riscv64", "__riscv && __riscv_xlen == 64"), + ("loongarch64", "__loongarch64"), + ("sh4", "__sh__"), + ("wasm32", "__wasm32__"), +)) assert sorted(CPU_preprocessor_checks.keys()) == sorted(CPU.POSSIBLE_VALUES) diff --git a/python/mozbuild/mozbuild/configure/lint.py b/python/mozbuild/mozbuild/configure/lint.py index 4598d83b8cb60..2f445c68ac54c 100644 --- a/python/mozbuild/mozbuild/configure/lint.py +++ b/python/mozbuild/mozbuild/configure/lint.py @@ -237,8 +237,7 @@ def _check_prefix_for_bool_option(self, *args, **kwargs): if name.startswith(f"--{prefix}-"): frame = self._pretty_current_frame() e = ConfigureError( - "{} should be used instead of " - "{} with default={}".format( + "{} should be used instead of {} with default={}".format( name.replace(f"--{prefix}-", f"--{replacement}-"), name, default, diff --git a/python/mozbuild/mozbuild/configure/options.py b/python/mozbuild/mozbuild/configure/options.py index e6627b8251d90..fdc28f78a86d2 100644 --- a/python/mozbuild/mozbuild/configure/options.py +++ b/python/mozbuild/mozbuild/configure/options.py @@ -220,8 +220,7 @@ def __init__( ): if not name and not env: raise InvalidOptionError( - "At least an option name or an environment variable name must " - "be given" + "At least an option name or an environment variable name must be given" ) if name: if not isinstance(name, str): diff --git a/python/mozbuild/mozbuild/controller/building.py b/python/mozbuild/mozbuild/controller/building.py index 844329bb203d0..f2659ccc33da1 100644 --- a/python/mozbuild/mozbuild/controller/building.py +++ b/python/mozbuild/mozbuild/controller/building.py @@ -55,10 +55,9 @@ """.strip() -INSTALL_TESTS_CLOBBER = "".join( - [ - TextWrapper().fill(line) + "\n" - for line in """ +INSTALL_TESTS_CLOBBER = "".join([ + TextWrapper().fill(line) + "\n" + for line in """ The build system was unable to install tests because the CLOBBER file has \ been updated. This means if you edited any test files, your changes may not \ be picked up until a full/clobber build is performed. @@ -73,8 +72,7 @@ $ touch {clobber_file} """.splitlines() - ] -) +]) CLOBBER_REQUESTED_MESSAGE = """ =================== @@ -1153,7 +1151,7 @@ def _build( monitor.start() if directory is not None and not what: - print("Can only use -C/--directory with an explicit target " "name.") + print("Can only use -C/--directory with an explicit target name.") return 1 if directory is not None: @@ -1259,14 +1257,12 @@ def get_substs_flag(name): status = None - if not config_rc and any( - [ - self.backend_out_of_date( - mozpath.join(self.topobjdir, "backend.%sBackend" % backend) - ) - for backend in all_backends - ] - ): + if not config_rc and any([ + self.backend_out_of_date( + mozpath.join(self.topobjdir, "backend.%sBackend" % backend) + ) + for backend in all_backends + ]): print("Build configuration changed. Regenerating backend.") args = [ config.substs["PYTHON3"], @@ -1490,7 +1486,7 @@ def get_substs_flag(name): logging.WARNING, "compiler_warning", warning, - "warning: {normpath}:{line}:{column} [{flag}] " "{message}", + "warning: {normpath}:{line}:{column} [{flag}] {message}", ) else: self.log( @@ -1532,9 +1528,9 @@ def get_substs_flag(name): self.notify("Build complete" if not status else "Build failed") if status: - if what and any( - [target for target in what if target not in ("faster", "binaries")] - ): + if what and any([ + target for target in what if target not in ("faster", "binaries") + ]): print( "Hey! Builds initiated with `mach build " "$A_SPECIFIC_TARGET` may not always work, even if the " @@ -1548,7 +1544,7 @@ def get_substs_flag(name): # if excessive: # print(EXCESSIVE_SWAP_MESSAGE) - print("To view a profile of the build, run |mach " "resource-usage|.") + print("To view a profile of the build, run |mach resource-usage|.") long_build = monitor.elapsed > 1200 @@ -1840,13 +1836,11 @@ def _check_clobber(self, mozconfig, env): return `True` if the clobber was required but not completed, and return `False` if the clobber was not required and not completed. """ - auto_clobber = any( - [ - env.get("AUTOCLOBBER", False), - (mozconfig["env"] or {}).get("added", {}).get("AUTOCLOBBER", False), - "AUTOCLOBBER=1" in (mozconfig["make_extra"] or []), - ] - ) + auto_clobber = any([ + env.get("AUTOCLOBBER", False), + (mozconfig["env"] or {}).get("added", {}).get("AUTOCLOBBER", False), + "AUTOCLOBBER=1" in (mozconfig["make_extra"] or []), + ]) from mozbuild.base import BuildEnvironmentNotFoundException substs = dict() diff --git a/python/mozbuild/mozbuild/controller/clobber.py b/python/mozbuild/mozbuild/controller/clobber.py index faa218be6cb5c..00f1c73f84f66 100644 --- a/python/mozbuild/mozbuild/controller/clobber.py +++ b/python/mozbuild/mozbuild/controller/clobber.py @@ -13,10 +13,9 @@ from mozfile.mozfile import remove as mozfileremove from mozpack import path as mozpath -CLOBBER_MESSAGE = "".join( - [ - TextWrapper().fill(line) + "\n" - for line in """ +CLOBBER_MESSAGE = "".join([ + TextWrapper().fill(line) + "\n" + for line in """ The CLOBBER file has been updated, indicating that an incremental build since \ your last build will probably not work. A full/clobber build is required. @@ -38,8 +37,7 @@ $ touch {clobber_file} """.splitlines() - ] -) +]) class Clobberer: @@ -141,9 +139,9 @@ def remove_objdir(self, full=True): """ # Determine where cargo build artifacts are stored RUST_TARGET_VARS = ("RUST_HOST_TARGET", "RUST_TARGET") - rust_targets = set( - [self.substs[x] for x in RUST_TARGET_VARS if x in self.substs] - ) + rust_targets = set([ + self.substs[x] for x in RUST_TARGET_VARS if x in self.substs + ]) rust_build_kind = "release" if self.substs.get("MOZ_DEBUG_RUST"): rust_build_kind = "debug" diff --git a/python/mozbuild/mozbuild/faster_daemon.py b/python/mozbuild/mozbuild/faster_daemon.py index 0be69af1d9d49..3bd6245c38a8b 100644 --- a/python/mozbuild/mozbuild/faster_daemon.py +++ b/python/mozbuild/mozbuild/faster_daemon.py @@ -71,11 +71,9 @@ def defines(self): defines = dict(self.config_environment.acdefines) # These additions work around warts in the build system: see # http://searchfox.org/mozilla-central/rev/ad093e98f42338effe2e2513e26c3a311dd96422/config/faster/rules.mk#92-93 - defines.update( - { - "AB_CD": "en-US", - } - ) + defines.update({ + "AB_CD": "en-US", + }) return defines @mozbuild.util.memoized_property @@ -143,14 +141,10 @@ def changed_files(self): data = self.client.getSubscription("topsrcdir") if data: for dat in data: - files |= set( - [ - mozpath.normpath( - mozpath.join(self.config_environment.topsrcdir, f) - ) - for f in dat.get("files", []) - ] - ) + files |= set([ + mozpath.normpath(mozpath.join(self.config_environment.topsrcdir, f)) + for f in dat.get("files", []) + ]) return files diff --git a/python/mozbuild/mozbuild/frontend/context.py b/python/mozbuild/mozbuild/frontend/context.py index ebfd509d1c36e..16a11c5696ffd 100644 --- a/python/mozbuild/mozbuild/frontend/context.py +++ b/python/mozbuild/mozbuild/frontend/context.py @@ -495,13 +495,11 @@ def _os_ldflags(self): # TODO: This is pretty convoluted, and isn't really a per-context thing, # configure would be a better place to aggregate these. - if all( - [ - self._context.config.substs.get("OS_ARCH") == "WINNT", - self._context.config.substs.get("CC_TYPE") == "clang-cl", - not self._context.config.substs.get("MOZ_DEBUG"), - ] - ): + if all([ + self._context.config.substs.get("OS_ARCH") == "WINNT", + self._context.config.substs.get("CC_TYPE") == "clang-cl", + not self._context.config.substs.get("MOZ_DEBUG"), + ]): if self._context.config.substs.get("MOZ_OPTIMIZE"): flags.append("-OPT:REF,ICF") @@ -540,7 +538,7 @@ def _optimize_flags(self): def __setitem__(self, key, value): if key not in self._known_keys: raise ValueError( - "Invalid value. `%s` is not a compile flags " "category." % key + "Invalid value. `%s` is not a compile flags category." % key ) if key in self and self[key] is None: raise ValueError( @@ -1190,9 +1188,12 @@ def _action(item): ("exclusive", TypedList(str, StrictOrderingOnAppendList)), ) -GeneratedFilesList = StrictOrderingOnAppendListWithFlagsFactory( - {"script": str, "inputs": list, "force": bool, "flags": list} -) +GeneratedFilesList = StrictOrderingOnAppendListWithFlagsFactory({ + "script": str, + "inputs": list, + "force": bool, + "flags": list, +}) class Files(SubContext): @@ -2359,17 +2360,15 @@ def aggregate(files): """, ), "GYP_DIRS": ( - StrictOrderingOnAppendListWithFlagsFactory( - { - "variables": dict, - "input": str, - "sandbox_vars": dict, - "no_chromium": bool, - "no_unified": bool, - "non_unified_sources": StrictOrderingOnAppendList, - "action_overrides": dict, - } - ), + StrictOrderingOnAppendListWithFlagsFactory({ + "variables": dict, + "input": str, + "sandbox_vars": dict, + "no_chromium": bool, + "no_unified": bool, + "non_unified_sources": StrictOrderingOnAppendList, + "action_overrides": dict, + }), list, """Defines a list of object directories handled by gyp configurations. diff --git a/python/mozbuild/mozbuild/frontend/data.py b/python/mozbuild/mozbuild/frontend/data.py index 8e389bab01dbc..e0fc082da3460 100644 --- a/python/mozbuild/mozbuild/frontend/data.py +++ b/python/mozbuild/mozbuild/frontend/data.py @@ -1399,20 +1399,18 @@ def __init__( self.required_during_compile = [ f for f in self.outputs - if f.endswith( - ( - ".asm", - ".c", - ".cpp", - ".inc", - ".m", - ".mm", - ".def", - ".s", - ".S", - "symverscript", - ) - ) + if f.endswith(( + ".asm", + ".c", + ".cpp", + ".inc", + ".m", + ".mm", + ".def", + ".s", + ".S", + "symverscript", + )) ] else: self.required_during_compile = required_during_compile diff --git a/python/mozbuild/mozbuild/frontend/emitter.py b/python/mozbuild/mozbuild/frontend/emitter.py index d5dbd938f9fdd..8f66a856d634f 100644 --- a/python/mozbuild/mozbuild/frontend/emitter.py +++ b/python/mozbuild/mozbuild/frontend/emitter.py @@ -670,13 +670,11 @@ def check_unique_binary(program, kind): if program: check_unique_binary(program, kind) self._binaries[program] = cls(context, program) - self._linkage.append( - ( - context, - self._binaries[program], - kind.replace("PROGRAM", "USE_LIBS"), - ) - ) + self._linkage.append(( + context, + self._binaries[program], + kind.replace("PROGRAM", "USE_LIBS"), + )) add_program(self._binaries[program], kind) all_rust_programs = [] @@ -711,13 +709,11 @@ def check_unique_binary(program, kind): check_unique_binary(program, kind) self._binaries[program] = cls(context, program, cargo_file) - self._linkage.append( - ( - context, - self._binaries[program], - kind.replace("RUST_PROGRAMS", "USE_LIBS"), - ) - ) + self._linkage.append(( + context, + self._binaries[program], + kind.replace("RUST_PROGRAMS", "USE_LIBS"), + )) add_program(self._binaries[program], kind) for kind, cls in [ @@ -736,17 +732,11 @@ def check_unique_binary(program, kind): self._binaries[program] = cls( context, program, is_unit_test=kind == "CPP_UNIT_TESTS" ) - self._linkage.append( - ( - context, - self._binaries[program], - ( - "HOST_USE_LIBS" - if kind == "HOST_SIMPLE_PROGRAMS" - else "USE_LIBS" - ), - ) - ) + self._linkage.append(( + context, + self._binaries[program], + ("HOST_USE_LIBS" if kind == "HOST_SIMPLE_PROGRAMS" else "USE_LIBS"), + )) add_program(self._binaries[program], kind) host_libname = context.get("HOST_LIBRARY_NAME") @@ -795,19 +785,17 @@ def check_unique_binary(program, kind): if final_lib: if static_lib: raise SandboxValidationError( - "FINAL_LIBRARY implies FORCE_STATIC_LIB. " - "Please remove the latter.", + "FINAL_LIBRARY implies FORCE_STATIC_LIB. Please remove the latter.", context, ) if shared_lib: raise SandboxValidationError( - "FINAL_LIBRARY conflicts with FORCE_SHARED_LIB. " - "Please remove one.", + "FINAL_LIBRARY conflicts with FORCE_SHARED_LIB. Please remove one.", context, ) if is_framework: raise SandboxValidationError( - "FINAL_LIBRARY conflicts with IS_FRAMEWORK. " "Please remove one.", + "FINAL_LIBRARY conflicts with IS_FRAMEWORK. Please remove one.", context, ) static_args["link_into"] = final_lib @@ -817,7 +805,7 @@ def check_unique_binary(program, kind): if is_framework: if soname: raise SandboxValidationError( - "IS_FRAMEWORK conflicts with SONAME. " "Please remove one.", + "IS_FRAMEWORK conflicts with SONAME. Please remove one.", context, ) shared_lib = True @@ -961,7 +949,7 @@ def check_unique_binary(program, kind): if lib_defines: if not libname: raise SandboxValidationError( - "LIBRARY_DEFINES needs a " "LIBRARY_NAME to take effect", + "LIBRARY_DEFINES needs a LIBRARY_NAME to take effect", context, ) lib.lib_defines.update(lib_defines) @@ -1040,8 +1028,7 @@ def check_unique_binary(program, kind): for f in context_srcs: if f in seen_sources: raise SandboxValidationError( - "Source file should only " - "be added to %s once: %s" % (symbol, f), + "Source file should only be added to %s once: %s" % (symbol, f), context, ) seen_sources.add(f) @@ -1058,8 +1045,7 @@ def check_unique_binary(program, kind): if isinstance(f, SourcePath) and not os.path.exists(full_path): raise SandboxValidationError( - "File listed in %s does not " - "exist: '%s'" % (symbol, full_path), + "File listed in %s does not exist: '%s'" % (symbol, full_path), context, ) @@ -1089,7 +1075,7 @@ def check_unique_binary(program, kind): if no_pgo: if no_pgo_sources: raise SandboxValidationError( - "NO_PGO and SOURCES[...].no_pgo " "cannot be set at the same time", + "NO_PGO and SOURCES[...].no_pgo cannot be set at the same time", context, ) passthru.variables["NO_PROFILE_GUIDED_OPTIMIZE"] = no_pgo @@ -1261,16 +1247,14 @@ def emit_from_context(self, context): and context["DELAYLOAD_DLLS"] ): if context.config.substs.get("CC_TYPE") != "clang": - context["LDFLAGS"].extend( - [("-DELAYLOAD:%s" % dll) for dll in context["DELAYLOAD_DLLS"]] - ) + context["LDFLAGS"].extend([ + ("-DELAYLOAD:%s" % dll) for dll in context["DELAYLOAD_DLLS"] + ]) else: - context["LDFLAGS"].extend( - [ - ("-Wl,-Xlink=-DELAYLOAD:%s" % dll) - for dll in context["DELAYLOAD_DLLS"] - ] - ) + context["LDFLAGS"].extend([ + ("-Wl,-Xlink=-DELAYLOAD:%s" % dll) + for dll in context["DELAYLOAD_DLLS"] + ]) context["OS_LIBS"].append("delayimp") for v in ["CMFLAGS", "CMMFLAGS"]: @@ -1448,12 +1432,10 @@ def emit_from_context(self, context): for obj in self._handle_linkables(context, passthru, generated_files): yield obj - generated_files.update( - [ - "%s%s" % (k, self.config.substs.get("BIN_SUFFIX", "")) - for k in self._binaries.keys() - ] - ) + generated_files.update([ + "%s%s" % (k, self.config.substs.get("BIN_SUFFIX", "")) + for k in self._binaries.keys() + ]) processed_moz_src_files = None if "MOZ_SRC_FILES" in context: @@ -1587,7 +1569,7 @@ def emit_from_context(self, context): context.get("DIST_SUBDIR") or context.get("XPI_NAME") ): raise SandboxValidationError( - "RESOURCES_FILES cannot be used with DIST_SUBDIR or " "XPI_NAME.", + "RESOURCES_FILES cannot be used with DIST_SUBDIR or XPI_NAME.", context, ) @@ -1673,14 +1655,14 @@ def _process_xpidl(self, context): if not xpidl_module: if context["XPIDL_SOURCES"]: raise SandboxValidationError( - "XPIDL_MODULE must be defined if " "XPIDL_SOURCES is defined.", + "XPIDL_MODULE must be defined if XPIDL_SOURCES is defined.", context, ) return if not context["XPIDL_SOURCES"]: raise SandboxValidationError( - "XPIDL_MODULE cannot be defined " "unless there are XPIDL_SOURCES", + "XPIDL_MODULE cannot be defined unless there are XPIDL_SOURCES", context, ) @@ -1695,7 +1677,7 @@ def _process_xpidl(self, context): for idl in context["XPIDL_SOURCES"]: if not os.path.exists(idl.full_path): raise SandboxValidationError( - "File %s from XPIDL_SOURCES " "does not exist" % idl.full_path, + "File %s from XPIDL_SOURCES does not exist" % idl.full_path, context, ) @@ -1839,15 +1821,13 @@ def process_support_files(test): obj.installs[source] = (dest, False) obj.external_installs |= install_info.external_installs for install_path in install_info.deferred_installs: - if all( - [ - "*" not in install_path, - not os.path.isfile( - mozpath.join(context.config.topsrcdir, install_path[2:]) - ), - install_path not in install_info.external_installs, - ] - ): + if all([ + "*" not in install_path, + not os.path.isfile( + mozpath.join(context.config.topsrcdir, install_path[2:]) + ), + install_path not in install_info.external_installs, + ]): raise SandboxValidationError( "Error processing test " "manifest %s: entry in support-files not present " @@ -1934,8 +1914,7 @@ def _process_jar_manifests(self, context): jar_manifests = context.get("JAR_MANIFESTS", []) if len(jar_manifests) > 1: raise SandboxValidationError( - "While JAR_MANIFESTS is a list, " - "it is currently limited to one value.", + "While JAR_MANIFESTS is a list, it is currently limited to one value.", context, ) diff --git a/python/mozbuild/mozbuild/frontend/gyp_reader.py b/python/mozbuild/mozbuild/frontend/gyp_reader.py index 361af4844eaeb..d24df2f81b0e9 100644 --- a/python/mozbuild/mozbuild/frontend/gyp_reader.py +++ b/python/mozbuild/mozbuild/frontend/gyp_reader.py @@ -431,12 +431,10 @@ def __init__( if config.substs["CC_TYPE"] == "clang-cl": # This isn't actually used anywhere in this generator, but it's needed # to override the registry detection of VC++ in gyp. - os.environ.update( - { - "GYP_MSVS_OVERRIDE_PATH": "fake_path", - "GYP_MSVS_VERSION": config.substs["MSVS_VERSION"], - } - ) + os.environ.update({ + "GYP_MSVS_OVERRIDE_PATH": "fake_path", + "GYP_MSVS_VERSION": config.substs["MSVS_VERSION"], + }) params = { "parallel": False, diff --git a/python/mozbuild/mozbuild/frontend/reader.py b/python/mozbuild/mozbuild/frontend/reader.py index 93020fa92a1f3..1802fe27eb04a 100644 --- a/python/mozbuild/mozbuild/frontend/reader.py +++ b/python/mozbuild/mozbuild/frontend/reader.py @@ -875,8 +875,7 @@ def __init__(self, config, finder=default_finder): def summary(self): return ExecutionSummary( - "Finished reading {file_count:d} moz.build files in " - "{execution_time:.2f}s", + "Finished reading {file_count:d} moz.build files in {execution_time:.2f}s", file_count=self._file_count, execution_time=self._execution_time, ) @@ -1217,7 +1216,7 @@ def _read_mozbuild(self, path, config, descend, metadata): for v in ("input", "variables"): if not getattr(gyp_dir, v): raise SandboxValidationError( - "Missing value for " 'GYP_DIRS["%s"].%s' % (target_dir, v), + 'Missing value for GYP_DIRS["%s"].%s' % (target_dir, v), context, ) diff --git a/python/mozbuild/mozbuild/frontend/sandbox.py b/python/mozbuild/mozbuild/frontend/sandbox.py index 76057c367baff..00ddb979fcf39 100644 --- a/python/mozbuild/mozbuild/frontend/sandbox.py +++ b/python/mozbuild/mozbuild/frontend/sandbox.py @@ -101,20 +101,18 @@ class Sandbox(dict): """ # The default set of builtins. - BUILTINS = ReadOnlyDict( - { - # Only real Python built-ins should go here. - "None": None, - "False": False, - "True": True, - "sorted": alphabetical_sorted, - "int": int, - "len": len, - "range": range, - "set": set, - "tuple": tuple, - } - ) + BUILTINS = ReadOnlyDict({ + # Only real Python built-ins should go here. + "None": None, + "False": False, + "True": True, + "sorted": alphabetical_sorted, + "int": int, + "len": len, + "range": range, + "set": set, + "tuple": tuple, + }) def __init__(self, context, finder=default_finder): """Initialize a Sandbox ready for execution.""" diff --git a/python/mozbuild/mozbuild/lockfiles/generate_python_lockfiles.py b/python/mozbuild/mozbuild/lockfiles/generate_python_lockfiles.py index 7b40ef45c2a68..a22c01f699c0e 100644 --- a/python/mozbuild/mozbuild/lockfiles/generate_python_lockfiles.py +++ b/python/mozbuild/mozbuild/lockfiles/generate_python_lockfiles.py @@ -28,7 +28,6 @@ class MissingUVError(Exception): class GeneratePythonLockfiles(MozbuildObject): - def __init__(self, *args, **kwargs) -> None: super().__init__(*args, virtualenv_name="uv", **kwargs) diff --git a/python/mozbuild/mozbuild/lockfiles/site_dependency_extractor.py b/python/mozbuild/mozbuild/lockfiles/site_dependency_extractor.py index 5a46810e6a43a..126b6f2c6207e 100644 --- a/python/mozbuild/mozbuild/lockfiles/site_dependency_extractor.py +++ b/python/mozbuild/mozbuild/lockfiles/site_dependency_extractor.py @@ -31,7 +31,6 @@ class DependencyParseError(Exception): class SiteDependencyExtractor: - def __init__(self, site_name: str, sites_dir: Path, topsrcdir: Path) -> None: self.site_file = sites_dir / f"{site_name}.txt" if not self.site_file.is_file(): diff --git a/python/mozbuild/mozbuild/mach_commands.py b/python/mozbuild/mozbuild/mach_commands.py index b09482630c4bd..7259c406566a7 100644 --- a/python/mozbuild/mozbuild/mach_commands.py +++ b/python/mozbuild/mozbuild/mach_commands.py @@ -127,36 +127,34 @@ def starts_with_cargo(s): else: raise ValueError - return Schema( - { - # The name of the command (not checked for now, but maybe - # later) - Required("command"): All(str, starts_with_cargo), - # Whether `make` should stop immediately in case - # of error returned by the command. Default: False - "continue_on_error": Boolean, - # Whether this command requires pre_export and export build - # targets to have run. Defaults to bool(cargo_build_flags). - "requires_export": Boolean, - # Build flags to use. If this variable is not - # defined here, the build flags are generated automatically and are - # the same as for `cargo build`. See available substitutions at the - # end. - "cargo_build_flags": [str], - # Extra build flags to use. These flags are added - # after the cargo_build_flags both when they are provided or - # automatically generated. See available substitutions at the end. - "cargo_extra_flags": [str], - # Available substitutions for `cargo_*_flags`: - # * {arch}: architecture target - # * {crate}: current crate name - # * {directory}: Directory of the current crate within the source tree - # * {features}: Rust features (for `--features`) - # * {manifest}: full path of `Cargo.toml` file - # * {target}: `--lib` for library, `--bin CRATE` for executables - # * {topsrcdir}: Top directory of sources - } - ) + return Schema({ + # The name of the command (not checked for now, but maybe + # later) + Required("command"): All(str, starts_with_cargo), + # Whether `make` should stop immediately in case + # of error returned by the command. Default: False + "continue_on_error": Boolean, + # Whether this command requires pre_export and export build + # targets to have run. Defaults to bool(cargo_build_flags). + "requires_export": Boolean, + # Build flags to use. If this variable is not + # defined here, the build flags are generated automatically and are + # the same as for `cargo build`. See available substitutions at the + # end. + "cargo_build_flags": [str], + # Extra build flags to use. These flags are added + # after the cargo_build_flags both when they are provided or + # automatically generated. See available substitutions at the end. + "cargo_extra_flags": [str], + # Available substitutions for `cargo_*_flags`: + # * {arch}: architecture target + # * {crate}: current crate name + # * {directory}: Directory of the current crate within the source tree + # * {features}: Rust features (for `--features`) + # * {manifest}: full path of `Cargo.toml` file + # * {target}: `--lib` for library, `--bin CRATE` for executables + # * {topsrcdir}: Top directory of sources + }) @Command( @@ -487,8 +485,9 @@ def doctor(command_context, fix=False, verbose=False): "what", default=["objdir", "python"], nargs="*", - help="Target to clobber, must be one of {{{}}} (default " - "objdir and python).".format(", ".join(CLOBBER_CHOICES)), + help="Target to clobber, must be one of {{{}}} (default objdir and python).".format( + ", ".join(CLOBBER_CHOICES) + ), ) @CommandArgument("--full", action="store_true", help="Perform a full clobber") def clobber(command_context, what, full=False): @@ -717,16 +716,14 @@ def handle_log_file(command_context, log_file): start_time = created command_context.log_manager.terminal_handler.formatter.start_time = created if "line" in params: - record = logging.makeLogRecord( - { - "created": created, - "name": command_context._logger.name, - "levelno": logging.INFO, - "msg": "{line}", - "params": params, - "action": action, - } - ) + record = logging.makeLogRecord({ + "created": created, + "name": command_context._logger.name, + "levelno": logging.INFO, + "msg": "{line}", + "params": params, + "action": action, + }) command_context._logger.handle(record) @@ -1582,8 +1579,7 @@ def _get_android_run_parser(): "--no-wait", action="store_true", default=False, - help="Do not wait for application to start before returning " - "(default: False)", + help="Do not wait for application to start before returning (default: False)", ) group.add_argument( "--enable-fission", @@ -1736,8 +1732,7 @@ def _get_desktop_run_parser(): group.add_argument( "--temp-profile", action="store_true", - help="Run the program using a new temporary profile created inside " - "the objdir.", + help="Run the program using a new temporary profile created inside the objdir.", ) group.add_argument( "--macos-open", @@ -3097,8 +3092,7 @@ def repackage_msi( "--unsigned", default=False, action="store_true", - help="Support `Add-AppxPackage ... -AllowUnsigned` on Windows 11." - "(Default: false)", + help="Support `Add-AppxPackage ... -AllowUnsigned` on Windows 11.(Default: false)", ) def repackage_msix( command_context, @@ -3541,8 +3535,7 @@ def repackage_snap_install(command_context, snap_file, snap_name, sudo=None): logging.ERROR, "repackage-snap-install-no-sudo", {}, - "Couldn't find a command to run snap as root; please use the" - " --sudo option", + "Couldn't find a command to run snap as root; please use the --sudo option", ) if not snap_file: diff --git a/python/mozbuild/mozbuild/repackaging/flatpak.py b/python/mozbuild/mozbuild/repackaging/flatpak.py index 628e916c9bbab..98024b0824cf3 100644 --- a/python/mozbuild/mozbuild/repackaging/flatpak.py +++ b/python/mozbuild/mozbuild/repackaging/flatpak.py @@ -150,19 +150,17 @@ def repackage_flatpak( application_ini_data = application_ini_data_from_directory(str(lib_dir)) variables = get_build_variables(application_ini_data, arch, version) - variables.update( - { - "FREEDESKTOP_VERSION": FREEDESKTOP_VERSION, - "FIREFOX_BASEAPP_CHANNEL": FIREFOX_BASEAPP_CHANNEL, - "FLATPAK_BRANCH": flatpak_branch, - "DATE": variables["TIMESTAMP"].strftime("%Y-%m-%d"), - # Override PKG_NAME since we use branches for beta vs release - "PKG_NAME": product, - "DBusActivatable": "false", - # Override Icon to match the flatpak's name - "Icon": flatpak_name, - } - ) + variables.update({ + "FREEDESKTOP_VERSION": FREEDESKTOP_VERSION, + "FIREFOX_BASEAPP_CHANNEL": FIREFOX_BASEAPP_CHANNEL, + "FLATPAK_BRANCH": flatpak_branch, + "DATE": variables["TIMESTAMP"].strftime("%Y-%m-%d"), + # Override PKG_NAME since we use branches for beta vs release + "PKG_NAME": product, + "DBusActivatable": "false", + # Override Icon to match the flatpak's name + "Icon": flatpak_name, + }) _render_flatpak_templates(template_dir, build_dir, variables) from fluent.runtime.fallback import FluentLocalization, FluentResourceLoader diff --git a/python/mozbuild/mozbuild/repackaging/msix.py b/python/mozbuild/mozbuild/repackaging/msix.py index e4ddbd47dcac4..a52b72bef8fad 100644 --- a/python/mozbuild/mozbuild/repackaging/msix.py +++ b/python/mozbuild/mozbuild/repackaging/msix.py @@ -737,9 +737,7 @@ def repackage_msix( if not makeappx: makeappx = find_sdk_tool("makeappx.exe", log=log) if not makeappx: - raise ValueError( - "makeappx is required; " "set MAKEAPPX or WINDOWSSDKDIR or PATH" - ) + raise ValueError("makeappx is required; set MAKEAPPX or WINDOWSSDKDIR or PATH") # `makeappx.exe` supports both slash and hyphen style arguments; `makemsix` # supports only hyphen style. `makeappx.exe` allows to overwrite and to @@ -776,7 +774,7 @@ def repackage_msix( def _sign_msix_win(output, force, log, verbose): powershell_exe = find_sdk_tool("powershell.exe", log=log) if not powershell_exe: - raise ValueError("powershell is required; " "set POWERSHELL or PATH") + raise ValueError("powershell is required; set POWERSHELL or PATH") def powershell(argstring, check=True): "Invoke `powershell.exe`. Arguments are given as a string to allow consumer to quote." @@ -789,9 +787,7 @@ def powershell(argstring, check=True): signtool = find_sdk_tool("signtool.exe", log=log) if not signtool: - raise ValueError( - "signtool is required; " "set SIGNTOOL or WINDOWSSDKDIR or PATH" - ) + raise ValueError("signtool is required; set SIGNTOOL or WINDOWSSDKDIR or PATH") # Our first order of business is to find, or generate, a (self-signed) # certificate. @@ -979,12 +975,12 @@ def _sign_msix_posix(output, force, log, verbose): makeappx = find_sdk_tool("makeappx", log=log) if not makeappx: - raise ValueError("makeappx is required; " "set MAKEAPPX or PATH") + raise ValueError("makeappx is required; set MAKEAPPX or PATH") openssl = find_sdk_tool("openssl", log=log) if not openssl: - raise ValueError("openssl is required; " "set OPENSSL or PATH") + raise ValueError("openssl is required; set OPENSSL or PATH") if "sign" not in subprocess.run( makeappx, check=False, capture_output=True diff --git a/python/mozbuild/mozbuild/repackaging/snap.py b/python/mozbuild/mozbuild/repackaging/snap.py index 21fa4d823fb64..2df94d7fc7ed3 100644 --- a/python/mozbuild/mozbuild/repackaging/snap.py +++ b/python/mozbuild/mozbuild/repackaging/snap.py @@ -118,16 +118,14 @@ def repackage_snap( def unpack_tarball(package, destdir): os.makedirs(destdir, exist_ok=True) - subprocess.check_call( - [ - "tar", - "-C", - destdir, - "-xvf", - package, - "--strip-components=1", - ] - ) + subprocess.check_call([ + "tar", + "-C", + destdir, + "-xvf", + package, + "--strip-components=1", + ]) def missing_connections(app_name): diff --git a/python/mozbuild/mozbuild/sphinx.py b/python/mozbuild/mozbuild/sphinx.py index d496646daeed0..09d20817c4d37 100644 --- a/python/mozbuild/mozbuild/sphinx.py +++ b/python/mozbuild/mozbuild/sphinx.py @@ -17,22 +17,18 @@ def function_reference(f, attr, args, doc): lines = [] - lines.extend( - [ - f, - "-" * len(f), - "", - ] - ) + lines.extend([ + f, + "-" * len(f), + "", + ]) docstring = prepare_docstring(doc) - lines.extend( - [ - docstring[0], - "", - ] - ) + lines.extend([ + docstring[0], + "", + ]) arg_types = [] @@ -46,12 +42,10 @@ def function_reference(f, attr, args, doc): arg_s = "(%s)" % ", ".join(arg_types) - lines.extend( - [ - ":Arguments: %s" % arg_s, - "", - ] - ) + lines.extend([ + ":Arguments: %s" % arg_s, + "", + ]) lines.extend(docstring[1:]) lines.append("") @@ -68,20 +62,16 @@ def variable_reference(v, st_type, in_type, doc): docstring = prepare_docstring(doc) - lines.extend( - [ - docstring[0], - "", - ] - ) + lines.extend([ + docstring[0], + "", + ]) - lines.extend( - [ - ":Storage Type: ``%s``" % st_type.__name__, - ":Input Type: ``%s``" % in_type.__name__, - "", - ] - ) + lines.extend([ + ":Storage Type: ``%s``" % st_type.__name__, + ":Input Type: ``%s``" % in_type.__name__, + "", + ]) lines.extend(docstring[1:]) lines.append("") @@ -98,14 +88,12 @@ def special_reference(v, func, typ, doc): docstring = prepare_docstring(doc) - lines.extend( - [ - docstring[0], - "", - ":Type: ``%s``" % typ.__name__, - "", - ] - ) + lines.extend([ + docstring[0], + "", + ":Type: ``%s``" % typ.__name__, + "", + ]) lines.extend(docstring[1:]) lines.append("") @@ -116,25 +104,21 @@ def special_reference(v, func, typ, doc): def format_module(m): lines = [] - lines.extend( - [ - ".. note::", - " moz.build files' implementation includes a ``Path`` class.", - ] - ) + lines.extend([ + ".. note::", + " moz.build files' implementation includes a ``Path`` class.", + ]) path_docstring_minus_summary = prepare_docstring(m.Path.__doc__)[2:] lines.extend([" " + line for line in path_docstring_minus_summary]) for subcontext, cls in sorted(m.SUBCONTEXTS.items()): - lines.extend( - [ - ".. _mozbuild_subcontext_%s:" % subcontext, - "", - "Sub-Context: %s" % subcontext, - "=============" + "=" * len(subcontext), - "", - ] - ) + lines.extend([ + ".. _mozbuild_subcontext_%s:" % subcontext, + "", + "Sub-Context: %s" % subcontext, + "=============" + "=" * len(subcontext), + "", + ]) lines.extend(prepare_docstring(cls.__doc__)) if lines[-1]: lines.append("") @@ -142,35 +126,29 @@ def format_module(m): for k, v in sorted(cls.VARIABLES.items()): lines.extend(variable_reference(k, *v)) - lines.extend( - [ - "Variables", - "=========", - "", - ] - ) + lines.extend([ + "Variables", + "=========", + "", + ]) for v in sorted(m.VARIABLES): lines.extend(variable_reference(v, *m.VARIABLES[v])) - lines.extend( - [ - "Functions", - "=========", - "", - ] - ) + lines.extend([ + "Functions", + "=========", + "", + ]) for func in sorted(m.FUNCTIONS): lines.extend(function_reference(func, *m.FUNCTIONS[func])) - lines.extend( - [ - "Special Variables", - "=================", - "", - ] - ) + lines.extend([ + "Special Variables", + "=================", + "", + ]) for v in sorted(m.SPECIAL_VARIABLES): lines.extend(special_reference(v, *m.SPECIAL_VARIABLES[v])) diff --git a/python/mozbuild/mozbuild/test/action/test_buildlist.py b/python/mozbuild/mozbuild/test/action/test_buildlist.py index 1a59d9d7d5c13..697f14f462f07 100644 --- a/python/mozbuild/mozbuild/test/action/test_buildlist.py +++ b/python/mozbuild/mozbuild/test/action/test_buildlist.py @@ -47,7 +47,7 @@ def assertFileContains(self, filename, l): self.assertEqual(line, l.pop(0)) self.assertTrue( len(l) == 0, - f"not enough lines in file! (expected '{l}'," f" got '{lines}'", + f"not enough lines in file! (expected '{l}', got '{lines}'", ) def test_basic(self): diff --git a/python/mozbuild/mozbuild/test/backend/test_partialconfigenvironment.py b/python/mozbuild/mozbuild/test/backend/test_partialconfigenvironment.py index 13b1656981259..f29a8b0e34a36 100644 --- a/python/mozbuild/mozbuild/test/backend/test_partialconfigenvironment.py +++ b/python/mozbuild/mozbuild/test/backend/test_partialconfigenvironment.py @@ -80,12 +80,10 @@ def test_remove_subst(self): self.assertTrue(os.path.exists(path)) def _assert_deps(self, env, deps): - deps = sorted( - [ - "$(wildcard %s)" % (mozpath.join(env.topobjdir, "config.statusd", d)) - for d in deps - ] - ) + deps = sorted([ + "$(wildcard %s)" % (mozpath.join(env.topobjdir, "config.statusd", d)) + for d in deps + ]) self.assertEqual(sorted(env.get_dependencies()), deps) def test_dependencies(self): diff --git a/python/mozbuild/mozbuild/test/backend/test_test_manifest.py b/python/mozbuild/mozbuild/test/backend/test_test_manifest.py index 4e7f86277c3c6..ee872a617901a 100644 --- a/python/mozbuild/mozbuild/test/backend/test_test_manifest.py +++ b/python/mozbuild/mozbuild/test/backend/test_test_manifest.py @@ -120,14 +120,12 @@ def test_test_manifest_sources(self): self.assertEqual( sources, - set( - [ - mozpath.join(env.topsrcdir, "mochitest.toml"), - mozpath.join(env.topsrcdir, "mochitest-common.toml"), - mozpath.join(env.topsrcdir, "moz.build"), - status_path, - ] - ), + set([ + mozpath.join(env.topsrcdir, "mochitest.toml"), + mozpath.join(env.topsrcdir, "mochitest-common.toml"), + mozpath.join(env.topsrcdir, "moz.build"), + status_path, + ]), ) diff --git a/python/mozbuild/mozbuild/test/common.py b/python/mozbuild/mozbuild/test/common.py index b3d90accd5724..d5da6c993c5d8 100644 --- a/python/mozbuild/mozbuild/test/common.py +++ b/python/mozbuild/mozbuild/test/common.py @@ -50,7 +50,7 @@ def __init__( "DLL_PREFIX": "lib", "DLL_SUFFIX": ".so", }, - **extra_substs + **extra_substs, ) self.defines = self.substs diff --git a/python/mozbuild/mozbuild/test/configure/test_bootstrap.py b/python/mozbuild/mozbuild/test/configure/test_bootstrap.py index fb8a9a41b7f67..4dff978bafd7d 100644 --- a/python/mozbuild/mozbuild/test/configure/test_bootstrap.py +++ b/python/mozbuild/mozbuild/test/configure/test_bootstrap.py @@ -16,7 +16,7 @@ class IndexSearch: def should_replace_task(self, task, *args): - return f'fake-task-id-for-{task["index"][0]}' + return f"fake-task-id-for-{task['index'][0]}" class TestBootstrap(BaseConfigureTest): diff --git a/python/mozbuild/mozbuild/test/configure/test_checks_configure.py b/python/mozbuild/mozbuild/test/configure/test_checks_configure.py index 3189d315e4aac..bdfe42a154f40 100644 --- a/python/mozbuild/mozbuild/test/configure/test_checks_configure.py +++ b/python/mozbuild/mozbuild/test/configure/test_checks_configure.py @@ -535,8 +535,7 @@ def test_check_prog_with_path(self): """ DEBUG: a: Looking for known-a ERROR: Paths provided to find_program must be a list of strings, not %r - """ - % mozpath.dirname(self.OTHER_A) + """ % mozpath.dirname(self.OTHER_A) ), ) @@ -1144,9 +1143,10 @@ def test_id_and_secret_keyfile(self): }, ) - with MockedOpen( - {"default-key": "default-id default-key\n", "key": "fake-id fake-key\n"} - ): + with MockedOpen({ + "default-key": "default-id default-key\n", + "key": "fake-id fake-key\n", + }): config, output, status = self.get_result( "id_and_secret_keyfile('Bing API', default='default-key')", args=["--with-bing-api-keyfile=key"], diff --git a/python/mozbuild/mozbuild/test/configure/test_configure.py b/python/mozbuild/mozbuild/test/configure/test_configure.py index 82ea1461ad810..3b55ad16fc12d 100644 --- a/python/mozbuild/mozbuild/test/configure/test_configure.py +++ b/python/mozbuild/mozbuild/test/configure/test_configure.py @@ -40,9 +40,9 @@ def get_config( return config def moz_configure(self, source): - return MockedOpen( - {os.path.join(test_data_path, "moz.configure"): textwrap.dedent(source)} - ) + return MockedOpen({ + os.path.join(test_data_path, "moz.configure"): textwrap.dedent(source) + }) def test_defaults(self): config = self.get_config() @@ -269,16 +269,18 @@ def test_returned_default(self): def test_returned_choices(self): for val in ("a", "b", "c"): - config = self.get_config( - ["--enable-values=alpha", "--returned-choices=%s" % val] - ) + config = self.get_config([ + "--enable-values=alpha", + "--returned-choices=%s" % val, + ]) self.assertIn("CHOICES", config) self.assertEqual(PositiveOptionValue((val,)), config["CHOICES"]) for val in ("0", "1", "2"): - config = self.get_config( - ["--enable-values=numeric", "--returned-choices=%s" % val] - ) + config = self.get_config([ + "--enable-values=numeric", + "--returned-choices=%s" % val, + ]) self.assertIn("CHOICES", config) self.assertEqual(PositiveOptionValue((val,)), config["CHOICES"]) @@ -1374,7 +1376,7 @@ def test_option_when(self): self.assertEqual( str(e.exception), - "@depends function needs the same `when` as " "options it depends on", + "@depends function needs the same `when` as options it depends on", ) with self.moz_configure( @@ -1394,7 +1396,7 @@ def always2(): self.assertEqual( str(e.exception), - "@depends function needs the same `when` as " "options it depends on", + "@depends function needs the same `when` as options it depends on", ) with self.moz_configure( @@ -1485,10 +1487,9 @@ def test_include_failures(self): self.assertEqual(str(e.exception), "Unexpected type: 'int'") def test_include_when(self): - with MockedOpen( - { - os.path.join(test_data_path, "moz.configure"): textwrap.dedent( - """ + with MockedOpen({ + os.path.join(test_data_path, "moz.configure"): textwrap.dedent( + """ option('--with-foo', help='Foo') include('always.configure', when=True) @@ -1499,27 +1500,27 @@ def test_include_when(self): set_config('BAR', bar) set_config('QUX', qux) """ - ), - os.path.join(test_data_path, "always.configure"): textwrap.dedent( - """ + ), + os.path.join(test_data_path, "always.configure"): textwrap.dedent( + """ option('--with-bar', help='Bar') @depends('--with-bar') def bar(x): if x: return 'bar' """ - ), - os.path.join(test_data_path, "never.configure"): textwrap.dedent( - """ + ), + os.path.join(test_data_path, "never.configure"): textwrap.dedent( + """ option('--with-qux', help='Qux') @depends('--with-qux') def qux(x): if x: return 'qux' """ - ), - os.path.join(test_data_path, "foo.configure"): textwrap.dedent( - """ + ), + os.path.join(test_data_path, "foo.configure"): textwrap.dedent( + """ option('--with-foo-really', help='Really foo') @depends('--with-foo-really') def foo(x): @@ -1528,14 +1529,13 @@ def foo(x): include('foo2.configure', when='--with-foo-really') """ - ), - os.path.join(test_data_path, "foo2.configure"): textwrap.dedent( - """ + ), + os.path.join(test_data_path, "foo2.configure"): textwrap.dedent( + """ set_config('FOO2', True) """ - ), - } - ): + ), + }): config = self.get_config() self.assertEqual(config, {}) @@ -1586,7 +1586,7 @@ def test_sandbox_failures(self): self.get_config() self.assertIn( - "Cannot assign `foo` because it is neither a @depends nor a " "@template", + "Cannot assign `foo` because it is neither a @depends nor a @template", str(e.exception), ) @@ -1615,7 +1615,7 @@ def foo(value): self.assertEqual( str(e.exception), - "'--with-foo' is not a known option. Maybe it's " "declared too late?", + "'--with-foo' is not a known option. Maybe it's declared too late?", ) with self.assertRaises(ConfigureError) as e: @@ -1642,7 +1642,7 @@ def foo(value): self.assertEqual( str(e.exception), - "Cannot use object of type 'int' as argument " "to @depends", + "Cannot use object of type 'int' as argument to @depends", ) with self.assertRaises(ConfigureError) as e: @@ -1947,7 +1947,7 @@ def foo(value): self.assertEqual( str(e.exception), - "@depends function needs the same `when` as " "options it depends on", + "@depends function needs the same `when` as options it depends on", ) with self.moz_configure( @@ -2084,9 +2084,9 @@ def baz(value): ("", NegativeOptionValue()), ("--baz=baz", PositiveOptionValue(("baz",))), ): - config = self.get_config( - [x for x in (foo_opt, bar_opt, baz_opt) if x] - ) + config = self.get_config([ + x for x in (foo_opt, bar_opt, baz_opt) if x + ]) self.assertEqual( config, { diff --git a/python/mozbuild/mozbuild/test/configure/test_lint.py b/python/mozbuild/mozbuild/test/configure/test_lint.py index 2a4b8a2f06eec..34278f7f1531f 100644 --- a/python/mozbuild/mozbuild/test/configure/test_lint.py +++ b/python/mozbuild/mozbuild/test/configure/test_lint.py @@ -47,9 +47,9 @@ def lint_test(self, options=[], env={}): sandbox.run(mozpath.join(test_data_path, "moz.configure")) def moz_configure(self, source): - return MockedOpen( - {os.path.join(test_data_path, "moz.configure"): textwrap.dedent(source)} - ) + return MockedOpen({ + os.path.join(test_data_path, "moz.configure"): textwrap.dedent(source) + }) def assertRaisesFromLine(self, exc_type, line): return AssertRaisesFromLine( @@ -341,7 +341,7 @@ def test_default_enable(self): self.lint_test() self.assertEqual( str(e.exception), - "--disable-foo should be used instead of " "--enable-foo with default=True", + "--disable-foo should be used instead of --enable-foo with default=True", ) def test_default_disable(self): @@ -361,8 +361,7 @@ def test_default_disable(self): self.lint_test() self.assertEqual( str(e.exception), - "--enable-foo should be used instead of " - "--disable-foo with default=False", + "--enable-foo should be used instead of --disable-foo with default=False", ) def test_default_with(self): @@ -382,7 +381,7 @@ def test_default_with(self): self.lint_test() self.assertEqual( str(e.exception), - "--without-foo should be used instead of " "--with-foo with default=True", + "--without-foo should be used instead of --with-foo with default=True", ) def test_default_without(self): @@ -402,7 +401,7 @@ def test_default_without(self): self.lint_test() self.assertEqual( str(e.exception), - "--with-foo should be used instead of " "--without-foo with default=False", + "--with-foo should be used instead of --without-foo with default=False", ) def test_default_func(self): @@ -427,8 +426,7 @@ def test_default_func(self): self.lint_test() self.assertEqual( str(e.exception), - '`help` should contain "{Enable|Disable}" because of ' - "non-constant default", + '`help` should contain "{Enable|Disable}" because of non-constant default', ) def test_dual_help(self): diff --git a/python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py b/python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py index 393bc85961e57..3fc45f3e40dfd 100644 --- a/python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py +++ b/python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py @@ -62,14 +62,12 @@ @memoize def GCC_BASE(version): version = Version(version) - return FakeCompiler( - { - "__GNUC__": version.major, - "__GNUC_MINOR__": version.minor, - "__GNUC_PATCHLEVEL__": version.patch, - "__STDC__": 1, - } - ) + return FakeCompiler({ + "__GNUC__": version.major, + "__GNUC_MINOR__": version.minor, + "__GNUC_PATCHLEVEL__": version.patch, + "__STDC__": 1, + }) @memoize @@ -145,14 +143,12 @@ def GXX(version): @memoize def CLANG_BASE(version): version = Version(version) - return FakeCompiler( - { - "__clang__": 1, - "__clang_major__": version.major, - "__clang_minor__": version.minor, - "__clang_patchlevel__": version.patch, - } - ) + return FakeCompiler({ + "__clang__": 1, + "__clang_major__": version.major, + "__clang_minor__": version.minor, + "__clang_patchlevel__": version.patch, + }) @memoize @@ -239,17 +235,15 @@ def CLANG_PLATFORM(gcc_platform): @memoize def VS(version): version = Version(version) - return FakeCompiler( - { - None: { - "_MSC_VER": "%02d%02d" % (version.major, version.minor), - "_MSC_FULL_VER": "%02d%02d%05d" - % (version.major, version.minor, version.patch), - "_MT": "1", - }, - "*.cpp": DEFAULT_CXX_97, - } - ) + return FakeCompiler({ + None: { + "_MSC_VER": "%02d%02d" % (version.major, version.minor), + "_MSC_FULL_VER": "%02d%02d%05d" + % (version.major, version.minor, version.patch), + "_MT": "1", + }, + "*.cpp": DEFAULT_CXX_97, + }) VS_2017u8 = VS("19.15.26726") @@ -703,12 +697,10 @@ def test_no_supported_compiler(self): def test_absolute_path(self): paths = dict(self.PATHS) - paths.update( - { - "/opt/clang/bin/clang": paths["/usr/bin/clang"], - "/opt/clang/bin/clang++": paths["/usr/bin/clang++"], - } - ) + paths.update({ + "/opt/clang/bin/clang": paths["/usr/bin/clang"], + "/opt/clang/bin/clang++": paths["/usr/bin/clang++"], + }) result = { "c_compiler": self.DEFAULT_CLANG_RESULT + {"compiler": "/opt/clang/bin/clang"}, @@ -725,12 +717,10 @@ def test_absolute_path(self): def test_atypical_name(self): paths = dict(self.PATHS) - paths.update( - { - "/usr/bin/afl-clang-fast": paths["/usr/bin/clang"], - "/usr/bin/afl-clang-fast++": paths["/usr/bin/clang++"], - } - ) + paths.update({ + "/usr/bin/afl-clang-fast": paths["/usr/bin/clang"], + "/usr/bin/afl-clang-fast++": paths["/usr/bin/clang++"], + }) self.do_toolchain_test( paths, { @@ -884,13 +874,11 @@ class OSXToolchainTest(BaseToolchainTest): GCC_10_RESULT = LinuxToolchainTest.GCC_10_RESULT GXX_10_RESULT = LinuxToolchainTest.GXX_10_RESULT SYSROOT_FLAGS = { - "flags": PrependFlags( - [ - "-isysroot", - xcrun("", ("--show-sdk-path",))[1], - "-mmacosx-version-min=10.15", - ] - ) + "flags": PrependFlags([ + "-isysroot", + xcrun("", ("--show-sdk-path",))[1], + "-mmacosx-version-min=10.15", + ]) } def test_clang(self): @@ -1362,12 +1350,10 @@ def do_test_cross_gcc(self, host, target): }, ) - paths.update( - { - "%s-gcc" % toolchain_prefix: DEFAULT_GCC + self.PLATFORMS[target], - "%s-g++" % toolchain_prefix: DEFAULT_GXX + self.PLATFORMS[target], - } - ) + paths.update({ + "%s-gcc" % toolchain_prefix: DEFAULT_GCC + self.PLATFORMS[target], + "%s-g++" % toolchain_prefix: DEFAULT_GXX + self.PLATFORMS[target], + }) self.do_toolchain_test( paths, { @@ -1494,12 +1480,10 @@ def test_cross_clang(self): def test_cross_atypical_clang(self): paths = dict(self.PATHS) - paths.update( - { - "/usr/bin/afl-clang-fast": paths["/usr/bin/clang"], - "/usr/bin/afl-clang-fast++": paths["/usr/bin/clang++"], - } - ) + paths.update({ + "/usr/bin/afl-clang-fast": paths["/usr/bin/clang"], + "/usr/bin/afl-clang-fast++": paths["/usr/bin/clang++"], + }) afl_clang_result = self.DEFAULT_CLANG_RESULT + { "compiler": "/usr/bin/afl-clang-fast" } @@ -1522,12 +1506,10 @@ def test_cross_atypical_clang(self): class OSXCrossToolchainTest(BaseToolchainTest): TARGET = "i686-apple-darwin11.2.0" PATHS = dict(LinuxToolchainTest.PATHS) - PATHS.update( - { - "/usr/bin/clang": CLANG_17 + CLANG_PLATFORM_X86_64_LINUX, - "/usr/bin/clang++": CLANGXX_17 + CLANG_PLATFORM_X86_64_LINUX, - } - ) + PATHS.update({ + "/usr/bin/clang": CLANG_17 + CLANG_PLATFORM_X86_64_LINUX, + "/usr/bin/clang++": CLANGXX_17 + CLANG_PLATFORM_X86_64_LINUX, + }) DEFAULT_CLANG_RESULT = CompilerResult( flags=[], version="17.0.0", diff --git a/python/mozbuild/mozbuild/test/configure/test_toolchain_helpers.py b/python/mozbuild/mozbuild/test/configure/test_toolchain_helpers.py index 1751ac4a5cd74..3e4055c51ba25 100644 --- a/python/mozbuild/mozbuild/test/configure/test_toolchain_helpers.py +++ b/python/mozbuild/mozbuild/test/configure/test_toolchain_helpers.py @@ -98,9 +98,10 @@ def test_expansion(self): self.assertEqual(pp.out.getvalue(), '1 . 2 . c "D"') def test_normalization(self): - pp = CompilerPreprocessor( - {"__has_attribute(bar)": 1, '__has_warning("-Wc++98-foo")': 1} - ) + pp = CompilerPreprocessor({ + "__has_attribute(bar)": 1, + '__has_warning("-Wc++98-foo")': 1, + }) pp.out = StringIO() input = StringIO( dedent( @@ -268,15 +269,13 @@ def test_fake_compiler(self): compiler = FakeCompiler({"A": "1", "B": "2"}) self.assertEqual(compiler(None, ["-E", "file"]), (0, "1 2 C", "")) - compiler = FakeCompiler( - { - None: {"A": "1", "B": "2"}, - "-foo": {"C": "foo"}, - "-bar": {"B": "bar", "C": "bar"}, - "-qux": {"B": False}, - "*.c": {"B": "42"}, - } - ) + compiler = FakeCompiler({ + None: {"A": "1", "B": "2"}, + "-foo": {"C": "foo"}, + "-bar": {"B": "bar", "C": "bar"}, + "-qux": {"B": False}, + "*.c": {"B": "42"}, + }) self.assertEqual(compiler(None, ["-E", "file"]), (0, "1 2 C", "")) self.assertEqual(compiler(None, ["-E", "-foo", "file"]), (0, "1 2 foo", "")) self.assertEqual( diff --git a/python/mozbuild/mozbuild/test/configure/test_toolkit_moz_configure.py b/python/mozbuild/mozbuild/test/configure/test_toolkit_moz_configure.py index 7d20c0a49e0a0..6540c04255059 100644 --- a/python/mozbuild/mozbuild/test/configure/test_toolkit_moz_configure.py +++ b/python/mozbuild/mozbuild/test/configure/test_toolkit_moz_configure.py @@ -38,7 +38,7 @@ def get_value_for(args=[], environ={}, mozconfig=""): ) self.assertEqual( - "--enable-application=browser " "MOZ_VTUNE=1", + "--enable-application=browser MOZ_VTUNE=1", get_value_for(["--enable-application=browser", "MOZ_VTUNE=1"]), ) diff --git a/python/mozbuild/mozbuild/test/configure/test_util.py b/python/mozbuild/mozbuild/test/configure/test_util.py index bf2d1a9bb8c5e..172f63227441f 100644 --- a/python/mozbuild/mozbuild/test/configure/test_util.py +++ b/python/mozbuild/mozbuild/test/configure/test_util.py @@ -59,7 +59,7 @@ def test_format(self): logger.debug("qux") self.assertEqual(out.getvalue(), "baz\n") - self.assertEqual(err.getvalue(), "ERROR:foo\n" "WARNING:bar\n") + self.assertEqual(err.getvalue(), "ERROR:foo\nWARNING:bar\n") def test_continuation(self): out = StringIO() @@ -75,7 +75,7 @@ def test_continuation(self): logger.info("yes") logger.info("qux") - self.assertEqual(out.getvalue(), "foo\n" "checking bar... yes\n" "qux\n") + self.assertEqual(out.getvalue(), "foo\nchecking bar... yes\nqux\n") out.seek(0) out.truncate() @@ -88,7 +88,7 @@ def test_continuation(self): self.assertEqual( out.getvalue(), - "foo\n" "checking bar... \n" "WARNING:hoge\n" " ... no\n" "qux\n", + "foo\nchecking bar... \nWARNING:hoge\n ... no\nqux\n", ) out.seek(0) @@ -103,12 +103,7 @@ def test_continuation(self): self.assertEqual( out.getvalue(), - "foo\n" - "checking bar... \n" - "WARNING:hoge\n" - "WARNING:fuga\n" - " ... no\n" - "qux\n", + "foo\nchecking bar... \nWARNING:hoge\nWARNING:fuga\n ... no\nqux\n", ) out.seek(0) @@ -127,9 +122,9 @@ def test_continuation(self): logger.info("no") logger.info("qux") - self.assertEqual(out.getvalue(), "foo\n" "checking bar... no\n" "qux\n") + self.assertEqual(out.getvalue(), "foo\nchecking bar... no\nqux\n") - self.assertEqual(err.getvalue(), "WARNING:hoge\n" "WARNING:fuga\n") + self.assertEqual(err.getvalue(), "WARNING:hoge\nWARNING:fuga\n") def test_queue_debug(self): out = StringIO() @@ -146,7 +141,7 @@ def test_queue_debug(self): logger.info("yes") logger.info("qux") - self.assertEqual(out.getvalue(), "checking bar... yes\n" "qux\n") + self.assertEqual(out.getvalue(), "checking bar... yes\nqux\n") out.seek(0) out.truncate() @@ -158,7 +153,7 @@ def test_queue_debug(self): logger.error("fail") self.assertEqual( - out.getvalue(), "checking bar... no\n" "DEBUG:do foo\n" "ERROR:fail\n" + out.getvalue(), "checking bar... no\nDEBUG:do foo\nERROR:fail\n" ) out.seek(0) @@ -219,7 +214,7 @@ def test_queue_debug(self): self.assertIs(caught, e) self.assertEqual( - out.getvalue(), "checking bar... no\n" "DEBUG:do foo\n" "DEBUG:do bar\n" + out.getvalue(), "checking bar... no\nDEBUG:do foo\nDEBUG:do bar\n" ) def test_queue_debug_reentrant(self): @@ -245,7 +240,7 @@ def test_queue_debug_reentrant(self): self.assertEqual( out.getvalue(), - "outer info\n" "inner info\n" "DEBUG| outer debug\n" "DEBUG| inner debug\n", + "outer info\ninner info\nDEBUG| outer debug\nDEBUG| inner debug\n", ) out.seek(0) @@ -265,7 +260,7 @@ def test_queue_debug_reentrant(self): self.assertEqual( out.getvalue(), - "outer info\n" "inner info\n" "DEBUG| outer debug\n" "DEBUG| inner debug\n", + "outer info\ninner info\nDEBUG| outer debug\nDEBUG| inner debug\n", ) out.seek(0) @@ -406,7 +401,7 @@ def test_non_ascii_subprocess_output(self): self.assertEqual(status, 0) quote_char = "'" if getpreferredencoding().lower() == "utf-8": - quote_char = "\u00B4" + quote_char = "\u00b4" self.assertEqual(out.getvalue().strip(), quote_char) diff --git a/python/mozbuild/mozbuild/test/frontend/test_context.py b/python/mozbuild/mozbuild/test/frontend/test_context.py index 307b6afe3deb2..4f9d487ef504b 100644 --- a/python/mozbuild/mozbuild/test/frontend/test_context.py +++ b/python/mozbuild/mozbuild/test/frontend/test_context.py @@ -29,13 +29,11 @@ class TestContext(unittest.TestCase): def test_defaults(self): - test = Context( - { - "foo": (int, int, ""), - "bar": (bool, bool, ""), - "baz": (dict, dict, ""), - } - ) + test = Context({ + "foo": (int, int, ""), + "bar": (bool, bool, ""), + "baz": (dict, dict, ""), + }) self.assertEqual(list(test), []) @@ -57,12 +55,10 @@ def test_defaults(self): self.assertEqual(set(test.keys()), {"foo", "bar", "baz"}) def test_type_check(self): - test = Context( - { - "foo": (int, int, ""), - "baz": (dict, list, ""), - } - ) + test = Context({ + "foo": (int, int, ""), + "baz": (dict, list, ""), + }) test["foo"] = 5 @@ -81,13 +77,11 @@ def test_type_check(self): self.assertEqual(test["baz"], {"a": 1, "b": 2}) def test_update(self): - test = Context( - { - "foo": (int, int, ""), - "bar": (bool, bool, ""), - "baz": (dict, list, ""), - } - ) + test = Context({ + "foo": (int, int, ""), + "bar": (bool, bool, ""), + "baz": (dict, list, ""), + }) self.assertEqual(list(test), []) @@ -548,11 +542,9 @@ def test_path_typed_list(self): MyListWithFlags = ContextDerivedTypedListWithItems( Path, - StrictOrderingOnAppendListWithFlagsFactory( - { - "foo": bool, - } - ), + StrictOrderingOnAppendListWithFlagsFactory({ + "foo": bool, + }), ) l = MyListWithFlags(ctxt1) l += paths diff --git a/python/mozbuild/mozbuild/test/frontend/test_emitter.py b/python/mozbuild/mozbuild/test/frontend/test_emitter.py index a660754f54367..6facc90f1d125 100644 --- a/python/mozbuild/mozbuild/test/frontend/test_emitter.py +++ b/python/mozbuild/mozbuild/test/frontend/test_emitter.py @@ -1008,7 +1008,7 @@ def test_test_manifest_unmatched_generated(self): with self.assertRaisesRegex( SandboxValidationError, "entry in generated-files not present elsewhere" ): - self.read_topsrcdir(reader), + (self.read_topsrcdir(reader),) def test_test_manifest_parent_support_files_dir(self): """support-files referencing a file in a parent directory works.""" @@ -1058,9 +1058,12 @@ def test_ipdl_sources(self): mozpath.relpath(p, ipdl_collection.topsrcdir) for p in ipdl_collection.all_regular_sources() ) - expected = set( - ["bar/bar.ipdl", "bar/bar2.ipdlh", "foo/foo.ipdl", "foo/foo2.ipdlh"] - ) + expected = set([ + "bar/bar.ipdl", + "bar/bar2.ipdlh", + "foo/foo.ipdl", + "foo/foo2.ipdlh", + ]) self.assertEqual(ipdls, expected) diff --git a/python/mozbuild/mozbuild/test/frontend/test_namespaces.py b/python/mozbuild/mozbuild/test/frontend/test_namespaces.py index 3c360c5c5c386..394493fb6cd72 100644 --- a/python/mozbuild/mozbuild/test/frontend/test_namespaces.py +++ b/python/mozbuild/mozbuild/test/frontend/test_namespaces.py @@ -64,11 +64,9 @@ def __hash__(self): "HOGEHOGE": ( ContextDerivedTypedListWithItems( Piyo, - StrictOrderingOnAppendListWithFlagsFactory( - { - "foo": bool, - } - ), + StrictOrderingOnAppendListWithFlagsFactory({ + "foo": bool, + }), ), list, None, diff --git a/python/mozbuild/mozbuild/test/frontend/test_reader.py b/python/mozbuild/mozbuild/test/frontend/test_reader.py index 07383a022ad94..63c1160cfa2e5 100644 --- a/python/mozbuild/mozbuild/test/frontend/test_reader.py +++ b/python/mozbuild/mozbuild/test/frontend/test_reader.py @@ -289,9 +289,9 @@ def test_find_relevant_mozbuilds(self): ) # Missing moz.build from missing intermediate directory. - paths = reader._find_relevant_mozbuilds( - ["d1/no-intermediate-moz-build/child/file"] - ) + paths = reader._find_relevant_mozbuilds([ + "d1/no-intermediate-moz-build/child/file" + ]) self.assertEqual( paths, { @@ -304,9 +304,9 @@ def test_find_relevant_mozbuilds(self): ) # Lots of empty directories. - paths = reader._find_relevant_mozbuilds( - ["d1/parent-is-far/dir1/dir2/dir3/file"] - ) + paths = reader._find_relevant_mozbuilds([ + "d1/parent-is-far/dir1/dir2/dir3/file" + ]) self.assertEqual( paths, { @@ -319,9 +319,10 @@ def test_find_relevant_mozbuilds(self): ) # Lots of levels. - paths = reader._find_relevant_mozbuilds( - ["d1/every-level/a/file", "d1/every-level/b/file"] - ) + paths = reader._find_relevant_mozbuilds([ + "d1/every-level/a/file", + "d1/every-level/b/file", + ]) self.assertEqual( paths, { @@ -354,9 +355,11 @@ def test_find_relevant_mozbuilds(self): def test_read_relevant_mozbuilds(self): reader = self.reader("reader-relevant-mozbuild") - paths, contexts = reader.read_relevant_mozbuilds( - ["d1/every-level/a/file", "d1/every-level/b/file", "d2/file"] - ) + paths, contexts = reader.read_relevant_mozbuilds([ + "d1/every-level/a/file", + "d1/every-level/b/file", + "d2/file", + ]) self.assertEqual(len(paths), 3) self.assertEqual(len(contexts), 6) @@ -387,13 +390,11 @@ def test_files_bad_bug_component(self): def test_files_bug_component_static(self): reader = self.reader("files-info") - v = reader.files_info( - [ - "bug_component/static/foo", - "bug_component/static/bar", - "bug_component/static/foo/baz", - ] - ) + v = reader.files_info([ + "bug_component/static/foo", + "bug_component/static/bar", + "bug_component/static/foo/baz", + ]) self.assertEqual(len(v), 3) self.assertEqual( v["bug_component/static/foo"]["BUG_COMPONENT"], @@ -420,13 +421,11 @@ def test_files_bug_component_simple(self): def test_files_bug_component_different_matchers(self): reader = self.reader("files-info") - v = reader.files_info( - [ - "bug_component/different-matchers/foo.jsm", - "bug_component/different-matchers/bar.cpp", - "bug_component/different-matchers/baz.misc", - ] - ) + v = reader.files_info([ + "bug_component/different-matchers/foo.jsm", + "bug_component/different-matchers/bar.cpp", + "bug_component/different-matchers/baz.misc", + ]) self.assertEqual(len(v), 3) js_flags = v["bug_component/different-matchers/foo.jsm"] @@ -445,14 +444,12 @@ def test_files_bug_component_different_matchers(self): def test_files_bug_component_final(self): reader = self.reader("files-info") - v = reader.files_info( - [ - "bug_component/final/foo", - "bug_component/final/Makefile.in", - "bug_component/final/subcomponent/Makefile.in", - "bug_component/final/subcomponent/bar", - ] - ) + v = reader.files_info([ + "bug_component/final/foo", + "bug_component/final/Makefile.in", + "bug_component/final/subcomponent/Makefile.in", + "bug_component/final/subcomponent/bar", + ]) self.assertEqual( v["bug_component/final/foo"]["BUG_COMPONENT"], @@ -479,17 +476,15 @@ def test_invalid_flavor(self): def test_schedules(self): reader = self.reader("schedules") - info = reader.files_info( - [ - "win.and.osx", - "somefile", - "foo.win", - "foo.osx", - "subd/aa.py", - "subd/yaml.py", - "subd/win.js", - ] - ) + info = reader.files_info([ + "win.and.osx", + "somefile", + "foo.win", + "foo.osx", + "subd/aa.py", + "subd/yaml.py", + "subd/win.js", + ]) # default: all exclusive, no inclusive self.assertEqual(info["somefile"]["SCHEDULES"].inclusive, []) self.assertEqual( diff --git a/python/mozbuild/mozbuild/test/frontend/test_sandbox.py b/python/mozbuild/mozbuild/test/frontend/test_sandbox.py index 6bddcf85df2ee..6f22b1e795224 100644 --- a/python/mozbuild/mozbuild/test/frontend/test_sandbox.py +++ b/python/mozbuild/mozbuild/test/frontend/test_sandbox.py @@ -25,11 +25,9 @@ class TestSandbox(unittest.TestCase): def sandbox(self): return Sandbox( - Context( - { - "DIRS": (list, list, None), - } - ) + Context({ + "DIRS": (list, list, None), + }) ) def test_exec_source_success(self): @@ -498,11 +496,9 @@ class Foo(int): def foo(a, b): return type(a), type(b) - FUNCTIONS.update( - { - "foo": (lambda self: foo, (Foo, int), ""), - } - ) + FUNCTIONS.update({ + "foo": (lambda self: foo, (Foo, int), ""), + }) try: sandbox = self.sandbox() diff --git a/python/mozbuild/mozbuild/test/test_confvars.py b/python/mozbuild/mozbuild/test/test_confvars.py index 401e44e66647f..191252bc71fbc 100644 --- a/python/mozbuild/mozbuild/test/test_confvars.py +++ b/python/mozbuild/mozbuild/test/test_confvars.py @@ -13,7 +13,6 @@ def TemporaryConfVars(): class TestContext(unittest.TestCase): - def loads(self, *lines): with NamedTemporaryFile("wt", delete=False) as ntf: ntf.writelines(lines) @@ -64,7 +63,7 @@ def test_parse_invalid_assign_in_trailing_comment(self): ) def test_parse_quoted_assignment(self): - confvars = self.loads("a='b'\n" "b=' c'\n" 'c=" \'c"\n') + confvars = self.loads("a='b'\nb=' c'\nc=\" 'c\"\n") self.assertEqual(confvars, {"a": "b", "b": " c", "c": " 'c"}) def test_parse_invalid_assignment(self): diff --git a/python/mozbuild/mozbuild/test/test_legacy_test.py b/python/mozbuild/mozbuild/test/test_legacy_test.py index 9a75599d1a90e..41fdfaaa6841c 100644 --- a/python/mozbuild/mozbuild/test/test_legacy_test.py +++ b/python/mozbuild/mozbuild/test/test_legacy_test.py @@ -22,9 +22,9 @@ def test_extra_legacy_tests(): for src, fd in repo.get_tracked_files_finder().find("**/moz.build"): if src in allowlist: continue - assert ( - b"LegacyTest(" not in fd.read() - ), f"LegacyTest used in {src}, please refrain and use another test kind." + assert b"LegacyTest(" not in fd.read(), ( + f"LegacyTest used in {src}, please refrain and use another test kind." + ) if __name__ == "__main__": diff --git a/python/mozbuild/mozbuild/test/test_line_endings.py b/python/mozbuild/mozbuild/test/test_line_endings.py index 4162eb3e2f025..f218497618392 100644 --- a/python/mozbuild/mozbuild/test/test_line_endings.py +++ b/python/mozbuild/mozbuild/test/test_line_endings.py @@ -26,17 +26,17 @@ def createFile(self, lineendings): self.f.flush() def testMac(self): - self.createFile([b"\x0D"] * 3) + self.createFile([b"\x0d"] * 3) self.pp.do_include(self.f.name) self.assertEqual(self.pp.out.getvalue(), "a\nb\nc\n") def testUnix(self): - self.createFile([b"\x0A"] * 3) + self.createFile([b"\x0a"] * 3) self.pp.do_include(self.f.name) self.assertEqual(self.pp.out.getvalue(), "a\nb\nc\n") def testWindows(self): - self.createFile([b"\x0D\x0A"] * 3) + self.createFile([b"\x0d\x0a"] * 3) self.pp.do_include(self.f.name) self.assertEqual(self.pp.out.getvalue(), "a\nb\nc\n") diff --git a/python/mozbuild/mozbuild/test/test_manifest.py b/python/mozbuild/mozbuild/test/test_manifest.py index abe4b67602bb8..d56c2a0aba5e8 100644 --- a/python/mozbuild/mozbuild/test/test_manifest.py +++ b/python/mozbuild/mozbuild/test/test_manifest.py @@ -43,11 +43,10 @@ def test_simple(self): "bugzilla": {"component": "Graphics", "product": "Core"}, } - self.process_test_vectors( - [ - ( - simple_dict, - b""" + self.process_test_vectors([ + ( + simple_dict, + b""" --- schema: 1 origin: @@ -63,10 +62,10 @@ def test_simple(self): product: Core component: Graphics """.strip(), - ), - ( - simple_dict, - b""" + ), + ( + simple_dict, + b""" schema: 1 origin: name: cairo @@ -81,32 +80,30 @@ def test_simple(self): product: Core component: Graphics """.strip(), - ), - ] - ) + ), + ]) # =========================================================================================== def test_updatebot(self): - self.process_test_vectors( - [ - ( - { - "schema": "1", - "origin": { - "description": "2D Graphics Library", - "license": ["MPL-1.1", "LGPL-2.1"], - "name": "cairo", - "release": "version 1.6.4", - "revision": "AA001122334455", - "url": "https://www.cairographics.org/", - }, - "bugzilla": {"component": "Graphics", "product": "Core"}, - "updatebot": { - "maintainer-phab": "tjr", - "maintainer-bz": "a@example.com", - }, + self.process_test_vectors([ + ( + { + "schema": "1", + "origin": { + "description": "2D Graphics Library", + "license": ["MPL-1.1", "LGPL-2.1"], + "name": "cairo", + "release": "version 1.6.4", + "revision": "AA001122334455", + "url": "https://www.cairographics.org/", }, - b""" + "bugzilla": {"component": "Graphics", "product": "Core"}, + "updatebot": { + "maintainer-phab": "tjr", + "maintainer-bz": "a@example.com", + }, + }, + b""" --- schema: 1 origin: @@ -125,26 +122,26 @@ def test_updatebot(self): maintainer-phab: tjr maintainer-bz: a@example.com """.strip(), - ), - # ------------------------------------------------- - ( - { - "schema": "1", - "origin": { - "description": "2D Graphics Library", - "license": ["MPL-1.1", "LGPL-2.1"], - "name": "cairo", - "release": "version 1.6.4", - "revision": "001122334455", - "url": "https://www.cairographics.org/", - }, - "bugzilla": {"component": "Graphics", "product": "Core"}, - "updatebot": { - "maintainer-phab": "tjr", - "maintainer-bz": "a@example.com", - }, + ), + # ------------------------------------------------- + ( + { + "schema": "1", + "origin": { + "description": "2D Graphics Library", + "license": ["MPL-1.1", "LGPL-2.1"], + "name": "cairo", + "release": "version 1.6.4", + "revision": "001122334455", + "url": "https://www.cairographics.org/", + }, + "bugzilla": {"component": "Graphics", "product": "Core"}, + "updatebot": { + "maintainer-phab": "tjr", + "maintainer-bz": "a@example.com", }, - b""" + }, + b""" --- schema: 1 origin: @@ -163,27 +160,27 @@ def test_updatebot(self): maintainer-phab: tjr maintainer-bz: a@example.com """.strip(), - ), - # ------------------------------------------------- - ( - { - "schema": "1", - "origin": { - "description": "2D Graphics Library", - "license": ["MPL-1.1", "LGPL-2.1"], - "name": "cairo", - "release": "version 1.6.4", - "revision": "001122334455", - "url": "https://www.cairographics.org/", - }, - "bugzilla": {"component": "Graphics", "product": "Core"}, - "updatebot": { - "try-preset": "foo", - "maintainer-phab": "tjr", - "maintainer-bz": "a@example.com", - }, + ), + # ------------------------------------------------- + ( + { + "schema": "1", + "origin": { + "description": "2D Graphics Library", + "license": ["MPL-1.1", "LGPL-2.1"], + "name": "cairo", + "release": "version 1.6.4", + "revision": "001122334455", + "url": "https://www.cairographics.org/", + }, + "bugzilla": {"component": "Graphics", "product": "Core"}, + "updatebot": { + "try-preset": "foo", + "maintainer-phab": "tjr", + "maintainer-bz": "a@example.com", }, - b""" + }, + b""" --- schema: 1 origin: @@ -203,32 +200,32 @@ def test_updatebot(self): maintainer-phab: tjr maintainer-bz: a@example.com """.strip(), - ), - # ------------------------------------------------- - ( - { - "schema": "1", - "origin": { - "description": "2D Graphics Library", - "license": ["MPL-1.1", "LGPL-2.1"], - "name": "cairo", - "release": "version 1.6.4", - "revision": "AA001122334455", - "url": "https://www.cairographics.org/", - }, - "bugzilla": {"component": "Graphics", "product": "Core"}, - "vendoring": { - "url": "https://example.com", - "source-hosting": "gitlab", - }, - "updatebot": { - "maintainer-phab": "tjr", - "maintainer-bz": "a@example.com", - "fuzzy-query": "!linux64", - "tasks": [{"type": "commit-alert"}], - }, + ), + # ------------------------------------------------- + ( + { + "schema": "1", + "origin": { + "description": "2D Graphics Library", + "license": ["MPL-1.1", "LGPL-2.1"], + "name": "cairo", + "release": "version 1.6.4", + "revision": "AA001122334455", + "url": "https://www.cairographics.org/", }, - b""" + "bugzilla": {"component": "Graphics", "product": "Core"}, + "vendoring": { + "url": "https://example.com", + "source-hosting": "gitlab", + }, + "updatebot": { + "maintainer-phab": "tjr", + "maintainer-bz": "a@example.com", + "fuzzy-query": "!linux64", + "tasks": [{"type": "commit-alert"}], + }, + }, + b""" --- schema: 1 origin: @@ -253,11 +250,11 @@ def test_updatebot(self): tasks: - type: commit-alert """.strip(), - ), - # ------------------------------------------------- - ( - "exception", - b""" + ), + # ------------------------------------------------- + ( + "exception", + b""" --- schema: 1 origin: @@ -283,32 +280,32 @@ def test_updatebot(self): tasks: - type: commit-alert """.strip(), - ), - # ------------------------------------------------- - ( - { - "schema": "1", - "origin": { - "description": "2D Graphics Library", - "license": ["MPL-1.1", "LGPL-2.1"], - "name": "cairo", - "release": "version 1.6.4", - "revision": "AA001122334455", - "url": "https://www.cairographics.org/", - }, - "bugzilla": {"component": "Graphics", "product": "Core"}, - "vendoring": { - "url": "https://example.com", - "source-hosting": "gitlab", - }, - "updatebot": { - "maintainer-phab": "tjr", - "maintainer-bz": "a@example.com", - "fuzzy-paths": ["dir1/", "dir2"], - "tasks": [{"type": "commit-alert"}], - }, + ), + # ------------------------------------------------- + ( + { + "schema": "1", + "origin": { + "description": "2D Graphics Library", + "license": ["MPL-1.1", "LGPL-2.1"], + "name": "cairo", + "release": "version 1.6.4", + "revision": "AA001122334455", + "url": "https://www.cairographics.org/", + }, + "bugzilla": {"component": "Graphics", "product": "Core"}, + "vendoring": { + "url": "https://example.com", + "source-hosting": "gitlab", }, - b""" + "updatebot": { + "maintainer-phab": "tjr", + "maintainer-bz": "a@example.com", + "fuzzy-paths": ["dir1/", "dir2"], + "tasks": [{"type": "commit-alert"}], + }, + }, + b""" --- schema: 1 origin: @@ -335,32 +332,32 @@ def test_updatebot(self): tasks: - type: commit-alert """.strip(), - ), - # ------------------------------------------------- - ( - { - "schema": "1", - "origin": { - "description": "2D Graphics Library", - "license": ["MPL-1.1", "LGPL-2.1"], - "name": "cairo", - "release": "version 1.6.4", - "revision": "AA001122334455", - "url": "https://www.cairographics.org/", - }, - "bugzilla": {"component": "Graphics", "product": "Core"}, - "vendoring": { - "url": "https://example.com", - "source-hosting": "gitlab", - }, - "updatebot": { - "maintainer-phab": "tjr", - "maintainer-bz": "a@example.com", - "fuzzy-paths": ["dir1/"], - "tasks": [{"type": "commit-alert"}], - }, + ), + # ------------------------------------------------- + ( + { + "schema": "1", + "origin": { + "description": "2D Graphics Library", + "license": ["MPL-1.1", "LGPL-2.1"], + "name": "cairo", + "release": "version 1.6.4", + "revision": "AA001122334455", + "url": "https://www.cairographics.org/", + }, + "bugzilla": {"component": "Graphics", "product": "Core"}, + "vendoring": { + "url": "https://example.com", + "source-hosting": "gitlab", + }, + "updatebot": { + "maintainer-phab": "tjr", + "maintainer-bz": "a@example.com", + "fuzzy-paths": ["dir1/"], + "tasks": [{"type": "commit-alert"}], }, - b""" + }, + b""" --- schema: 1 origin: @@ -385,43 +382,43 @@ def test_updatebot(self): tasks: - type: commit-alert """.strip(), - ), - # ------------------------------------------------- - ( - { - "schema": "1", - "origin": { - "description": "2D Graphics Library", - "license": ["MPL-1.1", "LGPL-2.1"], - "name": "cairo", - "release": "version 1.6.4", - "revision": "AA001122334455", - "url": "https://www.cairographics.org/", - }, - "bugzilla": {"component": "Graphics", "product": "Core"}, - "vendoring": { - "url": "https://example.com", - "source-hosting": "gitlab", - "tracking": "commit", - "flavor": "rust", - }, - "updatebot": { - "maintainer-phab": "tjr", - "maintainer-bz": "a@example.com", - "tasks": [ - {"type": "commit-alert", "frequency": "release"}, - { - "type": "vendoring", - "enabled": False, - "cc": ["b@example.com"], - "needinfo": ["c@example.com"], - "frequency": "1 weeks", - "platform": "windows", - }, - ], - }, + ), + # ------------------------------------------------- + ( + { + "schema": "1", + "origin": { + "description": "2D Graphics Library", + "license": ["MPL-1.1", "LGPL-2.1"], + "name": "cairo", + "release": "version 1.6.4", + "revision": "AA001122334455", + "url": "https://www.cairographics.org/", + }, + "bugzilla": {"component": "Graphics", "product": "Core"}, + "vendoring": { + "url": "https://example.com", + "source-hosting": "gitlab", + "tracking": "commit", + "flavor": "rust", + }, + "updatebot": { + "maintainer-phab": "tjr", + "maintainer-bz": "a@example.com", + "tasks": [ + {"type": "commit-alert", "frequency": "release"}, + { + "type": "vendoring", + "enabled": False, + "cc": ["b@example.com"], + "needinfo": ["c@example.com"], + "frequency": "1 weeks", + "platform": "windows", + }, + ], }, - b""" + }, + b""" --- schema: 1 origin: @@ -454,43 +451,43 @@ def test_updatebot(self): frequency: 1 weeks platform: windows """.strip(), - ), - # ------------------------------------------------- - ( - { - "schema": "1", - "origin": { - "description": "2D Graphics Library", - "license": ["MPL-1.1", "LGPL-2.1"], - "name": "cairo", - "release": "version 1.6.4", - "revision": "AA001122334455", - "url": "https://www.cairographics.org/", - }, - "bugzilla": {"component": "Graphics", "product": "Core"}, - "vendoring": { - "url": "https://example.com", - "source-hosting": "gitlab", - "tracking": "tag", - "flavor": "rust", - }, - "updatebot": { - "maintainer-phab": "tjr", - "maintainer-bz": "a@example.com", - "tasks": [ - {"type": "commit-alert", "frequency": "release"}, - { - "type": "vendoring", - "enabled": False, - "cc": ["b@example.com"], - "needinfo": ["c@example.com"], - "frequency": "1 weeks, 4 commits", - "platform": "windows", - }, - ], - }, + ), + # ------------------------------------------------- + ( + { + "schema": "1", + "origin": { + "description": "2D Graphics Library", + "license": ["MPL-1.1", "LGPL-2.1"], + "name": "cairo", + "release": "version 1.6.4", + "revision": "AA001122334455", + "url": "https://www.cairographics.org/", }, - b""" + "bugzilla": {"component": "Graphics", "product": "Core"}, + "vendoring": { + "url": "https://example.com", + "source-hosting": "gitlab", + "tracking": "tag", + "flavor": "rust", + }, + "updatebot": { + "maintainer-phab": "tjr", + "maintainer-bz": "a@example.com", + "tasks": [ + {"type": "commit-alert", "frequency": "release"}, + { + "type": "vendoring", + "enabled": False, + "cc": ["b@example.com"], + "needinfo": ["c@example.com"], + "frequency": "1 weeks, 4 commits", + "platform": "windows", + }, + ], + }, + }, + b""" --- schema: 1 origin: @@ -523,11 +520,11 @@ def test_updatebot(self): frequency: 1 weeks, 4 commits platform: windows """.strip(), - ), - # ------------------------------------------------- - ( - "exception", # rust flavor cannot use update-actions - b""" + ), + # ------------------------------------------------- + ( + "exception", # rust flavor cannot use update-actions + b""" --- schema: 1 origin: @@ -564,46 +561,46 @@ def test_updatebot(self): frequency: 1 weeks, 4 commits platform: windows """.strip(), - ), - # ------------------------------------------------- - ( - { - "schema": "1", - "origin": { - "description": "2D Graphics Library", - "license": ["MPL-1.1", "LGPL-2.1"], - "name": "cairo", - "release": "version 1.6.4", - "revision": "AA001122334455", - "url": "https://www.cairographics.org/", - }, - "bugzilla": {"component": "Graphics", "product": "Core"}, - "vendoring": { - "url": "https://example.com", - "source-hosting": "gitlab", - }, - "updatebot": { - "maintainer-phab": "tjr", - "maintainer-bz": "a@example.com", - "tasks": [ - { - "type": "vendoring", - "enabled": False, - "cc": ["b@example.com", "c@example.com"], - "needinfo": ["d@example.com", "e@example.com"], - "frequency": "every", - }, - { - "type": "commit-alert", - "filter": "none", - "source-extensions": [".c", ".cpp"], - "frequency": "2 weeks", - "platform": "linux", - }, - ], - }, + ), + # ------------------------------------------------- + ( + { + "schema": "1", + "origin": { + "description": "2D Graphics Library", + "license": ["MPL-1.1", "LGPL-2.1"], + "name": "cairo", + "release": "version 1.6.4", + "revision": "AA001122334455", + "url": "https://www.cairographics.org/", + }, + "bugzilla": {"component": "Graphics", "product": "Core"}, + "vendoring": { + "url": "https://example.com", + "source-hosting": "gitlab", }, - b""" + "updatebot": { + "maintainer-phab": "tjr", + "maintainer-bz": "a@example.com", + "tasks": [ + { + "type": "vendoring", + "enabled": False, + "cc": ["b@example.com", "c@example.com"], + "needinfo": ["d@example.com", "e@example.com"], + "frequency": "every", + }, + { + "type": "commit-alert", + "filter": "none", + "source-extensions": [".c", ".cpp"], + "frequency": "2 weeks", + "platform": "linux", + }, + ], + }, + }, + b""" --- schema: 1 origin: @@ -642,46 +639,46 @@ def test_updatebot(self): - .c - .cpp """.strip(), - ), - # ------------------------------------------------- - ( - { - "schema": "1", - "origin": { - "description": "2D Graphics Library", - "license": ["MPL-1.1", "LGPL-2.1"], - "name": "cairo", - "release": "version 1.6.4", - "revision": "AA001122334455", - "url": "https://www.cairographics.org/", - }, - "bugzilla": {"component": "Graphics", "product": "Core"}, - "vendoring": { - "url": "https://example.com", - "source-hosting": "gitlab", - }, - "updatebot": { - "maintainer-phab": "tjr", - "maintainer-bz": "a@example.com", - "tasks": [ - { - "type": "vendoring", - "enabled": False, - "cc": ["b@example.com", "c@example.com"], - "needinfo": ["d@example.com", "e@example.com"], - "frequency": "every", - }, - { - "type": "commit-alert", - "filter": "none", - "source-extensions": [".c", ".cpp"], - "frequency": "2 commits", - "platform": "linux", - }, - ], - }, + ), + # ------------------------------------------------- + ( + { + "schema": "1", + "origin": { + "description": "2D Graphics Library", + "license": ["MPL-1.1", "LGPL-2.1"], + "name": "cairo", + "release": "version 1.6.4", + "revision": "AA001122334455", + "url": "https://www.cairographics.org/", + }, + "bugzilla": {"component": "Graphics", "product": "Core"}, + "vendoring": { + "url": "https://example.com", + "source-hosting": "gitlab", + }, + "updatebot": { + "maintainer-phab": "tjr", + "maintainer-bz": "a@example.com", + "tasks": [ + { + "type": "vendoring", + "enabled": False, + "cc": ["b@example.com", "c@example.com"], + "needinfo": ["d@example.com", "e@example.com"], + "frequency": "every", + }, + { + "type": "commit-alert", + "filter": "none", + "source-extensions": [".c", ".cpp"], + "frequency": "2 commits", + "platform": "linux", + }, + ], }, - b""" + }, + b""" --- schema: 1 origin: @@ -720,47 +717,47 @@ def test_updatebot(self): - .c - .cpp """.strip(), - ), - # ------------------------------------------------- - ( - { - "schema": "1", - "origin": { - "description": "2D Graphics Library", - "license": ["MPL-1.1", "LGPL-2.1"], - "name": "cairo", - "release": "version 1.6.4", - "revision": "AA001122334455", - "url": "https://www.cairographics.org/", - }, - "bugzilla": {"component": "Graphics", "product": "Core"}, - "vendoring": { - "url": "https://example.com", - "source-hosting": "gitlab", - }, - "updatebot": { - "maintainer-phab": "tjr", - "maintainer-bz": "a@example.com", - "tasks": [ - { - "type": "vendoring", - "enabled": False, - "cc": ["b@example.com", "c@example.com"], - "needinfo": ["d@example.com", "e@example.com"], - "frequency": "every", - "blocking": "1234", - }, - { - "type": "commit-alert", - "filter": "none", - "source-extensions": [".c", ".cpp"], - "frequency": "2 commits", - "platform": "linux", - }, - ], - }, + ), + # ------------------------------------------------- + ( + { + "schema": "1", + "origin": { + "description": "2D Graphics Library", + "license": ["MPL-1.1", "LGPL-2.1"], + "name": "cairo", + "release": "version 1.6.4", + "revision": "AA001122334455", + "url": "https://www.cairographics.org/", }, - b""" + "bugzilla": {"component": "Graphics", "product": "Core"}, + "vendoring": { + "url": "https://example.com", + "source-hosting": "gitlab", + }, + "updatebot": { + "maintainer-phab": "tjr", + "maintainer-bz": "a@example.com", + "tasks": [ + { + "type": "vendoring", + "enabled": False, + "cc": ["b@example.com", "c@example.com"], + "needinfo": ["d@example.com", "e@example.com"], + "frequency": "every", + "blocking": "1234", + }, + { + "type": "commit-alert", + "filter": "none", + "source-extensions": [".c", ".cpp"], + "frequency": "2 commits", + "platform": "linux", + }, + ], + }, + }, + b""" --- schema: 1 origin: @@ -800,11 +797,11 @@ def test_updatebot(self): - .c - .cpp """.strip(), - ), - # ------------------------------------------------- - ( - "exception", - b""" + ), + # ------------------------------------------------- + ( + "exception", + b""" --- schema: 1 origin: @@ -845,30 +842,28 @@ def test_updatebot(self): - .c - .cpp """.strip(), - ), - # ------------------------------------------------- - ( - { - "schema": "1", - "origin": { - "license": ["MPL-1.1", "LGPL-2.1"], - "name": "cairo", - "description": "2D Graphics Library", - "url": "https://www.cairographics.org/", - "release": "version 1.6.4", - "revision": "AA001122334455", - }, - "bugzilla": {"component": "Graphics", "product": "Core"}, - "vendoring": { - "url": "https://example.com", - "source-hosting": "gitlab", - "flavor": "individual-files", - "individual-files": [ - {"upstream": "foo", "destination": "bar"} - ], - }, + ), + # ------------------------------------------------- + ( + { + "schema": "1", + "origin": { + "license": ["MPL-1.1", "LGPL-2.1"], + "name": "cairo", + "description": "2D Graphics Library", + "url": "https://www.cairographics.org/", + "release": "version 1.6.4", + "revision": "AA001122334455", + }, + "bugzilla": {"component": "Graphics", "product": "Core"}, + "vendoring": { + "url": "https://example.com", + "source-hosting": "gitlab", + "flavor": "individual-files", + "individual-files": [{"upstream": "foo", "destination": "bar"}], }, - b""" + }, + b""" --- schema: 1 origin: @@ -891,33 +886,31 @@ def test_updatebot(self): product: Core component: Graphics """.strip(), - ), - # ------------------------------------------------- - ( - { - "schema": "1", - "origin": { - "license": ["MPL-1.1", "LGPL-2.1"], - "name": "cairo", - "description": "2D Graphics Library", - "url": "https://www.cairographics.org/", - "release": "version 1.6.4", - "revision": "AA001122334455", - }, - "bugzilla": {"component": "Graphics", "product": "Core"}, - "vendoring": { - "url": "https://example.com", - "source-hosting": "gitlab", - "flavor": "individual-files", - "individual-files": [ - {"upstream": "foo", "destination": "bar"} - ], - "update-actions": [ - {"action": "move-file", "from": "foo", "to": "bar"} - ], - }, + ), + # ------------------------------------------------- + ( + { + "schema": "1", + "origin": { + "license": ["MPL-1.1", "LGPL-2.1"], + "name": "cairo", + "description": "2D Graphics Library", + "url": "https://www.cairographics.org/", + "release": "version 1.6.4", + "revision": "AA001122334455", }, - b""" + "bugzilla": {"component": "Graphics", "product": "Core"}, + "vendoring": { + "url": "https://example.com", + "source-hosting": "gitlab", + "flavor": "individual-files", + "individual-files": [{"upstream": "foo", "destination": "bar"}], + "update-actions": [ + {"action": "move-file", "from": "foo", "to": "bar"} + ], + }, + }, + b""" --- schema: 1 origin: @@ -944,33 +937,33 @@ def test_updatebot(self): product: Core component: Graphics """.strip(), - ), - # ------------------------------------------------- - ( - { - "schema": "1", - "origin": { - "license": ["MPL-1.1", "LGPL-2.1"], - "name": "cairo", - "description": "2D Graphics Library", - "url": "https://www.cairographics.org/", - "release": "version 1.6.4", - "revision": "AA001122334455", - }, - "bugzilla": {"component": "Graphics", "product": "Core"}, - "vendoring": { - "url": "https://example.com", - "source-hosting": "gitlab", - "flavor": "individual-files", - "individual-files-default-destination": "bar", - "individual-files-default-upstream": "foo", - "individual-files-list": ["bar", "foo"], - "update-actions": [ - {"action": "move-file", "from": "foo", "to": "bar"} - ], - }, + ), + # ------------------------------------------------- + ( + { + "schema": "1", + "origin": { + "license": ["MPL-1.1", "LGPL-2.1"], + "name": "cairo", + "description": "2D Graphics Library", + "url": "https://www.cairographics.org/", + "release": "version 1.6.4", + "revision": "AA001122334455", + }, + "bugzilla": {"component": "Graphics", "product": "Core"}, + "vendoring": { + "url": "https://example.com", + "source-hosting": "gitlab", + "flavor": "individual-files", + "individual-files-default-destination": "bar", + "individual-files-default-upstream": "foo", + "individual-files-list": ["bar", "foo"], + "update-actions": [ + {"action": "move-file", "from": "foo", "to": "bar"} + ], }, - b""" + }, + b""" --- schema: 1 origin: @@ -999,11 +992,11 @@ def test_updatebot(self): product: Core component: Graphics """.strip(), - ), - # ------------------------------------------------- - ( - "exception", # can't have both types of indidivudal-files list - b""" + ), + # ------------------------------------------------- + ( + "exception", # can't have both types of indidivudal-files list + b""" --- schema: 1 origin: @@ -1032,11 +1025,11 @@ def test_updatebot(self): product: Core component: Graphics """.strip(), - ), - # ------------------------------------------------- - ( - "exception", # can't have indidivudal-files-default-upstream - b""" + ), + # ------------------------------------------------- + ( + "exception", # can't have indidivudal-files-default-upstream + b""" --- schema: 1 origin: @@ -1064,11 +1057,11 @@ def test_updatebot(self): product: Core component: Graphics """.strip(), - ), - # ------------------------------------------------- - ( - "exception", # must have indidivudal-files-default-upstream - b""" + ), + # ------------------------------------------------- + ( + "exception", # must have indidivudal-files-default-upstream + b""" --- schema: 1 origin: @@ -1096,11 +1089,11 @@ def test_updatebot(self): product: Core component: Graphics """.strip(), - ), - # ------------------------------------------------- - ( - "exception", - b""" + ), + # ------------------------------------------------- + ( + "exception", + b""" --- schema: 1 origin: @@ -1124,11 +1117,11 @@ def test_updatebot(self): product: Core component: Graphics """.strip(), - ), - # ------------------------------------------------- - ( - "exception", - b""" + ), + # ------------------------------------------------- + ( + "exception", + b""" --- schema: 1 origin: @@ -1148,11 +1141,11 @@ def test_updatebot(self): product: Core component: Graphics """.strip(), - ), - # ------------------------------------------------- - ( - "exception", - b""" + ), + # ------------------------------------------------- + ( + "exception", + b""" --- schema: 1 origin: @@ -1175,11 +1168,11 @@ def test_updatebot(self): product: Core component: Graphics """.strip(), - ), - # ------------------------------------------------- - ( - "exception", - b""" + ), + # ------------------------------------------------- + ( + "exception", + b""" --- schema: 1 origin: @@ -1201,11 +1194,11 @@ def test_updatebot(self): product: Core component: Graphics """.strip(), - ), - # ------------------------------------------------- - ( - "exception", - b""" + ), + # ------------------------------------------------- + ( + "exception", + b""" --- schema: 1 origin: @@ -1245,11 +1238,11 @@ def test_updatebot(self): - .c - .cpp """.strip(), - ), - # ------------------------------------------------- - ( - "exception", - b""" + ), + # ------------------------------------------------- + ( + "exception", + b""" --- schema: 1 origin: @@ -1289,11 +1282,11 @@ def test_updatebot(self): - .c - .cpp """.strip(), - ), - # ------------------------------------------------- - ( - "exception", - b""" + ), + # ------------------------------------------------- + ( + "exception", + b""" --- schema: 1 origin: @@ -1332,11 +1325,11 @@ def test_updatebot(self): - .c - .cpp """.strip(), - ), - # ------------------------------------------------- - ( - "exception", - b""" + ), + # ------------------------------------------------- + ( + "exception", + b""" --- schema: 1 origin: @@ -1375,11 +1368,11 @@ def test_updatebot(self): - .c - .cpp """.strip(), - ), - # ------------------------------------------------- - ( - "exception", - b""" + ), + # ------------------------------------------------- + ( + "exception", + b""" --- schema: 1 origin: @@ -1419,11 +1412,11 @@ def test_updatebot(self): - .c - .cpp """.strip(), - ), - # ------------------------------------------------- - ( - "exception", - b""" + ), + # ------------------------------------------------- + ( + "exception", + b""" --- schema: 1 origin: @@ -1463,11 +1456,11 @@ def test_updatebot(self): - .c - .cpp """.strip(), - ), - # ------------------------------------------------- - ( - "exception", - b""" + ), + # ------------------------------------------------- + ( + "exception", + b""" --- schema: 1 origin: @@ -1506,11 +1499,11 @@ def test_updatebot(self): - .c - .cpp """.strip(), - ), - # ------------------------------------------------- - ( - "exception", - b""" + ), + # ------------------------------------------------- + ( + "exception", + b""" --- schema: 1 origin: @@ -1540,11 +1533,11 @@ def test_updatebot(self): - .c - .cpp """.strip(), - ), - # ------------------------------------------------- - ( - "exception", - b""" + ), + # ------------------------------------------------- + ( + "exception", + b""" --- schema: 1 origin: @@ -1576,11 +1569,11 @@ def test_updatebot(self): - .c - .cpp """.strip(), - ), - # ------------------------------------------------- - ( - "exception", - b""" + ), + # ------------------------------------------------- + ( + "exception", + b""" --- schema: 1 origin: @@ -1605,11 +1598,11 @@ def test_updatebot(self): - type: vendoring filter: none """.strip(), - ), - # ------------------------------------------------- - ( - "exception", - b""" + ), + # ------------------------------------------------- + ( + "exception", + b""" --- schema: 1 origin: @@ -1633,11 +1626,11 @@ def test_updatebot(self): tasks: - type: foo """.strip(), - ), - # ------------------------------------------------- - ( - "exception", - b""" + ), + # ------------------------------------------------- + ( + "exception", + b""" --- schema: 1 origin: @@ -1664,11 +1657,11 @@ def test_updatebot(self): - .c - .cpp """.strip(), - ), - # ------------------------------------------------- - ( - "exception", - b""" + ), + # ------------------------------------------------- + ( + "exception", + b""" --- schema: 1 origin: @@ -1693,10 +1686,10 @@ def test_updatebot(self): - type: commit-alert filter: hogwash """.strip(), - ), - ( - "exception", - b""" + ), + ( + "exception", + b""" --- schema: 1 origin: @@ -1729,10 +1722,10 @@ def test_updatebot(self): source-extensions: - .c - .cpp""".strip(), - ), - ( - "exception", - b""" + ), + ( + "exception", + b""" --- schema: 1 origin: @@ -1765,10 +1758,10 @@ def test_updatebot(self): source-extensions: - .c - .cpp""".strip(), - ), - ( - "exception", - b""" + ), + ( + "exception", + b""" --- schema: 1 origin: @@ -1801,10 +1794,10 @@ def test_updatebot(self): source-extensions: - .c - .cpp""".strip(), - ), - ( - "exception", - b""" + ), + ( + "exception", + b""" --- schema: 1 origin: @@ -1837,10 +1830,10 @@ def test_updatebot(self): source-extensions: - .c - .cpp""".strip(), - ), - ( - "exception", - b""" + ), + ( + "exception", + b""" --- schema: 1 origin: @@ -1865,9 +1858,8 @@ def test_updatebot(self): - type: commit-alert frequency: 0 weeks """.strip(), - ), - ] - ) + ), + ]) # =========================================================================================== def test_malformed(self): @@ -1898,22 +1890,21 @@ def test_json(self): load_moz_yaml(tf.name, require_license_file=False) def test_revision(self): - self.process_test_vectors( - [ - ( - { - "schema": "1", - "origin": { - "description": "2D Graphics Library", - "license": ["MPL-1.1", "LGPL-2.1"], - "name": "cairo", - "release": "version 1.6.4", - "revision": "v1.6.37", - "url": "https://www.cairographics.org/", - }, - "bugzilla": {"component": "Graphics", "product": "Core"}, + self.process_test_vectors([ + ( + { + "schema": "1", + "origin": { + "description": "2D Graphics Library", + "license": ["MPL-1.1", "LGPL-2.1"], + "name": "cairo", + "release": "version 1.6.4", + "revision": "v1.6.37", + "url": "https://www.cairographics.org/", }, - b""" + "bugzilla": {"component": "Graphics", "product": "Core"}, + }, + b""" --- schema: 1 origin: @@ -1928,10 +1919,10 @@ def test_revision(self): bugzilla: product: Core component: Graphics""".strip(), - ), - ( - "exception", - b""" + ), + ( + "exception", + b""" --- schema: 1 origin: @@ -1946,10 +1937,10 @@ def test_revision(self): bugzilla: product: Core component: Graphics""".strip(), - ), - ( - "exception", - b""" + ), + ( + "exception", + b""" --- schema: 1 origin: @@ -1964,10 +1955,10 @@ def test_revision(self): bugzilla: product: Core component: Graphics""".strip(), - ), - ( - "exception", - b""" + ), + ( + "exception", + b""" --- schema: 1 origin: @@ -1982,10 +1973,10 @@ def test_revision(self): bugzilla: product: Core component: Graphics""".strip(), - ), - ( - "exception", - b""" + ), + ( + "exception", + b""" --- schema: 1 origin: @@ -2000,10 +1991,10 @@ def test_revision(self): bugzilla: product: Core component: Graphics""".strip(), - ), - ( - "exception", - b""" + ), + ( + "exception", + b""" --- schema: 1 origin: @@ -2018,10 +2009,10 @@ def test_revision(self): bugzilla: product: Core component: Graphics""".strip(), - ), - ( - "exception", - b""" + ), + ( + "exception", + b""" --- schema: 1 origin: @@ -2046,10 +2037,10 @@ def test_revision(self): args: ['hi'] pattern: 'hi' """.strip(), - ), - ( - "exception", - b""" + ), + ( + "exception", + b""" --- schema: 1 origin: @@ -2072,9 +2063,8 @@ def test_revision(self): cwd: '{cwd}' args: ['hi'] """.strip(), - ), - ] - ) + ), + ]) if __name__ == "__main__": diff --git a/python/mozbuild/mozbuild/test/test_preprocessor.py b/python/mozbuild/mozbuild/test/test_preprocessor.py index edc546e8578ae..88ce026ae1b8b 100644 --- a/python/mozbuild/mozbuild/test/test_preprocessor.py +++ b/python/mozbuild/mozbuild/test/test_preprocessor.py @@ -34,15 +34,13 @@ def do_include_pass(self, content_lines): self.do_include_compare(content_lines, ["PASS"]) def test_conditional_if_0(self): - self.do_include_pass( - [ - "#if 0", - "FAIL", - "#else", - "PASS", - "#endif", - ] - ) + self.do_include_pass([ + "#if 0", + "FAIL", + "#else", + "PASS", + "#endif", + ]) def test_no_marker(self): lines = [ @@ -80,99 +78,83 @@ def test_number_value(self): ) def test_conditional_if_0_elif_1(self): - self.do_include_pass( - [ - "#if 0", - "#elif 1", - "PASS", - "#else", - "FAIL", - "#endif", - ] - ) + self.do_include_pass([ + "#if 0", + "#elif 1", + "PASS", + "#else", + "FAIL", + "#endif", + ]) def test_conditional_if_1(self): - self.do_include_pass( - [ - "#if 1", - "PASS", - "#else", - "FAIL", - "#endif", - ] - ) + self.do_include_pass([ + "#if 1", + "PASS", + "#else", + "FAIL", + "#endif", + ]) def test_conditional_if_0_or_1(self): - self.do_include_pass( - [ - "#if 0 || 1", - "PASS", - "#else", - "FAIL", - "#endif", - ] - ) + self.do_include_pass([ + "#if 0 || 1", + "PASS", + "#else", + "FAIL", + "#endif", + ]) def test_conditional_if_1_elif_1_else(self): - self.do_include_pass( - [ - "#if 1", - "PASS", - "#elif 1", - "FAIL", - "#else", - "FAIL", - "#endif", - ] - ) + self.do_include_pass([ + "#if 1", + "PASS", + "#elif 1", + "FAIL", + "#else", + "FAIL", + "#endif", + ]) def test_conditional_if_1_if_1(self): - self.do_include_pass( - [ - "#if 1", - "#if 1", - "PASS", - "#else", - "FAIL", - "#endif", - "#else", - "FAIL", - "#endif", - ] - ) + self.do_include_pass([ + "#if 1", + "#if 1", + "PASS", + "#else", + "FAIL", + "#endif", + "#else", + "FAIL", + "#endif", + ]) def test_conditional_not_0(self): - self.do_include_pass( - [ - "#if !0", - "PASS", - "#else", - "FAIL", - "#endif", - ] - ) + self.do_include_pass([ + "#if !0", + "PASS", + "#else", + "FAIL", + "#endif", + ]) def test_conditional_not_0_and_1(self): - self.do_include_pass( - [ - "#if !0 && !1", - "FAIL", - "#else", - "PASS", - "#endif", - ] - ) + self.do_include_pass([ + "#if !0 && !1", + "FAIL", + "#else", + "PASS", + "#endif", + ]) def test_conditional_not_1(self): - self.do_include_pass( - [ - "#if !1", - "FAIL", - "#else", - "PASS", - "#endif", - ] - ) + self.do_include_pass([ + "#if !1", + "FAIL", + "#else", + "PASS", + "#endif", + ]) def test_conditional_not_emptyval(self): self.do_include_compare( @@ -193,36 +175,30 @@ def test_conditional_not_emptyval(self): ) def test_conditional_not_nullval(self): - self.do_include_pass( - [ - "#define NULLVAL 0", - "#if !NULLVAL", - "PASS", - "#else", - "FAIL", - "#endif", - ] - ) + self.do_include_pass([ + "#define NULLVAL 0", + "#if !NULLVAL", + "PASS", + "#else", + "FAIL", + "#endif", + ]) def test_indentation(self): - self.do_include_pass( - [ - " #define NULLVAL 0", - " #if !NULLVAL", - "PASS", - " #else", - "FAIL", - " #endif", - ] - ) + self.do_include_pass([ + " #define NULLVAL 0", + " #if !NULLVAL", + "PASS", + " #else", + "FAIL", + " #endif", + ]) def test_expand(self): - self.do_include_pass( - [ - "#define ASVAR AS", - "#expand P__ASVAR__S", - ] - ) + self.do_include_pass([ + "#define ASVAR AS", + "#expand P__ASVAR__S", + ]) def test_undef_defined(self): self.do_include_compare( @@ -330,14 +306,12 @@ def test_filter_dumbComments_and_emptyLines(self): ) def test_filter_substitution(self): - self.do_include_pass( - [ - "#define VAR ASS", - "#filter substitution", - "P@VAR@", - "#unfilter substitution", - ] - ) + self.do_include_pass([ + "#define VAR ASS", + "#filter substitution", + "P@VAR@", + "#unfilter substitution", + ]) def test_error(self): with MockedOpen({"f": "#error spit this message out\n"}): @@ -361,265 +335,223 @@ def test_javascript_line(self): full = os.path.join(tmpdir, "javascript_line.js.in") with open(full, "w") as fh: fh.write( - "\n".join( - [ - "// Line 1", - "#if 0", - "// line 3", - "#endif", - "// line 5", - "# comment", - "// line 7", - "// line 8", - "// line 9", - "# another comment", - "// line 11", - "#define LINE 1", - "// line 13, given line number overwritten with 2", - "", - ] - ) + "\n".join([ + "// Line 1", + "#if 0", + "// line 3", + "#endif", + "// line 5", + "# comment", + "// line 7", + "// line 8", + "// line 9", + "# another comment", + "// line 11", + "#define LINE 1", + "// line 13, given line number overwritten with 2", + "", + ]) ) self.pp.do_include(full) - out = "\n".join( - [ - "// Line 1", - '//@line 5 "CWDjavascript_line.js.in"', - "// line 5", - '//@line 7 "CWDjavascript_line.js.in"', - "// line 7", - "// line 8", - "// line 9", - '//@line 11 "CWDjavascript_line.js.in"', - "// line 11", - '//@line 2 "CWDjavascript_line.js.in"', - "// line 13, given line number overwritten with 2", - "", - ] - ) + out = "\n".join([ + "// Line 1", + '//@line 5 "CWDjavascript_line.js.in"', + "// line 5", + '//@line 7 "CWDjavascript_line.js.in"', + "// line 7", + "// line 8", + "// line 9", + '//@line 11 "CWDjavascript_line.js.in"', + "// line 11", + '//@line 2 "CWDjavascript_line.js.in"', + "// line 13, given line number overwritten with 2", + "", + ]) out = out.replace("CWD", tmpdir + os.path.sep) self.assertEqual(self.pp.out.getvalue(), out) finally: shutil.rmtree(tmpdir) def test_literal(self): - self.do_include_pass( - [ - "#literal PASS", - ] - ) + self.do_include_pass([ + "#literal PASS", + ]) def test_var_directory(self): - self.do_include_pass( - [ - "#ifdef DIRECTORY", - "PASS", - "#else", - "FAIL", - "#endif", - ] - ) + self.do_include_pass([ + "#ifdef DIRECTORY", + "PASS", + "#else", + "FAIL", + "#endif", + ]) def test_var_file(self): - self.do_include_pass( - [ - "#ifdef FILE", - "PASS", - "#else", - "FAIL", - "#endif", - ] - ) + self.do_include_pass([ + "#ifdef FILE", + "PASS", + "#else", + "FAIL", + "#endif", + ]) def test_var_if_0(self): - self.do_include_pass( - [ - "#define VAR 0", - "#if VAR", - "FAIL", - "#else", - "PASS", - "#endif", - ] - ) + self.do_include_pass([ + "#define VAR 0", + "#if VAR", + "FAIL", + "#else", + "PASS", + "#endif", + ]) def test_var_if_0_elifdef(self): - self.do_include_pass( - [ - "#if 0", - "#elifdef FILE", - "PASS", - "#else", - "FAIL", - "#endif", - ] - ) + self.do_include_pass([ + "#if 0", + "#elifdef FILE", + "PASS", + "#else", + "FAIL", + "#endif", + ]) def test_var_if_0_elifndef(self): - self.do_include_pass( - [ - "#if 0", - "#elifndef VAR", - "PASS", - "#else", - "FAIL", - "#endif", - ] - ) + self.do_include_pass([ + "#if 0", + "#elifndef VAR", + "PASS", + "#else", + "FAIL", + "#endif", + ]) def test_var_ifdef_0(self): - self.do_include_pass( - [ - "#define VAR 0", - "#ifdef VAR", - "PASS", - "#else", - "FAIL", - "#endif", - ] - ) + self.do_include_pass([ + "#define VAR 0", + "#ifdef VAR", + "PASS", + "#else", + "FAIL", + "#endif", + ]) def test_var_ifdef_1_or_undef(self): - self.do_include_pass( - [ - "#define FOO 1", - "#if defined(FOO) || defined(BAR)", - "PASS", - "#else", - "FAIL", - "#endif", - ] - ) + self.do_include_pass([ + "#define FOO 1", + "#if defined(FOO) || defined(BAR)", + "PASS", + "#else", + "FAIL", + "#endif", + ]) def test_var_ifdef_undef(self): - self.do_include_pass( - [ - "#define VAR 0", - "#undef VAR", - "#ifdef VAR", - "FAIL", - "#else", - "PASS", - "#endif", - ] - ) + self.do_include_pass([ + "#define VAR 0", + "#undef VAR", + "#ifdef VAR", + "FAIL", + "#else", + "PASS", + "#endif", + ]) def test_var_ifndef_0(self): - self.do_include_pass( - [ - "#define VAR 0", - "#ifndef VAR", - "FAIL", - "#else", - "PASS", - "#endif", - ] - ) + self.do_include_pass([ + "#define VAR 0", + "#ifndef VAR", + "FAIL", + "#else", + "PASS", + "#endif", + ]) def test_var_ifndef_0_and_undef(self): - self.do_include_pass( - [ - "#define FOO 0", - "#if !defined(FOO) && !defined(BAR)", - "FAIL", - "#else", - "PASS", - "#endif", - ] - ) + self.do_include_pass([ + "#define FOO 0", + "#if !defined(FOO) && !defined(BAR)", + "FAIL", + "#else", + "PASS", + "#endif", + ]) def test_var_ifndef_undef(self): - self.do_include_pass( - [ - "#define VAR 0", - "#undef VAR", - "#ifndef VAR", - "PASS", - "#else", - "FAIL", - "#endif", - ] - ) + self.do_include_pass([ + "#define VAR 0", + "#undef VAR", + "#ifndef VAR", + "PASS", + "#else", + "FAIL", + "#endif", + ]) def test_var_line(self): - self.do_include_pass( - [ - "#ifdef LINE", - "PASS", - "#else", - "FAIL", - "#endif", - ] - ) + self.do_include_pass([ + "#ifdef LINE", + "PASS", + "#else", + "FAIL", + "#endif", + ]) def test_filterDefine(self): - self.do_include_pass( - [ - "#filter substitution", - "#define VAR AS", - "#define VAR2 P@VAR@", - "@VAR2@S", - ] - ) + self.do_include_pass([ + "#filter substitution", + "#define VAR AS", + "#define VAR2 P@VAR@", + "@VAR2@S", + ]) def test_number_value_equals(self): - self.do_include_pass( - [ - "#define FOO 1000", - "#if FOO == 1000", - "PASS", - "#else", - "FAIL", - "#endif", - ] - ) + self.do_include_pass([ + "#define FOO 1000", + "#if FOO == 1000", + "PASS", + "#else", + "FAIL", + "#endif", + ]) def test_default_defines(self): self.pp.handleCommandLine(["-DFOO"]) - self.do_include_pass( - [ - "#if FOO == 1", - "PASS", - "#else", - "FAIL", - ] - ) + self.do_include_pass([ + "#if FOO == 1", + "PASS", + "#else", + "FAIL", + ]) def test_number_value_equals_defines(self): self.pp.handleCommandLine(["-DFOO=1000"]) - self.do_include_pass( - [ - "#if FOO == 1000", - "PASS", - "#else", - "FAIL", - ] - ) + self.do_include_pass([ + "#if FOO == 1000", + "PASS", + "#else", + "FAIL", + ]) def test_octal_value_equals(self): - self.do_include_pass( - [ - "#define FOO 0100", - "#if FOO == 0100", - "PASS", - "#else", - "FAIL", - "#endif", - ] - ) + self.do_include_pass([ + "#define FOO 0100", + "#if FOO == 0100", + "PASS", + "#else", + "FAIL", + "#endif", + ]) def test_octal_value_equals_defines(self): self.pp.handleCommandLine(["-DFOO=0100"]) - self.do_include_pass( - [ - "#if FOO == 0100", - "PASS", - "#else", - "FAIL", - "#endif", - ] - ) + self.do_include_pass([ + "#if FOO == 0100", + "PASS", + "#else", + "FAIL", + "#endif", + ]) def test_value_quoted_expansion(self): """ @@ -647,27 +579,23 @@ def test_octal_value_quoted_expansion(self): def test_number_value_not_equals_quoted_defines(self): self.pp.handleCommandLine(['-DFOO="1000"']) - self.do_include_pass( - [ - "#if FOO == 1000", - "FAIL", - "#else", - "PASS", - "#endif", - ] - ) + self.do_include_pass([ + "#if FOO == 1000", + "FAIL", + "#else", + "PASS", + "#endif", + ]) def test_octal_value_not_equals_quoted_defines(self): self.pp.handleCommandLine(['-DFOO="0100"']) - self.do_include_pass( - [ - "#if FOO == 0100", - "FAIL", - "#else", - "PASS", - "#endif", - ] - ) + self.do_include_pass([ + "#if FOO == 0100", + "FAIL", + "#else", + "PASS", + "#endif", + ]) def test_undefined_variable(self): with MockedOpen({"f": "#filter substitution\n@foo@"}): @@ -677,29 +605,23 @@ def test_undefined_variable(self): def test_include(self): files = { - "foo/test": "\n".join( - [ - "#define foo foobarbaz", - "#include @inc@", - "@bar@", - "", - ] - ), - "bar": "\n".join( - [ - "#define bar barfoobaz", - "@foo@", - "", - ] - ), - "f": "\n".join( - [ - "#filter substitution", - "#define inc ../bar", - "#include foo/test", - "", - ] - ), + "foo/test": "\n".join([ + "#define foo foobarbaz", + "#include @inc@", + "@bar@", + "", + ]), + "bar": "\n".join([ + "#define bar barfoobaz", + "@foo@", + "", + ]), + "f": "\n".join([ + "#filter substitution", + "#define inc ../bar", + "#include foo/test", + "", + ]), } with MockedOpen(files): @@ -708,41 +630,33 @@ def test_include(self): def test_include_line(self): files = { - "srcdir/test.js": "\n".join( - [ - "#define foo foobarbaz", - "#include @inc@", - "@bar@", - "", - ] - ), - "srcdir/bar.js": "\n".join( - [ - "#define bar barfoobaz", - "@foo@", - "", - ] - ), - "srcdir/foo.js": "\n".join( - [ - "bazfoobar", - "#include bar.js", - "bazbarfoo", - "", - ] - ), + "srcdir/test.js": "\n".join([ + "#define foo foobarbaz", + "#include @inc@", + "@bar@", + "", + ]), + "srcdir/bar.js": "\n".join([ + "#define bar barfoobaz", + "@foo@", + "", + ]), + "srcdir/foo.js": "\n".join([ + "bazfoobar", + "#include bar.js", + "bazbarfoo", + "", + ]), "objdir/baz.js": "baz\n", - "srcdir/f.js": "\n".join( - [ - "#include foo.js", - "#filter substitution", - "#define inc bar.js", - "#include test.js", - "#include ../objdir/baz.js", - "fin", - "", - ] - ), + "srcdir/f.js": "\n".join([ + "#include foo.js", + "#filter substitution", + "#define inc bar.js", + "#include test.js", + "#include ../objdir/baz.js", + "fin", + "", + ]), } preprocessed = ( @@ -819,13 +733,11 @@ def test_invalid_ifdef(self): self.assertEqual(e.exception.key, "INVALID_VAR") # Trailing whitespaces, while not nice, shouldn't be an error. - self.do_include_pass( - [ - "#ifndef FOO ", - "PASS", - "#endif", - ] - ) + self.do_include_pass([ + "#ifndef FOO ", + "PASS", + "#endif", + ]) if __name__ == "__main__": diff --git a/python/mozbuild/mozbuild/test/test_pythonutil.py b/python/mozbuild/mozbuild/test/test_pythonutil.py index 6ebb5cc46e275..02438dd8f8235 100644 --- a/python/mozbuild/mozbuild/test/test_pythonutil.py +++ b/python/mozbuild/mozbuild/test/test_pythonutil.py @@ -12,12 +12,10 @@ def test_iter_modules_in_path(): tests_path = os.path.normcase(os.path.dirname(__file__)) paths = list(iter_modules_in_path(tests_path)) - assert set(paths) == set( - [ - os.path.join(os.path.abspath(tests_path), "__init__.py"), - os.path.join(os.path.abspath(tests_path), "test_pythonutil.py"), - ] - ) + assert set(paths) == set([ + os.path.join(os.path.abspath(tests_path), "__init__.py"), + os.path.join(os.path.abspath(tests_path), "test_pythonutil.py"), + ]) if __name__ == "__main__": diff --git a/python/mozbuild/mozbuild/test/test_telemetry_settings.py b/python/mozbuild/mozbuild/test/test_telemetry_settings.py index c170e56de1bc9..92e52292d0810 100644 --- a/python/mozbuild/mozbuild/test/test_telemetry_settings.py +++ b/python/mozbuild/mozbuild/test/test_telemetry_settings.py @@ -101,9 +101,7 @@ def _initialize_telemetry(settings, is_employee, contributor_prompt_response=Non return_value=contributor_prompt_response, ) as prompt_mock, mock.patch( "subprocess.run", return_value=Mock(returncode=0) - ), mock.patch( - "mach.config.ConfigSettings" - ), mock.patch( + ), mock.patch("mach.config.ConfigSettings"), mock.patch( "mach.telemetry.record_is_employee_telemetry_setting" ): initialize_telemetry_setting(settings, "", "") @@ -170,9 +168,7 @@ def mock_and_run(is_employee_bugzilla, is_employee_vcs): return_value=is_employee_bugzilla, ), mock.patch( "mach.telemetry.resolve_is_employee_by_vcs", return_value=is_employee_vcs - ), mock.patch( - "mach.telemetry.record_is_employee_telemetry_setting" - ): + ), mock.patch("mach.telemetry.record_is_employee_telemetry_setting"): fake_settings = Mock() fake_settings.mach_telemetry.is_employee = None return resolve_is_employee(None, str(tmpdir), fake_settings) @@ -196,9 +192,7 @@ def test_resolve_is_employee_no_cache_when_unknown(tmpdir, monkeypatch): return_value=None, ), mock.patch( "mach.telemetry.resolve_is_employee_by_vcs", return_value=None - ), mock.patch( - "mach.telemetry.record_is_employee_telemetry_setting" - ) as record_mock: + ), mock.patch("mach.telemetry.record_is_employee_telemetry_setting") as record_mock: fake_settings = Mock() fake_settings.mach_telemetry.is_employee = None result = resolve_is_employee(None, str(tmpdir), fake_settings) diff --git a/python/mozbuild/mozbuild/test/test_util.py b/python/mozbuild/mozbuild/test/test_util.py index 0467ff1cf9bd8..659f0a5a6fa5f 100644 --- a/python/mozbuild/mozbuild/test/test_util.py +++ b/python/mozbuild/mozbuild/test/test_util.py @@ -447,12 +447,10 @@ def test_iadd(self): class TestStrictOrderingOnAppendListWithFlagsFactory(unittest.TestCase): def test_strict_ordering_on_append_list_with_flags_factory(self): - cls = StrictOrderingOnAppendListWithFlagsFactory( - { - "foo": bool, - "bar": int, - } - ) + cls = StrictOrderingOnAppendListWithFlagsFactory({ + "foo": bool, + "bar": int, + }) l = cls() l += ["a", "b"] diff --git a/python/mozbuild/mozbuild/test/test_vendor.py b/python/mozbuild/mozbuild/test/test_vendor.py index 07ba0883377bc..d329d784d8357 100644 --- a/python/mozbuild/mozbuild/test/test_vendor.py +++ b/python/mozbuild/mozbuild/test/test_vendor.py @@ -32,16 +32,14 @@ def test_up_to_date_vendor(): # Verify that re-vendoring did not cause file changes. # Note that we don't want hg-ignored generated files # to bust the diff, so we exclude them (pycache, egg-info). - subprocess.check_call( - [ - "diff", - "-r", - os.path.join(topsrcdir, os.path.join("third_party", "python")), - os.path.join(work_dir, os.path.join("third_party", "python")), - "--exclude=__pycache__", - "--strip-trailing-cr", - ] - ) + subprocess.check_call([ + "diff", + "-r", + os.path.join(topsrcdir, os.path.join("third_party", "python")), + os.path.join(work_dir, os.path.join("third_party", "python")), + "--exclude=__pycache__", + "--strip-trailing-cr", + ]) if __name__ == "__main__": diff --git a/python/mozbuild/mozbuild/testing.py b/python/mozbuild/mozbuild/testing.py index 2b0cdb2684930..dbab68472bfc8 100644 --- a/python/mozbuild/mozbuild/testing.py +++ b/python/mozbuild/mozbuild/testing.py @@ -152,9 +152,10 @@ def convert_support_files(self, test, install_root, manifest_dir, out_dir): full = mozpath.normpath( mozpath.join(manifest_dir, mozpath.basename(pattern)) ) - info.installs.append( - (full, mozpath.join(install_root, pattern[1:])) - ) + info.installs.append(( + full, + mozpath.join(install_root, pattern[1:]), + )) else: full = mozpath.normpath(mozpath.join(manifest_dir, pattern)) dest_path = mozpath.join(out_dir, pattern) diff --git a/python/mozbuild/mozbuild/util.py b/python/mozbuild/mozbuild/util.py index 31e536bcb08b2..6943394cbc8f9 100644 --- a/python/mozbuild/mozbuild/util.py +++ b/python/mozbuild/mozbuild/util.py @@ -411,11 +411,9 @@ def extend(self, l): def __setitem__(self, key, val): if isinstance(key, slice): if not isinstance(val, list): - raise ValueError( - "List can only be sliced with other list " "instances." - ) + raise ValueError("List can only be sliced with other list instances.") if key.step: - raise ValueError("List cannot be sliced with a nonzero step " "value") + raise ValueError("List cannot be sliced with a nonzero step value") return super().__setitem__(key, val) return super().__setitem__(key, val) diff --git a/python/mozbuild/mozbuild/vendor/host_git.py b/python/mozbuild/mozbuild/vendor/host_git.py index 90f5125422b16..bcf09e5a680bb 100644 --- a/python/mozbuild/mozbuild/vendor/host_git.py +++ b/python/mozbuild/mozbuild/vendor/host_git.py @@ -13,9 +13,12 @@ class GitHost(BaseHost): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.workdir = tempfile.TemporaryDirectory(suffix="." + self.repo_url.netloc) - subprocess.check_call( - ["git", "clone", self.repo_url.geturl(), self.workdir.name] - ) + subprocess.check_call([ + "git", + "clone", + self.repo_url.geturl(), + self.workdir.name, + ]) def upstream_commit(self, revision): sha = subprocess.check_output( diff --git a/python/mozbuild/mozbuild/vendor/host_github.py b/python/mozbuild/mozbuild/vendor/host_github.py index 9300585f7107d..e99eef64a84ba 100644 --- a/python/mozbuild/mozbuild/vendor/host_github.py +++ b/python/mozbuild/mozbuild/vendor/host_github.py @@ -22,9 +22,11 @@ def upstream_commit(self, revision): return (info["sha"], info["commit"]["committer"]["date"]) def upstream_snapshot(self, revision): - return "/".join( - [self.manifest["vendoring"]["url"], "archive", revision + ".tar.gz"] - ) + return "/".join([ + self.manifest["vendoring"]["url"], + "archive", + revision + ".tar.gz", + ]) def upstream_path_to_file(self, revision, filepath): repo = self.repo_url.path[1:] diff --git a/python/mozbuild/mozbuild/vendor/host_gitlab.py b/python/mozbuild/mozbuild/vendor/host_gitlab.py index 8bfc3ddc79810..33b1d8c3d6fe7 100644 --- a/python/mozbuild/mozbuild/vendor/host_gitlab.py +++ b/python/mozbuild/mozbuild/vendor/host_gitlab.py @@ -21,6 +21,9 @@ def upstream_commit(self, revision): return (info["id"], info["committed_date"]) def upstream_snapshot(self, revision): - return "/".join( - [self.manifest["vendoring"]["url"], "-", "archive", revision + ".tar.gz"] - ) + return "/".join([ + self.manifest["vendoring"]["url"], + "-", + "archive", + revision + ".tar.gz", + ]) diff --git a/python/mozbuild/mozbuild/vendor/host_googlesource.py b/python/mozbuild/mozbuild/vendor/host_googlesource.py index 9b5e91579fdf5..0fe3b88f60ae6 100644 --- a/python/mozbuild/mozbuild/vendor/host_googlesource.py +++ b/python/mozbuild/mozbuild/vendor/host_googlesource.py @@ -12,9 +12,11 @@ class GoogleSourceHost(BaseHost): def upstream_commit(self, revision): """Query for a git commit and timestamp.""" - url = "/".join( - [self.manifest["vendoring"]["url"], "+", revision + "?format=JSON"] - ) + url = "/".join([ + self.manifest["vendoring"]["url"], + "+", + revision + "?format=JSON", + ]) req = requests.get(url) req.raise_for_status() try: @@ -29,9 +31,11 @@ def upstream_commit(self, revision): return (info["commit"], info["committer"]["time"]) def upstream_snapshot(self, revision): - return "/".join( - [self.manifest["vendoring"]["url"], "+archive", revision + ".tar.gz"] - ) + return "/".join([ + self.manifest["vendoring"]["url"], + "+archive", + revision + ".tar.gz", + ]) def upstream_path_to_file(self, revision, filepath): return ( diff --git a/python/mozbuild/mozbuild/vendor/mach_commands.py b/python/mozbuild/mozbuild/vendor/mach_commands.py index 4cae04c1fa8e4..5c91582b96927 100644 --- a/python/mozbuild/mozbuild/vendor/mach_commands.py +++ b/python/mozbuild/mozbuild/vendor/mach_commands.py @@ -178,9 +178,7 @@ def check_modified_files(command_context): {files} Please commit or stash these changes before vendoring, or re-run with `--ignore-modified`. -""".format( - files="\n".join(sorted(modified)) - ), +""".format(files="\n".join(sorted(modified))), ) sys.exit(1) diff --git a/python/mozbuild/mozbuild/vendor/moz_yaml.py b/python/mozbuild/mozbuild/vendor/moz_yaml.py index 38119c4005353..2a9f19846277f 100644 --- a/python/mozbuild/mozbuild/vendor/moz_yaml.py +++ b/python/mozbuild/mozbuild/vendor/moz_yaml.py @@ -152,93 +152,91 @@ def _schema_1(): ], ) - return Schema( - { - Required("schema"): "1", - Required("bugzilla"): { - Required("product"): All(str, Length(min=1)), - Required("component"): All(str, Length(min=1)), - }, - "origin": { - Required("name"): All(str, Length(min=1)), - Required("description"): All(str, Length(min=1)), - "notes": All(str, Length(min=1)), - Required("url"): FqdnUrl(), - Required("license"): Msg(License(), msg="Unsupported License"), - "license-file": All(str, Length(min=1)), - Required("release"): All(str, Length(min=1)), - # The following regex defines a valid git reference - # The first group [^ ~^:?*[\]] matches 0 or more times anything - # that isn't a Space, ~, ^, :, ?, *, or ] - # The second group [^ ~^:?*[\]\.]+ matches 1 or more times - # anything that isn't a Space, ~, ^, :, ?, *, [, ], or . - "revision": Match(r"^[^ ~^:?*[\]]*[^ ~^:?*[\]\.]+$"), - }, - "updatebot": { - Required("maintainer-phab"): All(str, Length(min=1)), - Required("maintainer-bz"): All(str, Length(min=1)), - "try-preset": All(str, Length(min=1)), - "fuzzy-query": All(str, Length(min=1)), - "fuzzy-paths": All([str], Length(min=1)), - "tasks": All( - UpdatebotTasks(), - [ - { - Required("type"): In( - ["vendoring", "commit-alert"], - msg="Invalid type specified in tasks", - ), - "branch": All(str, Length(min=1)), - "enabled": Boolean(), - "cc": Unique([str]), - "needinfo": Unique([str]), - "filter": In( - ["none", "security", "source-extensions"], - msg="Invalid filter value specified in tasks", - ), - "source-extensions": Unique([str]), - "blocking": Match(r"^[0-9]+$"), - "frequency": Match( - r"^(every|release|[1-9][0-9]* weeks?|[1-9][0-9]* commits?|" - + r"[1-9][0-9]* weeks?, ?[1-9][0-9]* commits?)$" - ), - "platform": Match(r"^(windows|linux)$"), - } - ], - ), - }, - "vendoring": { - Required("url"): FqdnUrl(), - Required("source-hosting"): All( - str, - Length(min=1), - In(VALID_SOURCE_HOSTS, msg="Unsupported Source Hosting"), - ), - "source-host-path": str, - "tracking": Match(r"^(commit|tag)$"), - "release-artifact": All(str, Length(min=1)), - "flavor": Match(r"^(regular|rust|individual-files)$"), - "skip-vendoring-steps": Unique([str]), - "vendor-directory": All(str, Length(min=1)), - "patches": Unique([str]), - "keep": Unique([str]), - "exclude": Unique([str]), - "include": Unique([str]), - "generated": Unique([str]), - "individual-files": [ + return Schema({ + Required("schema"): "1", + Required("bugzilla"): { + Required("product"): All(str, Length(min=1)), + Required("component"): All(str, Length(min=1)), + }, + "origin": { + Required("name"): All(str, Length(min=1)), + Required("description"): All(str, Length(min=1)), + "notes": All(str, Length(min=1)), + Required("url"): FqdnUrl(), + Required("license"): Msg(License(), msg="Unsupported License"), + "license-file": All(str, Length(min=1)), + Required("release"): All(str, Length(min=1)), + # The following regex defines a valid git reference + # The first group [^ ~^:?*[\]] matches 0 or more times anything + # that isn't a Space, ~, ^, :, ?, *, or ] + # The second group [^ ~^:?*[\]\.]+ matches 1 or more times + # anything that isn't a Space, ~, ^, :, ?, *, [, ], or . + "revision": Match(r"^[^ ~^:?*[\]]*[^ ~^:?*[\]\.]+$"), + }, + "updatebot": { + Required("maintainer-phab"): All(str, Length(min=1)), + Required("maintainer-bz"): All(str, Length(min=1)), + "try-preset": All(str, Length(min=1)), + "fuzzy-query": All(str, Length(min=1)), + "fuzzy-paths": All([str], Length(min=1)), + "tasks": All( + UpdatebotTasks(), + [ { - Required("upstream"): All(str, Length(min=1)), - Required("destination"): All(str, Length(min=1)), + Required("type"): In( + ["vendoring", "commit-alert"], + msg="Invalid type specified in tasks", + ), + "branch": All(str, Length(min=1)), + "enabled": Boolean(), + "cc": Unique([str]), + "needinfo": Unique([str]), + "filter": In( + ["none", "security", "source-extensions"], + msg="Invalid filter value specified in tasks", + ), + "source-extensions": Unique([str]), + "blocking": Match(r"^[0-9]+$"), + "frequency": Match( + r"^(every|release|[1-9][0-9]* weeks?|[1-9][0-9]* commits?|" + + r"[1-9][0-9]* weeks?, ?[1-9][0-9]* commits?)$" + ), + "platform": Match(r"^(windows|linux)$"), } ], - "individual-files-default-upstream": str, - "individual-files-default-destination": All(str, Length(min=1)), - "individual-files-list": Unique([str]), - "update-actions": actions_schema, - "post-patch-actions": actions_schema, - }, - } - ) + ), + }, + "vendoring": { + Required("url"): FqdnUrl(), + Required("source-hosting"): All( + str, + Length(min=1), + In(VALID_SOURCE_HOSTS, msg="Unsupported Source Hosting"), + ), + "source-host-path": str, + "tracking": Match(r"^(commit|tag)$"), + "release-artifact": All(str, Length(min=1)), + "flavor": Match(r"^(regular|rust|individual-files)$"), + "skip-vendoring-steps": Unique([str]), + "vendor-directory": All(str, Length(min=1)), + "patches": Unique([str]), + "keep": Unique([str]), + "exclude": Unique([str]), + "include": Unique([str]), + "generated": Unique([str]), + "individual-files": [ + { + Required("upstream"): All(str, Length(min=1)), + Required("destination"): All(str, Length(min=1)), + } + ], + "individual-files-default-upstream": str, + "individual-files-default-destination": All(str, Length(min=1)), + "individual-files-list": Unique([str]), + "update-actions": actions_schema, + "post-patch-actions": actions_schema, + }, + }) def _schema_1_additional(filename, manifest, require_license_file=True): diff --git a/python/mozbuild/mozbuild/vendor/rewrite_mozbuild.py b/python/mozbuild/mozbuild/vendor/rewrite_mozbuild.py index 85308c87f92c2..58b86b681e6be 100644 --- a/python/mozbuild/mozbuild/vendor/rewrite_mozbuild.py +++ b/python/mozbuild/mozbuild/vendor/rewrite_mozbuild.py @@ -434,23 +434,21 @@ def mozbuild_file_to_source_assignments(normalized_mozbuild_filename, assignment ) ) ] - source_assignment_nodes.extend( - [ - node - for node in ast.walk(root) - if isinstance(node, ast.Assign) - and ( - ( - isinstance(node.targets[0], ast.Name) - and node.targets[0].id == "EXPORTS" - ) - or ( - isinstance(node.targets[0], ast.Attribute) - and get_attribute_label(node.targets[0]).startswith("EXPORTS") - ) + source_assignment_nodes.extend([ + node + for node in ast.walk(root) + if isinstance(node, ast.Assign) + and ( + ( + isinstance(node.targets[0], ast.Name) + and node.targets[0].id == "EXPORTS" ) - ] - ) + or ( + isinstance(node.targets[0], ast.Attribute) + and get_attribute_label(node.targets[0]).startswith("EXPORTS") + ) + ) + ]) # Get the source-assignment-location for the node: assignment_index = 1 @@ -473,11 +471,12 @@ def mozbuild_file_to_source_assignments(normalized_mozbuild_filename, assignment if source_assignment_location in source_assignments: source_assignment_location = node_to_readable_file_location(code, a) - assert ( - source_assignment_location not in source_assignments - ), "In %s, two assignments have the same key ('%s')" % ( - normalized_mozbuild_filename, - source_assignment_location, + assert source_assignment_location not in source_assignments, ( + "In %s, two assignments have the same key ('%s')" + % ( + normalized_mozbuild_filename, + source_assignment_location, + ) ) source_assignments[source_assignment_location] = normalized_source_filename_list assignment_index += 1 @@ -562,9 +561,9 @@ def get_mozbuild_file_search_order( ordered_list = [] if all_mozbuild_filenames_normalized is None: - assert os.path.isfile( - ".arcconfig" - ), "We do not seem to be running from the gecko root" + assert os.path.isfile(".arcconfig"), ( + "We do not seem to be running from the gecko root" + ) # The first time around, this variable name is incorrect. # It's actually the full path+filename, not a directory. @@ -642,12 +641,10 @@ def filenames_directory_is_in_filename_list( f("foo/bar/a.c", ["foo/b.c", "foo/bar/c.c"]) -> true f("foo/bar/a.c", ["foo/b.c", "foo/bar/baz/d.c"]) -> false """ - path_list = set( - [ - os.path.dirname(f).replace(os.path.sep, "/") - for f in list_of_normalized_filenames - ] - ) + path_list = set([ + os.path.dirname(f).replace(os.path.sep, "/") + for f in list_of_normalized_filenames + ]) return os.path.dirname(filename_normalized).replace(os.path.sep, "/") in path_list @@ -1050,9 +1047,9 @@ def add_file_to_moz_build_file( normalized_filename_to_add = original_normalized_filename_to_add continue - assert ( - len(possible_assignments) > 0 - ), "Could not find a single possible source assignment" + assert len(possible_assignments) > 0, ( + "Could not find a single possible source assignment" + ) if len(possible_assignments) > 1: best_guess, _ = guess_best_assignment( possible_assignments, normalized_filename_to_add diff --git a/python/mozbuild/mozbuild/vendor/vendor_manifest.py b/python/mozbuild/mozbuild/vendor/vendor_manifest.py index 79cfa16ccb3e5..0a19a95b003f7 100644 --- a/python/mozbuild/mozbuild/vendor/vendor_manifest.py +++ b/python/mozbuild/mozbuild/vendor/vendor_manifest.py @@ -663,18 +663,13 @@ def update_yaml(self, revision, timestamp): f.write(("".join(yaml)).encode("utf-8")) def spurious_check(self, revision, ignore_modified): - changed_files = set( - [ - os.path.abspath(f) - for f in self.repository.get_changed_files(mode="staged") - ] - ) - generated_files = set( - [ - self.get_full_path(f) - for f in self.manifest["vendoring"].get("generated", []) - ] - ) + changed_files = set([ + os.path.abspath(f) for f in self.repository.get_changed_files(mode="staged") + ]) + generated_files = set([ + self.get_full_path(f) + for f in self.manifest["vendoring"].get("generated", []) + ]) changed_files = set(changed_files) - generated_files if not changed_files: self.logInfo({"r": revision}, "Upstream {r} hasn't modified files locally.") diff --git a/python/mozbuild/mozbuild/vendor/vendor_python.py b/python/mozbuild/mozbuild/vendor/vendor_python.py index 72f351b3d7af0..f7aab83062201 100644 --- a/python/mozbuild/mozbuild/vendor/vendor_python.py +++ b/python/mozbuild/mozbuild/vendor/vendor_python.py @@ -146,23 +146,21 @@ def vendor( with TemporaryDirectory() as tmp: # use requirements.txt to download archived source distributions of all # packages - subprocess.check_call( - [ - sys.executable, - "-m", - "pip", - "download", - "-r", - str(requirements_path), - "--no-deps", - "--dest", - tmp, - "--abi", - "none", - "--platform", - "any", - ] - ) + subprocess.check_call([ + sys.executable, + "-m", + "pip", + "download", + "-r", + str(requirements_path), + "--no-deps", + "--dest", + tmp, + "--abi", + "none", + "--platform", + "any", + ]) _purge_vendor_dir(vendor_dir) self._extract(tmp, vendor_dir, keep_extra_files) diff --git a/python/mozbuild/mozbuild/vendor/vendor_rust.py b/python/mozbuild/mozbuild/vendor/vendor_rust.py index 6ba4ffe1123db..1f27984dd1ecd 100644 --- a/python/mozbuild/mozbuild/vendor/vendor_rust.py +++ b/python/mozbuild/mozbuild/vendor/vendor_rust.py @@ -163,20 +163,18 @@ def __init__(self, *args, **kwargs): self._issues = [] def serialize_issues_json(self): - return json.dumps( - { - "Cargo.lock": [ - { - "path": "Cargo.lock", - "column": None, - "line": None, - "level": "error" if level == logging.ERROR else "warning", - "message": msg, - } - for (level, msg) in self._issues - ] - } - ) + return json.dumps({ + "Cargo.lock": [ + { + "path": "Cargo.lock", + "column": None, + "line": None, + "level": "error" if level == logging.ERROR else "warning", + "message": msg, + } + for (level, msg) in self._issues + ] + }) def generate_diff_stream(self): return self.repository.diff_stream() @@ -268,9 +266,7 @@ def has_modified_files(self): {files} Please commit or stash these changes before vendoring, or re-run with `--ignore-modified`. -""".format( - files="\n".join(sorted(modified)) - ), +""".format(files="\n".join(sorted(modified))), ) return modified @@ -706,13 +702,11 @@ def vendor(self, ignore_modified=False, force=False): for name, packages in grouped.items(): # Allow to have crates of the same name when one depends on the other. - num = len( - [ - p - for p in packages - if all(d.split()[0] != name for d in p.get("dependencies", [])) - ] - ) + num = len([ + p + for p in packages + if all(d.split()[0] != name for d in p.get("dependencies", [])) + ]) if num > 1: self.log( logging.ERROR, @@ -728,12 +722,10 @@ def vendor(self, ignore_modified=False, force=False): # Only emit warnings for cargo-vet for now. env = os.environ.copy() - env["PATH"] = os.pathsep.join( - ( - str(Path(cargo).parent), - os.environ["PATH"], - ) - ) + env["PATH"] = os.pathsep.join(( + str(Path(cargo).parent), + os.environ["PATH"], + )) flags = ["--output-format=json"] if "MOZ_AUTOMATION" in os.environ: flags.append("--locked") diff --git a/python/mozbuild/mozpack/archive.py b/python/mozbuild/mozpack/archive.py index 308d5c61f2add..70502519e475b 100644 --- a/python/mozbuild/mozpack/archive.py +++ b/python/mozbuild/mozpack/archive.py @@ -79,7 +79,7 @@ def create_tar_from_files(fp, files): # would be a glaring security hole if the archive were # uncompressed as root. if ti.mode & (stat.S_ISUID | stat.S_ISGID): - raise ValueError("cannot add file with setuid or setgid set: " "%s" % f) + raise ValueError("cannot add file with setuid or setgid set: %s" % f) # Set uid, gid, username, and group as deterministic values. ti.uid = 0 diff --git a/python/mozbuild/mozpack/chrome/manifest.py b/python/mozbuild/mozpack/chrome/manifest.py index a69b93ebc839b..ef1675cc27141 100644 --- a/python/mozbuild/mozpack/chrome/manifest.py +++ b/python/mozbuild/mozpack/chrome/manifest.py @@ -339,16 +339,14 @@ def __str__(self): # All manifest classes by their type name. -MANIFESTS_TYPES = dict( - [ - (c.type, c) - for c in globals().values() - if type(c) is type - and issubclass(c, ManifestEntry) - and hasattr(c, "type") - and c.type - ] -) +MANIFESTS_TYPES = dict([ + (c.type, c) + for c in globals().values() + if type(c) is type + and issubclass(c, ManifestEntry) + and hasattr(c, "type") + and c.type +]) MANIFEST_RE = re.compile(r"^#.*$") diff --git a/python/mozbuild/mozpack/dmg.py b/python/mozbuild/mozpack/dmg.py index 0794fb5742cc8..e959624b54486 100644 --- a/python/mozbuild/mozpack/dmg.py +++ b/python/mozbuild/mozpack/dmg.py @@ -52,15 +52,13 @@ def generate_hfs_file( size = int(output.split()[0]) / 1000 # Get in MB size = int(size * 1.02) # Bump the used size slightly larger. # Setup a proper file sized out with zero's - subprocess.check_call( - [ - "dd", - "if=/dev/zero", - f"of={hfs}", - "bs=1M", - f"count={size}", - ] - ) + subprocess.check_call([ + "dd", + "if=/dev/zero", + f"of={hfs}", + "bs=1M", + f"count={size}", + ]) subprocess.check_call([mkfshfs_tool, "-v", volume_name, hfs]) @@ -106,23 +104,26 @@ def create_dmg_from_staged( if attribution_sentinel: while len(attribution_sentinel) < 1024: attribution_sentinel += "\t" - subprocess.check_call( - [ - hfs_tool, - hfs, - "setattr", - f"{volume_name}.app", - "com.apple.application-instance", - attribution_sentinel, - ] - ) + subprocess.check_call([ + hfs_tool, + hfs, + "setattr", + f"{volume_name}.app", + "com.apple.application-instance", + attribution_sentinel, + ]) subprocess.check_call(["cp", hfs, str(Path(output_dmg).parent)]) dmg_cmd.append(attribution_sentinel) if compression == "lzma": - dmg_cmd.extend( - ["--compression", "lzma", "--level", "5", "--run-sectors", "2048"] - ) + dmg_cmd.extend([ + "--compression", + "lzma", + "--level", + "5", + "--run-sectors", + "2048", + ]) subprocess.check_call( dmg_cmd, @@ -135,35 +136,31 @@ def create_dmg_from_staged( format = "ULMO" hybrid = tmpdir / "hybrid.dmg" - subprocess.check_call( - [ - "hdiutil", - "makehybrid", - "-hfs", - "-hfs-volume-name", - volume_name, - "-hfs-openfolder", - stagedir, - "-ov", - stagedir, - "-o", - hybrid, - ] - ) - subprocess.check_call( - [ - "hdiutil", - "convert", - "-format", - format, - "-imagekey", - "bzip2-level=9", - "-ov", - hybrid, - "-o", - output_dmg, - ] - ) + subprocess.check_call([ + "hdiutil", + "makehybrid", + "-hfs", + "-hfs-volume-name", + volume_name, + "-hfs-openfolder", + stagedir, + "-ov", + stagedir, + "-o", + hybrid, + ]) + subprocess.check_call([ + "hdiutil", + "convert", + "-format", + format, + "-imagekey", + "bzip2-level=9", + "-ov", + hybrid, + "-o", + output_dmg, + ]) def create_dmg( diff --git a/python/mozbuild/mozpack/files.py b/python/mozbuild/mozpack/files.py index f03b375d26bdb..ac31ed129f42c 100644 --- a/python/mozbuild/mozpack/files.py +++ b/python/mozbuild/mozpack/files.py @@ -1253,13 +1253,11 @@ def __init__(self, repo, rev=".", recognize_repo_paths=False, **kwargs): # Immediately populate the list of files in the repo since nearly every # operation requires this list. - out = self._client.rawcommand( - [ - b"files", - b"--rev", - self._rev.encode(), - ] - ) + out = self._client.rawcommand([ + b"files", + b"--rev", + self._rev.encode(), + ]) for relpath in out.splitlines(): # Mercurial may use \ as path separator on Windows. So use # normpath(). diff --git a/python/mozbuild/mozpack/mozjar.py b/python/mozbuild/mozpack/mozjar.py index fd53cea4a4fc3..55e2ddd250981 100644 --- a/python/mozbuild/mozpack/mozjar.py +++ b/python/mozbuild/mozpack/mozjar.py @@ -197,18 +197,16 @@ class JarCdirEnd(JarStruct): """ MAGIC = 0x06054B50 - STRUCT = OrderedDict( - [ - ("disk_num", "uint16"), - ("cdir_disk", "uint16"), - ("disk_entries", "uint16"), - ("cdir_entries", "uint16"), - ("cdir_size", "uint32"), - ("cdir_offset", "uint32"), - ("comment_size", "uint16"), - ("comment", "comment_size"), - ] - ) + STRUCT = OrderedDict([ + ("disk_num", "uint16"), + ("cdir_disk", "uint16"), + ("disk_entries", "uint16"), + ("cdir_entries", "uint16"), + ("cdir_size", "uint32"), + ("cdir_offset", "uint32"), + ("comment_size", "uint16"), + ("comment", "comment_size"), + ]) CDIR_END_SIZE = JarCdirEnd().size @@ -220,29 +218,27 @@ class JarCdirEntry(JarStruct): """ MAGIC = 0x02014B50 - STRUCT = OrderedDict( - [ - ("creator_version", "uint16"), - ("min_version", "uint16"), - ("general_flag", "uint16"), - ("compression", "uint16"), - ("lastmod_time", "uint16"), - ("lastmod_date", "uint16"), - ("crc32", "uint32"), - ("compressed_size", "uint32"), - ("uncompressed_size", "uint32"), - ("filename_size", "uint16"), - ("extrafield_size", "uint16"), - ("filecomment_size", "uint16"), - ("disknum", "uint16"), - ("internal_attr", "uint16"), - ("external_attr", "uint32"), - ("offset", "uint32"), - ("filename", "filename_size"), - ("extrafield", "extrafield_size"), - ("filecomment", "filecomment_size"), - ] - ) + STRUCT = OrderedDict([ + ("creator_version", "uint16"), + ("min_version", "uint16"), + ("general_flag", "uint16"), + ("compression", "uint16"), + ("lastmod_time", "uint16"), + ("lastmod_date", "uint16"), + ("crc32", "uint32"), + ("compressed_size", "uint32"), + ("uncompressed_size", "uint32"), + ("filename_size", "uint16"), + ("extrafield_size", "uint16"), + ("filecomment_size", "uint16"), + ("disknum", "uint16"), + ("internal_attr", "uint16"), + ("external_attr", "uint32"), + ("offset", "uint32"), + ("filename", "filename_size"), + ("extrafield", "extrafield_size"), + ("filecomment", "filecomment_size"), + ]) class JarLocalFileHeader(JarStruct): @@ -251,22 +247,20 @@ class JarLocalFileHeader(JarStruct): """ MAGIC = 0x04034B50 - STRUCT = OrderedDict( - [ - ("min_version", "uint16"), - ("general_flag", "uint16"), - ("compression", "uint16"), - ("lastmod_time", "uint16"), - ("lastmod_date", "uint16"), - ("crc32", "uint32"), - ("compressed_size", "uint32"), - ("uncompressed_size", "uint32"), - ("filename_size", "uint16"), - ("extra_field_size", "uint16"), - ("filename", "filename_size"), - ("extra_field", "extra_field_size"), - ] - ) + STRUCT = OrderedDict([ + ("min_version", "uint16"), + ("general_flag", "uint16"), + ("compression", "uint16"), + ("lastmod_time", "uint16"), + ("lastmod_date", "uint16"), + ("crc32", "uint32"), + ("compressed_size", "uint32"), + ("uncompressed_size", "uint32"), + ("filename_size", "uint16"), + ("extra_field_size", "uint16"), + ("filename", "filename_size"), + ("extra_field", "extra_field_size"), + ]) class JarFileReader: diff --git a/python/mozbuild/mozpack/pkg.py b/python/mozbuild/mozpack/pkg.py index bfb5b0211d343..5ef950a57ae7a 100644 --- a/python/mozbuild/mozpack/pkg.py +++ b/python/mozbuild/mozpack/pkg.py @@ -165,17 +165,15 @@ def create_bom(bom_path: Path, root_path: Path, mkbom_tool: Path): mkbom_tool: Path, mkbom tool Path """ print(f"Creating BOM file from {root_path} to {bom_path}") - subprocess.check_call( - [ - mkbom_tool, - "-u", - "0", - "-g", - "80", - str(root_path), - str(bom_path), - ] - ) + subprocess.check_call([ + mkbom_tool, + "-u", + "0", + "-g", + "80", + str(root_path), + str(bom_path), + ]) print(f"Created BOM File size: {bom_path.stat().st_size // 1024}kb") @@ -256,14 +254,12 @@ def create_pkg( root_path.mkdir(parents=True, exist_ok=True) # Copy files over - subprocess.check_call( - [ - "cp", - "-R", - str(source_app), - str(root_path), - ] - ) + subprocess.check_call([ + "cp", + "-R", + str(source_app), + str(root_path), + ]) # Count all files (innards + itself) file_count = len(list(source_app.glob("**/*"))) + 1 diff --git a/python/mozbuild/mozpack/test/test_chrome_manifest.py b/python/mozbuild/mozpack/test/test_chrome_manifest.py index c1d5826bbc87e..936af1b7c1394 100644 --- a/python/mozbuild/mozpack/test/test_chrome_manifest.py +++ b/python/mozbuild/mozpack/test/test_chrome_manifest.py @@ -108,12 +108,10 @@ def test_parse_manifest(self): "chrome://browser/content/viewSourceOverlay.xul", ), ] - with mozunit.MockedOpen( - { - "manifest": "\n".join(manifest), - "other/manifest": "\n".join(other_manifest), - } - ): + with mozunit.MockedOpen({ + "manifest": "\n".join(manifest), + "other/manifest": "\n".join(other_manifest), + }): # Ensure we have tests for all types of manifests. self.assertEqual( set(type(e) for e in expected_result), set(MANIFESTS_TYPES.values()) diff --git a/python/mozbuild/mozpack/test/test_files.py b/python/mozbuild/mozpack/test/test_files.py index e09d31acedcf5..af80aa036b6bb 100644 --- a/python/mozbuild/mozpack/test/test_files.py +++ b/python/mozbuild/mozpack/test/test_files.py @@ -829,12 +829,12 @@ def test_manifest_file(self): # because they will be automatically included by virtue of being an # argument to a method of |bar|. bar_xpt = GeneratedFile( - b"\x58\x50\x43\x4F\x4D\x0A\x54\x79\x70\x65\x4C\x69\x62\x0D\x0A\x1A" - + b"\x01\x02\x00\x02\x00\x00\x00\x7B\x00\x00\x00\x24\x00\x00\x00\x5C" + b"\x58\x50\x43\x4f\x4d\x0a\x54\x79\x70\x65\x4c\x69\x62\x0d\x0a\x1a" + + b"\x01\x02\x00\x02\x00\x00\x00\x7b\x00\x00\x00\x24\x00\x00\x00\x5c" + b"\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" - + b"\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x5F" - + b"\x70\xDA\x76\x51\x9C\x48\x58\xB7\x1E\xE3\xC9\x23\x33\xE2\xD6\x00" - + b"\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x0D\x00\x66\x6F\x6F\x00" + + b"\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x5f" + + b"\x70\xda\x76\x51\x9c\x48\x58\xb7\x1e\xe3\xc9\x23\x33\xe2\xd6\x00" + + b"\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x0d\x00\x66\x6f\x6f\x00" + b"\x62\x61\x72\x00\x62\x61\x72\x00\x00\x00\x00\x01\x00\x00\x00\x00" + b"\x09\x01\x80\x92\x00\x01\x80\x06\x00\x00\x80" ) @@ -845,11 +845,11 @@ def test_manifest_file(self): # void foo(); # }; foo_xpt = GeneratedFile( - b"\x58\x50\x43\x4F\x4D\x0A\x54\x79\x70\x65\x4C\x69\x62\x0D\x0A\x1A" + b"\x58\x50\x43\x4f\x4d\x0a\x54\x79\x70\x65\x4c\x69\x62\x0d\x0a\x1a" + b"\x01\x02\x00\x01\x00\x00\x00\x57\x00\x00\x00\x24\x00\x00\x00\x40" - + b"\x80\x00\x00\x32\x71\xBE\xBC\x92\x7E\x4B\xEF\x93\x5E\x44\xE0\xAA" - + b"\xF3\xC1\xE5\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x09\x00" - + b"\x66\x6F\x6F\x00\x66\x6F\x6F\x00\x00\x00\x00\x01\x00\x00\x00\x00" + + b"\x80\x00\x00\x32\x71\xbe\xbc\x92\x7e\x4b\xef\x93\x5e\x44\xe0\xaa" + + b"\xf3\xc1\xe5\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x09\x00" + + b"\x66\x6f\x6f\x00\x66\x6f\x6f\x00\x00\x00\x00\x01\x00\x00\x00\x00" + b"\x05\x00\x80\x06\x00\x00\x00" ) @@ -859,11 +859,11 @@ def test_manifest_file(self): # void foo(); # }; foo2_xpt = GeneratedFile( - b"\x58\x50\x43\x4F\x4D\x0A\x54\x79\x70\x65\x4C\x69\x62\x0D\x0A\x1A" + b"\x58\x50\x43\x4f\x4d\x0a\x54\x79\x70\x65\x4c\x69\x62\x0d\x0a\x1a" + b"\x01\x02\x00\x01\x00\x00\x00\x57\x00\x00\x00\x24\x00\x00\x00\x40" - + b"\x80\x00\x00\x70\x57\xF2\xAA\xFD\xC2\x45\x59\xAB\xDE\x08\xD9\x39" - + b"\xF7\xE8\x0D\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x09\x00" - + b"\x66\x6F\x6F\x00\x66\x6F\x6F\x00\x00\x00\x00\x01\x00\x00\x00\x00" + + b"\x80\x00\x00\x70\x57\xf2\xaa\xfd\xc2\x45\x59\xab\xde\x08\xd9\x39" + + b"\xf7\xe8\x0d\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x09\x00" + + b"\x66\x6f\x6f\x00\x66\x6f\x6f\x00\x00\x00\x00\x01\x00\x00\x00\x00" + b"\x05\x00\x80\x06\x00\x00\x00" ) @@ -1282,12 +1282,10 @@ def test_composed_finder(self): ensureParentDir(self.tmppath("a/foo/qux/hoge")) open(self.tmppath("a/foo/qux/hoge"), "wb").write(b"hoge") open(self.tmppath("a/foo/qux/bar"), "wb").write(b"not the right content") - self.finder = ComposedFinder( - { - "": FileFinder(self.tmppath("a")), - "foo/qux": FileFinder(self.tmppath("b")), - } - ) + self.finder = ComposedFinder({ + "": FileFinder(self.tmppath("a")), + "foo/qux": FileFinder(self.tmppath("b")), + }) self.do_match_test() self.assertIsNone(self.finder.get("does-not-exist")) diff --git a/python/mozbuild/mozpack/test/test_mozjar.py b/python/mozbuild/mozpack/test/test_mozjar.py index fb5c7dbf4b354..9a935ccdb8f22 100644 --- a/python/mozbuild/mozpack/test/test_mozjar.py +++ b/python/mozbuild/mozpack/test/test_mozjar.py @@ -29,17 +29,15 @@ class TestJarStruct(unittest.TestCase): class Foo(JarStruct): MAGIC = 0x01020304 - STRUCT = OrderedDict( - [ - ("foo", "uint32"), - ("bar", "uint16"), - ("qux", "uint16"), - ("length", "uint16"), - ("length2", "uint16"), - ("string", "length"), - ("string2", "length2"), - ] - ) + STRUCT = OrderedDict([ + ("foo", "uint32"), + ("bar", "uint16"), + ("qux", "uint16"), + ("length", "uint16"), + ("length2", "uint16"), + ("string", "length"), + ("string2", "length2"), + ]) def test_jar_struct(self): foo = TestJarStruct.Foo() @@ -304,30 +302,26 @@ def test_preload(self): class TestJarLog(unittest.TestCase): def test_jarlog(self): s = StringIO( - "\n".join( - [ - "bar/baz.jar first", - "bar/baz.jar second", - "bar/baz.jar third", - "bar/baz.jar second", - "bar/baz.jar second", - "omni.ja stuff", - "bar/baz.jar first", - "omni.ja other/stuff", - "omni.ja stuff", - "bar/baz.jar third", - ] - ) + "\n".join([ + "bar/baz.jar first", + "bar/baz.jar second", + "bar/baz.jar third", + "bar/baz.jar second", + "bar/baz.jar second", + "omni.ja stuff", + "bar/baz.jar first", + "omni.ja other/stuff", + "omni.ja stuff", + "bar/baz.jar third", + ]) ) log = JarLog(fileobj=s) self.assertEqual( set(log.keys()), - set( - [ - "bar/baz.jar", - "omni.ja", - ] - ), + set([ + "bar/baz.jar", + "omni.ja", + ]), ) self.assertEqual( log["bar/baz.jar"], diff --git a/python/mozbuild/mozpack/test/test_packager.py b/python/mozbuild/mozpack/test/test_packager.py index 3b4c3d2d6e88c..2df4608ae2ff5 100644 --- a/python/mozbuild/mozpack/test/test_packager.py +++ b/python/mozbuild/mozpack/test/test_packager.py @@ -160,12 +160,10 @@ def __init__(self, path, content): packager.add( "qux/qux.manifest", GeneratedFile( - b"".join( - [ - b"resource qux qux/\n", - b"binary-component qux.so\n", - ] - ) + b"".join([ + b"resource qux qux/\n", + b"binary-component qux.so\n", + ]) ), ) bar_xpt = GeneratedFile(b"bar.xpt") @@ -180,12 +178,10 @@ def __init__(self, path, content): file = GeneratedFileWithPath( os.path.join(curdir, "foo.manifest"), - b"".join( - [ - b"manifest foo/bar.manifest\n", - b"manifest bar/baz.manifest\n", - ] - ), + b"".join([ + b"manifest foo/bar.manifest\n", + b"manifest bar/baz.manifest\n", + ]), ) with errors.context("manifest", 6): packager.add("foo.manifest", file) @@ -399,26 +395,24 @@ def __init__(self, path, content): self.assertEqual( packager.get_bases(), - set( - [ - "", - "addon", - "addon2", - "addon3", - "addon4", - "addon5", - "addon6", - "addon7", - "addon8", - "addon9", - "addon10", - "addon11", - "qux", - "hybrid", - "hybrid2", - "webextension", - ] - ), + set([ + "", + "addon", + "addon2", + "addon3", + "addon4", + "addon5", + "addon6", + "addon7", + "addon8", + "addon9", + "addon10", + "addon11", + "qux", + "hybrid", + "hybrid2", + "webextension", + ]), ) self.assertEqual(packager.get_bases(addons=False), set(["", "qux"])) @@ -429,9 +423,7 @@ def test_simple_packager_manifest_consistency(self): packager = SimplePackager(formatter) packager.add( "base.manifest", - GeneratedFile( - b"manifest foo/bar.manifest\n" b"manifest bar/baz.manifest\n" - ), + GeneratedFile(b"manifest foo/bar.manifest\nmanifest bar/baz.manifest\n"), ) packager.add("foo/bar.manifest", GeneratedFile(b"resource bar bar")) packager.add("bar/baz.manifest", GeneratedFile(b"resource baz baz")) @@ -452,9 +444,7 @@ def test_simple_packager_manifest_consistency(self): packager = SimplePackager(formatter) packager.add( "base.manifest", - GeneratedFile( - b"manifest foo/bar.manifest\n" b"manifest bar/baz.manifest\n" - ), + GeneratedFile(b"manifest foo/bar.manifest\nmanifest bar/baz.manifest\n"), ) packager.add("foo/bar.manifest", GeneratedFile(b"resource bar bar")) packager.add("bar/baz.manifest", GeneratedFile(b"resource baz baz")) @@ -487,16 +477,14 @@ def test_simple_manifest_parser(self): foobaz = GeneratedFile(b"foobaz") fooqux = GeneratedFile(b"fooqux") foozot = GeneratedFile(b"foozot") - finder = MockFinder( - { - "bin/foo/bar": foobar, - "bin/foo/baz": foobaz, - "bin/foo/qux": fooqux, - "bin/foo/zot": foozot, - "bin/foo/chrome.manifest": GeneratedFile(b"resource foo foo/"), - "bin/chrome.manifest": GeneratedFile(b"manifest foo/chrome.manifest"), - } - ) + finder = MockFinder({ + "bin/foo/bar": foobar, + "bin/foo/baz": foobaz, + "bin/foo/qux": fooqux, + "bin/foo/zot": foozot, + "bin/foo/chrome.manifest": GeneratedFile(b"resource foo foo/"), + "bin/chrome.manifest": GeneratedFile(b"manifest foo/chrome.manifest"), + }) parser = SimpleManifestSink(finder, formatter) component0 = Component("component0") component1 = Component("component1") diff --git a/python/mozbuild/mozpack/test/test_packager_formats.py b/python/mozbuild/mozpack/test/test_packager_formats.py index 734e12d60be58..9b7ba8aa9a992 100644 --- a/python/mozbuild/mozpack/test/test_packager_formats.py +++ b/python/mozbuild/mozpack/test/test_packager_formats.py @@ -107,27 +107,23 @@ } for addon in ("addon0", "addon1", "app/chrome/addons/addon2"): - RESULT_FLAT.update( - { - mozpath.join(addon, p): f - for p, f in { - "chrome.manifest": [ - "manifest chrome/chrome.manifest", - "manifest components/components.manifest", - ], - "chrome/chrome.manifest": [ - "content %s foo/bar/" % mozpath.basename(addon) - ], - "chrome/foo/bar/baz": FILES[mozpath.join(addon, "chrome/foo/bar/baz")], - "components/components.manifest": [ - "interfaces bar.xpt", - "interfaces foo.xpt", - ], - "components/bar.xpt": bar_xpt, - "components/foo.xpt": foo2_xpt, - }.items() - } - ) + RESULT_FLAT.update({ + mozpath.join(addon, p): f + for p, f in { + "chrome.manifest": [ + "manifest chrome/chrome.manifest", + "manifest components/components.manifest", + ], + "chrome/chrome.manifest": ["content %s foo/bar/" % mozpath.basename(addon)], + "chrome/foo/bar/baz": FILES[mozpath.join(addon, "chrome/foo/bar/baz")], + "components/components.manifest": [ + "interfaces bar.xpt", + "interfaces foo.xpt", + ], + "components/bar.xpt": bar_xpt, + "components/foo.xpt": foo2_xpt, + }.items() + }) RESULT_JAR = { p: RESULT_FLAT[p] @@ -149,42 +145,40 @@ ) } -RESULT_JAR.update( - { - "chrome/f/f.manifest": [ - "content oo jar:oo.jar!/", - "content bar jar:oo.jar!/bar/", - "resource foo resource://bar/", - ], - "chrome/f/oo.jar": { - "bar/baz": FILES["chrome/f/oo/bar/baz"], - "baz": FILES["chrome/f/oo/baz"], - "qux": FILES["chrome/f/oo/qux"], - }, - "app/chrome/chrome.manifest": [ - "content content jar:foo.jar!/", - ], - "app/chrome/foo.jar": { - "foo": FILES["app/chrome/foo/foo"], - }, - "addon0/chrome/chrome.manifest": [ - "content addon0 jar:foo.jar!/bar/", - ], - "addon0/chrome/foo.jar": { - "bar/baz": FILES["addon0/chrome/foo/bar/baz"], - }, - "addon1.xpi": { - mozpath.relpath(p, "addon1"): f - for p, f in RESULT_FLAT.items() - if p.startswith("addon1/") - }, - "app/chrome/addons/addon2.xpi": { - mozpath.relpath(p, "app/chrome/addons/addon2"): f - for p, f in RESULT_FLAT.items() - if p.startswith("app/chrome/addons/addon2/") - }, - } -) +RESULT_JAR.update({ + "chrome/f/f.manifest": [ + "content oo jar:oo.jar!/", + "content bar jar:oo.jar!/bar/", + "resource foo resource://bar/", + ], + "chrome/f/oo.jar": { + "bar/baz": FILES["chrome/f/oo/bar/baz"], + "baz": FILES["chrome/f/oo/baz"], + "qux": FILES["chrome/f/oo/qux"], + }, + "app/chrome/chrome.manifest": [ + "content content jar:foo.jar!/", + ], + "app/chrome/foo.jar": { + "foo": FILES["app/chrome/foo/foo"], + }, + "addon0/chrome/chrome.manifest": [ + "content addon0 jar:foo.jar!/bar/", + ], + "addon0/chrome/foo.jar": { + "bar/baz": FILES["addon0/chrome/foo/bar/baz"], + }, + "addon1.xpi": { + mozpath.relpath(p, "addon1"): f + for p, f in RESULT_FLAT.items() + if p.startswith("addon1/") + }, + "app/chrome/addons/addon2.xpi": { + mozpath.relpath(p, "app/chrome/addons/addon2"): f + for p, f in RESULT_FLAT.items() + if p.startswith("app/chrome/addons/addon2/") + }, +}) RESULT_OMNIJAR = { p: RESULT_FLAT[p] @@ -196,55 +190,51 @@ RESULT_OMNIJAR.update({p: RESULT_JAR[p] for p in RESULT_JAR if p.startswith("addon")}) -RESULT_OMNIJAR.update( - { - "omni.foo": { - "components/components.manifest": [ - "interfaces bar.xpt", - "interfaces foo.xpt", - ], - }, - "chrome.manifest": [ - "manifest components/components.manifest", - ], +RESULT_OMNIJAR.update({ + "omni.foo": { "components/components.manifest": [ - "binary-component foo.so", + "interfaces bar.xpt", + "interfaces foo.xpt", ], - "app/omni.foo": { - p: RESULT_FLAT["app/" + p] - for p in chain( - ( - "chrome.manifest", - "chrome/chrome.manifest", - "chrome/foo/foo", - "components/components.manifest", - "components/foo.js", - ), - ( - mozpath.relpath(p, "app") - for p in RESULT_FLAT.keys() - if p.startswith("app/chrome/addons/addon2/") - ), - ) - }, - } -) - -RESULT_OMNIJAR["omni.foo"].update( - { - p: RESULT_FLAT[p] - for p in ( - "chrome.manifest", - "chrome/chrome.manifest", - "chrome/f/f.manifest", - "chrome/f/oo/bar/baz", - "chrome/f/oo/baz", - "chrome/f/oo/qux", - "components/foo.xpt", - "components/bar.xpt", + }, + "chrome.manifest": [ + "manifest components/components.manifest", + ], + "components/components.manifest": [ + "binary-component foo.so", + ], + "app/omni.foo": { + p: RESULT_FLAT["app/" + p] + for p in chain( + ( + "chrome.manifest", + "chrome/chrome.manifest", + "chrome/foo/foo", + "components/components.manifest", + "components/foo.js", + ), + ( + mozpath.relpath(p, "app") + for p in RESULT_FLAT.keys() + if p.startswith("app/chrome/addons/addon2/") + ), ) - } -) + }, +}) + +RESULT_OMNIJAR["omni.foo"].update({ + p: RESULT_FLAT[p] + for p in ( + "chrome.manifest", + "chrome/chrome.manifest", + "chrome/f/f.manifest", + "chrome/f/oo/bar/baz", + "chrome/f/oo/baz", + "chrome/f/oo/qux", + "components/foo.xpt", + "components/bar.xpt", + ) +}) RESULT_OMNIJAR_WITH_SUBPATH = { k.replace("omni.foo", "bar/omni.foo"): v for k, v in RESULT_OMNIJAR.items() @@ -453,7 +443,7 @@ def test_chrome_override(self): self.assertEqual( str(e.exception), - 'error: "content foo foo/" overrides ' '"content foo foo/unix"', + 'error: "content foo foo/" overrides "content foo foo/unix"', ) # Chrome with the same name and same flags overrides the previous @@ -475,7 +465,7 @@ def test_chrome_override(self): self.assertEqual( str(e.exception), - 'error: "content bar bar/unix" overrides ' '"content bar bar/win os=WINNT"', + 'error: "content bar bar/unix" overrides "content bar bar/win os=WINNT"', ) # Adding something more specific still works. diff --git a/python/mozbuild/mozpack/test/test_packager_l10n.py b/python/mozbuild/mozpack/test/test_packager_l10n.py index c437b09d17b84..6126bc5fa009c 100644 --- a/python/mozbuild/mozpack/test/test_packager_l10n.py +++ b/python/mozbuild/mozpack/test/test_packager_l10n.py @@ -25,41 +25,39 @@ def test_l10n_repack(self): dict_cc = GeneratedFile(b"dict_cc") barbaz = GeneratedFile(b"barbaz") lst = GeneratedFile(b"foo\nbar") - app_finder = MockFinder( - { - "bar/foo": foo, - "chrome/foo/foobar": foobar, - "chrome/qux/qux.properties": qux, - "chrome/qux/baz/baz.properties": baz, - "chrome/chrome.manifest": ManifestFile( - "chrome", - [ - ManifestContent("chrome", "foo", "foo/"), - ManifestLocale("chrome", "qux", "en-US", "qux/"), - ], - ), - "chrome.manifest": ManifestFile( - "", [Manifest("", "chrome/chrome.manifest")] - ), - "dict/aa": dict_aa, - "app/chrome/bar/barbaz.dtd": barbaz, - "app/chrome/chrome.manifest": ManifestFile( - "app/chrome", [ManifestLocale("app/chrome", "bar", "en-US", "bar/")] - ), - "app/chrome.manifest": ManifestFile( - "app", [Manifest("app", "chrome/chrome.manifest")] - ), - "app/dict/bb": dict_bb, - "app/dict/cc": dict_cc, - "app/chrome/bar/search/foo.xml": foo, - "app/chrome/bar/search/bar.xml": bar, - "app/chrome/bar/search/lst.txt": lst, - "META-INF/foo": foo, # Stripped. - "inner/META-INF/foo": foo, # Not stripped. - "app/META-INF/foo": foo, # Stripped. - "app/inner/META-INF/foo": foo, # Not stripped. - } - ) + app_finder = MockFinder({ + "bar/foo": foo, + "chrome/foo/foobar": foobar, + "chrome/qux/qux.properties": qux, + "chrome/qux/baz/baz.properties": baz, + "chrome/chrome.manifest": ManifestFile( + "chrome", + [ + ManifestContent("chrome", "foo", "foo/"), + ManifestLocale("chrome", "qux", "en-US", "qux/"), + ], + ), + "chrome.manifest": ManifestFile( + "", [Manifest("", "chrome/chrome.manifest")] + ), + "dict/aa": dict_aa, + "app/chrome/bar/barbaz.dtd": barbaz, + "app/chrome/chrome.manifest": ManifestFile( + "app/chrome", [ManifestLocale("app/chrome", "bar", "en-US", "bar/")] + ), + "app/chrome.manifest": ManifestFile( + "app", [Manifest("app", "chrome/chrome.manifest")] + ), + "app/dict/bb": dict_bb, + "app/dict/cc": dict_cc, + "app/chrome/bar/search/foo.xml": foo, + "app/chrome/bar/search/bar.xml": bar, + "app/chrome/bar/search/lst.txt": lst, + "META-INF/foo": foo, # Stripped. + "inner/META-INF/foo": foo, # Not stripped. + "app/META-INF/foo": foo, # Stripped. + "app/inner/META-INF/foo": foo, # Not stripped. + }) app_finder.jarlogs = {} app_finder.base = "app" foo_l10n = GeneratedFile(b"foo_l10n") @@ -67,35 +65,33 @@ def test_l10n_repack(self): baz_l10n = GeneratedFile(b"baz_l10n") barbaz_l10n = GeneratedFile(b"barbaz_l10n") lst_l10n = GeneratedFile(b"foo\nqux") - l10n_finder = MockFinder( - { - "chrome/qux-l10n/qux.properties": qux_l10n, - "chrome/qux-l10n/baz/baz.properties": baz_l10n, - "chrome/chrome.manifest": ManifestFile( - "chrome", - [ - ManifestLocale("chrome", "qux", "x-test", "qux-l10n/"), - ], - ), - "chrome.manifest": ManifestFile( - "", [Manifest("", "chrome/chrome.manifest")] - ), - "dict/bb": dict_bb, - "dict/cc": dict_cc, - "app/chrome/bar-l10n/barbaz.dtd": barbaz_l10n, - "app/chrome/chrome.manifest": ManifestFile( - "app/chrome", - [ManifestLocale("app/chrome", "bar", "x-test", "bar-l10n/")], - ), - "app/chrome.manifest": ManifestFile( - "app", [Manifest("app", "chrome/chrome.manifest")] - ), - "app/dict/aa": dict_aa, - "app/chrome/bar-l10n/search/foo.xml": foo_l10n, - "app/chrome/bar-l10n/search/qux.xml": qux_l10n, - "app/chrome/bar-l10n/search/lst.txt": lst_l10n, - } - ) + l10n_finder = MockFinder({ + "chrome/qux-l10n/qux.properties": qux_l10n, + "chrome/qux-l10n/baz/baz.properties": baz_l10n, + "chrome/chrome.manifest": ManifestFile( + "chrome", + [ + ManifestLocale("chrome", "qux", "x-test", "qux-l10n/"), + ], + ), + "chrome.manifest": ManifestFile( + "", [Manifest("", "chrome/chrome.manifest")] + ), + "dict/bb": dict_bb, + "dict/cc": dict_cc, + "app/chrome/bar-l10n/barbaz.dtd": barbaz_l10n, + "app/chrome/chrome.manifest": ManifestFile( + "app/chrome", + [ManifestLocale("app/chrome", "bar", "x-test", "bar-l10n/")], + ), + "app/chrome.manifest": ManifestFile( + "app", [Manifest("app", "chrome/chrome.manifest")] + ), + "app/dict/aa": dict_aa, + "app/chrome/bar-l10n/search/foo.xml": foo_l10n, + "app/chrome/bar-l10n/search/qux.xml": qux_l10n, + "app/chrome/bar-l10n/search/lst.txt": lst_l10n, + }) l10n_finder.base = "l10n" copier = FileRegistry() formatter = l10n.FlatFormatter(copier) diff --git a/python/mozbuild/mozpack/test/test_path.py b/python/mozbuild/mozpack/test/test_path.py index 6c7aeb5400dbb..06b10e75aeafd 100644 --- a/python/mozbuild/mozpack/test/test_path.py +++ b/python/mozbuild/mozpack/test/test_path.py @@ -56,9 +56,11 @@ def test_dirname(self): def test_commonprefix(self): self.assertEqual( - commonprefix( - [self.SEP.join(("foo", "bar", "baz")), "foo/qux", "foo/baz/qux"] - ), + commonprefix([ + self.SEP.join(("foo", "bar", "baz")), + "foo/qux", + "foo/baz/qux", + ]), "foo/", ) self.assertEqual( diff --git a/python/mozbuild/mozpack/test/test_unify.py b/python/mozbuild/mozpack/test/test_unify.py index a3c79ec47c5cb..5504e7c69361f 100644 --- a/python/mozbuild/mozpack/test/test_unify.py +++ b/python/mozbuild/mozpack/test/test_unify.py @@ -47,18 +47,18 @@ def test_unified_finder(self): sorted=["test"], ) self.assertEqual( - sorted( - [(f, c.open().read().decode("utf-8")) for f, c in finder.find("foo")] - ), + sorted([ + (f, c.open().read().decode("utf-8")) for f, c in finder.find("foo") + ]), [("foo/bar", "foobar"), ("foo/baz", "foobaz")], ) self.assertRaises(ErrorMessage, any, finder.find("bar")) self.assertRaises(ErrorMessage, any, finder.find("baz")) self.assertRaises(ErrorMessage, any, finder.find("qux")) self.assertEqual( - sorted( - [(f, c.open().read().decode("utf-8")) for f, c in finder.find("test")] - ), + sorted([ + (f, c.open().read().decode("utf-8")) for f, c in finder.find("test") + ]), [("test/bar", "a\nb\nc\n"), ("test/foo", "a\nb\nc\n")], ) @@ -74,12 +74,10 @@ def test_unified_build_finder(self): self.create_one("a", "chrome/chrome.manifest", "a\nb\nc\n") self.create_one("b", "chrome/chrome.manifest", "b\nc\na\n") self.assertEqual( - sorted( - [ - (f, c.open().read().decode("utf-8")) - for f, c in finder.find("**/chrome.manifest") - ] - ), + sorted([ + (f, c.open().read().decode("utf-8")) + for f, c in finder.find("**/chrome.manifest") + ]), [("chrome.manifest", "a\nb\nc\n"), ("chrome/chrome.manifest", "a\nb\nc\n")], ) @@ -87,59 +85,51 @@ def test_unified_build_finder(self): self.create_one( "a", "chrome/browser/foo/buildconfig.html", - "\n".join( - [ - "", - " ", - "
", - "

Build Configuration

", - "
foo
", - "
", - " ", - "", - ] - ), + "\n".join([ + "", + " ", + "
", + "

Build Configuration

", + "
foo
", + "
", + " ", + "", + ]), ) self.create_one( "b", "chrome/browser/foo/buildconfig.html", - "\n".join( - [ - "", - " ", - "
", - "

Build Configuration

", - "
bar
", - "
", - " ", - "", - ] - ), + "\n".join([ + "", + " ", + "
", + "

Build Configuration

", + "
bar
", + "
", + " ", + "", + ]), ) self.assertEqual( - sorted( - [ - (f, c.open().read().decode("utf-8")) - for f, c in finder.find("**/buildconfig.html") - ] - ), + sorted([ + (f, c.open().read().decode("utf-8")) + for f, c in finder.find("**/buildconfig.html") + ]), [ ( "chrome/browser/foo/buildconfig.html", - "\n".join( - [ - "", - " ", - "
", - "

Build Configuration

", - "
foo
", - "
", - "
bar
", - "
", - " ", - "", - ] - ), + "\n".join([ + "", + " ", + "
", + "

Build Configuration

", + "
foo
", + "
", + "
bar
", + "
", + " ", + "", + ]), ) ], ) @@ -171,23 +161,19 @@ def test_unified_build_finder(self): target_tag = "<{em}targetPlatform>{platform}" target_attr = '{em}targetPlatform="{platform}" ' - rdf_tag = "".join( - [ - '<{RDF}Description {em}bar="bar" {em}qux="qux">', - "<{em}foo>foo", - "{targets}", - "<{em}baz>baz", - "", - ] - ) - rdf_attr = "".join( - [ - '<{RDF}Description {em}bar="bar" {attr}{em}qux="qux">', - "{targets}", - "<{em}foo>foo<{em}baz>baz", - "", - ] - ) + rdf_tag = "".join([ + '<{RDF}Description {em}bar="bar" {em}qux="qux">', + "<{em}foo>foo", + "{targets}", + "<{em}baz>baz", + "", + ]) + rdf_attr = "".join([ + '<{RDF}Description {em}bar="bar" {attr}{em}qux="qux">', + "{targets}", + "<{em}foo>foo<{em}baz>baz", + "", + ]) for descr_ns, target_ns in (("RDF:", ""), ("", "em:"), ("RDF:", "em:")): # First we need to infuse the above strings with our namespaces and @@ -236,12 +222,10 @@ def test_unified_build_finder(self): results.append((filename, result)) self.assertEqual( - sorted( - [ - (f, c.open().read().decode("utf-8")) - for f, c in finder.find("**/install.rdf") - ] - ), + sorted([ + (f, c.open().read().decode("utf-8")) + for f, c in finder.find("**/install.rdf") + ]), results, ) diff --git a/python/mozlint/mozlint/errors.py b/python/mozlint/mozlint/errors.py index cb4ed587140a7..7f597b7d66f44 100644 --- a/python/mozlint/mozlint/errors.py +++ b/python/mozlint/mozlint/errors.py @@ -29,5 +29,5 @@ class LintersNotConfigured(LintException): def __init__(self): LintException.__init__( self, - "No linters registered! Use `LintRoller.read` " "to register a linter.", + "No linters registered! Use `LintRoller.read` to register a linter.", ) diff --git a/python/mozlint/mozlint/formatters/stylish.py b/python/mozlint/mozlint/formatters/stylish.py index c2ebce9804ba2..23fb4b8625bfb 100644 --- a/python/mozlint/mozlint/formatters/stylish.py +++ b/python/mozlint/mozlint/formatters/stylish.py @@ -29,9 +29,7 @@ class StylishFormatter: fmt = """ {c1}{lineno}{column} {c2}{level}{normal} {message} {c1}{rule}({linter}){source}{normal} -{diff}""".lstrip( - "\n" - ) +{diff}""".lstrip("\n") fmt_summary = ( "{t.bold}{c}\u2716 {problem} ({error}, {warning}{failure}, {fixed}){t.normal}" ) diff --git a/python/mozlint/mozlint/formatters/summary.py b/python/mozlint/mozlint/formatters/summary.py index c71d6105467b1..fb28ba4a137c2 100644 --- a/python/mozlint/mozlint/formatters/summary.py +++ b/python/mozlint/mozlint/formatters/summary.py @@ -33,12 +33,12 @@ def __call__(self, result): ] abspath = mozpath.join(commonprefix, *parts) - summary[abspath][0] += len( - [r for r in result.issues[path] if r.level == "error"] - ) - summary[abspath][1] += len( - [r for r in result.issues[path] if r.level == "warning"] - ) + summary[abspath][0] += len([ + r for r in result.issues[path] if r.level == "error" + ]) + summary[abspath][1] += len([ + r for r in result.issues[path] if r.level == "warning" + ]) summary[abspath][1] += result.suppressed_warnings[path] msg = [] diff --git a/python/mozlint/mozlint/parser.py b/python/mozlint/mozlint/parser.py index b215440374d50..49ebcc7802c5c 100644 --- a/python/mozlint/mozlint/parser.py +++ b/python/mozlint/mozlint/parser.py @@ -39,7 +39,7 @@ def _validate(self, linter): if missing_attrs: raise LinterParseError( relpath, - "Missing required attribute(s): " "{}".format(",".join(missing_attrs)), + "Missing required attribute(s): {}".format(",".join(missing_attrs)), ) if linter["type"] not in supported_types: @@ -54,7 +54,7 @@ def _validate(self, linter): ): raise LinterParseError( relpath, - f"The {attr} directive must be a " "list of strings!", + f"The {attr} directive must be a list of strings!", ) invalid_paths = set() for path in linter[attr]: diff --git a/python/mozlint/mozlint/pathutils.py b/python/mozlint/mozlint/pathutils.py index 86cc002eed573..b6ac22d177591 100644 --- a/python/mozlint/mozlint/pathutils.py +++ b/python/mozlint/mozlint/pathutils.py @@ -196,7 +196,6 @@ def normalize(path): # First handle include/exclude directives # that exist (i.e don't have globs) for inc in include: - # If the include directive is a file and we're specifically linting # it, keep it. if inc.isfile and path.path == inc.path: diff --git a/python/mozlint/mozlint/roller.py b/python/mozlint/mozlint/roller.py index a7ffb0febfa5e..aeafa93cc525d 100644 --- a/python/mozlint/mozlint/roller.py +++ b/python/mozlint/mozlint/roller.py @@ -399,12 +399,9 @@ def roll(self, paths=None, outgoing=None, workdir=None, rev=None, num_procs=None # Make sure all paths are absolute. Join `paths` to cwd and `vcs_paths` to root. paths = set(map(os.path.abspath, paths)) - vcs_paths = set( - [ - os.path.join(self.root, p) if not os.path.isabs(p) else p - for p in vcs_paths - ] - ) + vcs_paths = set([ + os.path.join(self.root, p) if not os.path.isabs(p) else p for p in vcs_paths + ]) num_procs = num_procs or cpu_count() jobs = list(self._generate_jobs(paths, vcs_paths, num_procs)) diff --git a/python/mozlint/test/test_cli.py b/python/mozlint/test/test_cli.py index 13abaf441f927..8a2253468d4b7 100644 --- a/python/mozlint/test/test_cli.py +++ b/python/mozlint/test/test_cli.py @@ -156,15 +156,13 @@ def test_cli_run_with_stdin_filename(run, filedir, capfd, monkeypatch, tmp_path) monkeypatch.setattr("sys.stdin", io.TextIOWrapper(io.BytesIO(b"foobar\n"))) tmpfile = tmp_path / "temp" - run( - [ - "-l", - "string", - f"--stdin-filename={filedir}/foobar.py", - "--dump-stdin-file", - str(tmpfile), - ] - ) + run([ + "-l", + "string", + f"--stdin-filename={filedir}/foobar.py", + "--dump-stdin-file", + str(tmpfile), + ]) out, err = capfd.readouterr() assert out == "" assert tmpfile.read_text() == "foobar\n" diff --git a/python/mozlint/test/test_editor.py b/python/mozlint/test/test_editor.py index 7a15a613a6efc..875e7e85ee406 100644 --- a/python/mozlint/test/test_editor.py +++ b/python/mozlint/test/test_editor.py @@ -28,23 +28,21 @@ def fake_subprocess_call(*args, **kwargs): @pytest.fixture def result(): result = ResultSummary("/fake/root") - result.issues["foo.py"].extend( - [ - Issue( - linter="no-foobar", - path="foo.py", - lineno=1, - message="Oh no!", - ), - Issue( - linter="no-foobar", - path="foo.py", - lineno=3, - column=10, - message="To Yuma!", - ), - ] - ) + result.issues["foo.py"].extend([ + Issue( + linter="no-foobar", + path="foo.py", + lineno=1, + message="Oh no!", + ), + Issue( + linter="no-foobar", + path="foo.py", + lineno=3, + column=10, + message="To Yuma!", + ), + ]) return result diff --git a/python/mozlint/test/test_formatters.py b/python/mozlint/test/test_formatters.py index feded05e82153..b1c3521ef3fa0 100644 --- a/python/mozlint/test/test_formatters.py +++ b/python/mozlint/test/test_formatters.py @@ -67,18 +67,14 @@ {abc}:4:10: baz error: oh no baz {abc}:5: foo-diff error: oh no foo-diff {def}:4:2: bar-not-allowed warning: oh no bar -""".format( - **NORMALISED_PATHS - ).strip(), +""".format(**NORMALISED_PATHS).strip(), }, "summary": { "kwargs": {}, "format": """ {root}/a: 3 errors {root}/d: 0 errors, 1 warning -""".format( - **NORMALISED_PATHS - ).strip(), +""".format(**NORMALISED_PATHS).strip(), }, } diff --git a/python/mozperftest/mozperftest/environment.py b/python/mozperftest/mozperftest/environment.py index 7be0f1f639fdd..35273af7af1f5 100644 --- a/python/mozperftest/mozperftest/environment.py +++ b/python/mozperftest/mozperftest/environment.py @@ -19,9 +19,9 @@ class MachEnvironment(MachLogger): def __init__(self, mach_cmd, flavor="desktop-browser", hooks=None, **kwargs): MachLogger.__init__(self, mach_cmd) self._mach_cmd = mach_cmd - self._mach_args = dict( - [(self._normalize(key), value) for key, value in kwargs.items()] - ) + self._mach_args = dict([ + (self._normalize(key), value) for key, value in kwargs.items() + ]) self.layers = [] if flavor not in FLAVORS: raise NotImplementedError(flavor) diff --git a/python/mozperftest/mozperftest/metrics/common.py b/python/mozperftest/mozperftest/metrics/common.py index 1b510e5c94ec8..780acd8cae0f7 100644 --- a/python/mozperftest/mozperftest/metrics/common.py +++ b/python/mozperftest/mozperftest/metrics/common.py @@ -245,9 +245,9 @@ def filtered_metrics( for data_type, data_info in results.items(): newresults = [] for res in data_info: - if any([met["name"] in res["subtest"] for met in metrics]) and not any( - [met in res["subtest"] for met in exclude] - ): + if any([met["name"] in res["subtest"] for met in metrics]) and not any([ + met in res["subtest"] for met in exclude + ]): res["transformer"] = self.ptnb_config[data_type][ "custom_transformer" ] diff --git a/python/mozperftest/mozperftest/metrics/notebookupload.py b/python/mozperftest/mozperftest/metrics/notebookupload.py index ec53af2b7fdce..e8730439e31cc 100644 --- a/python/mozperftest/mozperftest/metrics/notebookupload.py +++ b/python/mozperftest/mozperftest/metrics/notebookupload.py @@ -16,42 +16,40 @@ class Notebook(Layer): activated = False arguments = COMMON_ARGS - arguments.update( - { - "analysis": { - "nargs": "*", - "default": [], - "help": "List of analyses to run in Iodide.", - }, - "analyze-strings": { - "action": "store_true", - "default": False, - "help": ( - "If set, strings won't be filtered out of the results to analyze in Iodide." - ), - }, - "no-server": { - "action": "store_true", - "default": False, - "help": "If set, the data won't be opened in Iodide.", - }, - "compare-to": { - "nargs": "*", - "default": [], - "help": ( - "Compare the results from this test to the historical data in the folder(s) " - "specified through this option. Only JSON data can be processed for the " - "moment. Each folder containing those JSONs is considered as a distinct " - "data point to compare with the newest run." - ), - }, - "stats": { - "action": "store_true", - "default": False, - "help": "If set, browsertime statistics will be reported.", - }, - } - ) + arguments.update({ + "analysis": { + "nargs": "*", + "default": [], + "help": "List of analyses to run in Iodide.", + }, + "analyze-strings": { + "action": "store_true", + "default": False, + "help": ( + "If set, strings won't be filtered out of the results to analyze in Iodide." + ), + }, + "no-server": { + "action": "store_true", + "default": False, + "help": "If set, the data won't be opened in Iodide.", + }, + "compare-to": { + "nargs": "*", + "default": [], + "help": ( + "Compare the results from this test to the historical data in the folder(s) " + "specified through this option. Only JSON data can be processed for the " + "moment. Each folder containing those JSONs is considered as a distinct " + "data point to compare with the newest run." + ), + }, + "stats": { + "action": "store_true", + "default": False, + "help": "If set, browsertime statistics will be reported.", + }, + }) def run(self, metadata): exclusions = None @@ -73,12 +71,10 @@ def run(self, metadata): raise Exception(f"{dirpath} is not a directory") # TODO: Handle more than just JSON data. for jsonfile in dirpath.rglob("*.json"): - metadata.add_result( - { - "results": str(jsonfile.resolve()), - "name": jsonfile.parent.name, - } - ) + metadata.add_result({ + "results": str(jsonfile.resolve()), + "name": jsonfile.parent.name, + }) results = filtered_metrics( metadata, diff --git a/python/mozperftest/mozperftest/metrics/perfboard/grafana.py b/python/mozperftest/mozperftest/metrics/perfboard/grafana.py index 1fa76ea991ff9..f738ff859637f 100644 --- a/python/mozperftest/mozperftest/metrics/perfboard/grafana.py +++ b/python/mozperftest/mozperftest/metrics/perfboard/grafana.py @@ -26,9 +26,9 @@ def __init__(self, layer, key, host="perfboard.dev.mozaws.net", port=3000): def get_dashboard(self, title): existing = self.client.search.search_dashboards(tag="component") - existing = dict( - [(dashboard["title"].lower(), dashboard["uid"]) for dashboard in existing] - ) + existing = dict([ + (dashboard["title"].lower(), dashboard["uid"]) for dashboard in existing + ]) if title in existing: return self.client.dashboard.get_dashboard(existing[title]) self.layer.debug(f"Creating dashboard {title}") diff --git a/python/mozperftest/mozperftest/metrics/perfboard/influx.py b/python/mozperftest/mozperftest/metrics/perfboard/influx.py index 4f7e27072c26b..7010766032f5b 100644 --- a/python/mozperftest/mozperftest/metrics/perfboard/influx.py +++ b/python/mozperftest/mozperftest/metrics/perfboard/influx.py @@ -17,49 +17,47 @@ class Influx(Layer): name = "perfboard" activated = False arguments = COMMON_ARGS - arguments.update( - { - "dashboard": { - "type": str, - "default": None, - "help": "Name of the dashboard - defaults to the script" - " `component` metadata. When not set, falls back to" - " `perftest`", - }, - "influx-host": { - "type": str, - "default": "perfboard.dev.mozaws.net", - }, - "influx-user": { - "type": str, - "default": "admin", - }, - "influx-port": { - "type": int, - "default": 8086, - }, - "influx-password": { - "type": str, - "default": None, - }, - "influx-db": { - "type": str, - "default": "perf", - }, - "grafana-host": { - "type": str, - "default": "perfboard.dev.mozaws.net", - }, - "grafana-key": { - "type": str, - "default": None, - }, - "grafana-port": { - "type": int, - "default": 3000, - }, - } - ) + arguments.update({ + "dashboard": { + "type": str, + "default": None, + "help": "Name of the dashboard - defaults to the script" + " `component` metadata. When not set, falls back to" + " `perftest`", + }, + "influx-host": { + "type": str, + "default": "perfboard.dev.mozaws.net", + }, + "influx-user": { + "type": str, + "default": "admin", + }, + "influx-port": { + "type": int, + "default": 8086, + }, + "influx-password": { + "type": str, + "default": None, + }, + "influx-db": { + "type": str, + "default": "perf", + }, + "grafana-host": { + "type": str, + "default": "perfboard.dev.mozaws.net", + }, + "grafana-key": { + "type": str, + "default": None, + }, + "grafana-port": { + "type": int, + "default": 3000, + }, + }) def _setup(self): venv = self.mach_cmd.virtualenv_manager @@ -157,9 +155,9 @@ def run(self, metadata): metric_name = line["subtest"] short_name = metric_name.split(".")[-1] short_name = short_name.lower() - if metrics and not any( - [m.lower().startswith(short_name.lower()) for m in metrics] - ): + if metrics and not any([ + m.lower().startswith(short_name.lower()) for m in metrics + ]): continue values = [v["value"] for v in line["data"]] data[short_name].extend(values) diff --git a/python/mozperftest/mozperftest/metrics/perfherder.py b/python/mozperftest/mozperftest/metrics/perfherder.py index 1d445e26e9dcf..89391ff56732c 100644 --- a/python/mozperftest/mozperftest/metrics/perfherder.py +++ b/python/mozperftest/mozperftest/metrics/perfherder.py @@ -31,23 +31,21 @@ class Perfherder(Layer): activated = False arguments = COMMON_ARGS - arguments.update( - { - "stats": { - "action": "store_true", - "default": False, - "help": "If set, browsertime statistics will be reported.", - }, - "timestamp": { - "type": float, - "default": None, - "help": ( - "Timestamp to use for the perfherder data. Can be the " - "current date or a past date if needed." - ), - }, - } - ) + arguments.update({ + "stats": { + "action": "store_true", + "default": False, + "help": "If set, browsertime statistics will be reported.", + }, + "timestamp": { + "type": float, + "default": None, + "help": ( + "Timestamp to use for the perfherder data. Can be the " + "current date or a past date if needed." + ), + }, + }) def run(self, metadata): """Processes the given results into a perfherder-formatted data blob. diff --git a/python/mozperftest/mozperftest/metrics/utils.py b/python/mozperftest/mozperftest/metrics/utils.py index a947434684567..2e09b2b1292c8 100644 --- a/python/mozperftest/mozperftest/metrics/utils.py +++ b/python/mozperftest/mozperftest/metrics/utils.py @@ -19,9 +19,14 @@ # These are the properties we know about in the schema. # If anything other than these is present, then we will # fail validation. -KNOWN_PERFHERDER_PROPS = set( - ["name", "value", "unit", "lowerIsBetter", "shouldAlert", "alertThreshold"] -) +KNOWN_PERFHERDER_PROPS = set([ + "name", + "value", + "unit", + "lowerIsBetter", + "shouldAlert", + "alertThreshold", +]) KNOWN_SUITE_PROPS = set( set(["results", "transformer", "transformer-options", "extraOptions", "framework"]) | KNOWN_PERFHERDER_PROPS @@ -125,7 +130,7 @@ def _check(field): raise ValueError(f"Unexpected metrics definition {field}") if sfield[0] not in KNOWN_SUITE_PROPS: raise ValueError( - f"Unknown field '{sfield[0]}', should be in " f"{KNOWN_SUITE_PROPS}" + f"Unknown field '{sfield[0]}', should be in {KNOWN_SUITE_PROPS}" ) sfield = [sfield[0], sfield[2]] diff --git a/python/mozperftest/mozperftest/metrics/visualmetrics.py b/python/mozperftest/mozperftest/metrics/visualmetrics.py index 1003834b9e998..036048ce3bc5c 100644 --- a/python/mozperftest/mozperftest/metrics/visualmetrics.py +++ b/python/mozperftest/mozperftest/metrics/visualmetrics.py @@ -87,14 +87,12 @@ def run(self, metadata): self.info(f"Treated {treated} videos.") if len(self.metrics) > 0: - metadata.add_result( - { - "name": metadata.script["name"] + "-vm", - "framework": {"name": "mozperftest"}, - "transformer": "mozperftest.metrics.visualmetrics:VisualData", - "results": list(self.metrics.values()), - } - ) + metadata.add_result({ + "name": metadata.script["name"] + "-vm", + "framework": {"name": "mozperftest"}, + "transformer": "mozperftest.metrics.visualmetrics:VisualData", + "results": list(self.metrics.values()), + }) # we also extend --perfherder-metrics and --console-metrics if they # are activated diff --git a/python/mozperftest/mozperftest/runner.py b/python/mozperftest/mozperftest/runner.py index 86ee812605435..1830b05fc5743 100644 --- a/python/mozperftest/mozperftest/runner.py +++ b/python/mozperftest/mozperftest/runner.py @@ -14,6 +14,7 @@ When the module is executed directly, if the --on-try option is used, it will fetch arguments from Tascluster's parameters. """ + import json import logging import os diff --git a/python/mozperftest/mozperftest/system/geckoprofiler.py b/python/mozperftest/mozperftest/system/geckoprofiler.py index 0ae545c8e41dd..64c95f02d4e00 100644 --- a/python/mozperftest/mozperftest/system/geckoprofiler.py +++ b/python/mozperftest/mozperftest/system/geckoprofiler.py @@ -80,9 +80,9 @@ def start(self, geckoprofiler_opts=None): config_content = f"""env: MOZ_PROFILER_STARTUP: 1 - MOZ_PROFILER_STARTUP_INTERVAL: {geckoprofiler_opts['interval']} - MOZ_PROFILER_STARTUP_FEATURES: {geckoprofiler_opts['features']} - MOZ_PROFILER_STARTUP_FILTERS: {geckoprofiler_opts['filters']} + MOZ_PROFILER_STARTUP_INTERVAL: {geckoprofiler_opts["interval"]} + MOZ_PROFILER_STARTUP_FEATURES: {geckoprofiler_opts["features"]} + MOZ_PROFILER_STARTUP_FILTERS: {geckoprofiler_opts["filters"]} """.encode() with tempfile.NamedTemporaryFile(delete=False) as config_file: diff --git a/python/mozperftest/mozperftest/system/proxy.py b/python/mozperftest/mozperftest/system/proxy.py index f9cfa2ac2cf10..3938a93e4a729 100644 --- a/python/mozperftest/mozperftest/system/proxy.py +++ b/python/mozperftest/mozperftest/system/proxy.py @@ -160,9 +160,9 @@ def run(self, metadata): if metadata.flavor == "mobile-browser": command.extend(["--tool=%s" % "mitmproxy-android"]) command.extend(["--binary=android"]) - command.extend( - [f"--app={get_pretty_app_name(self.get_arg('android-app-name'))}"] - ) + command.extend([ + f"--app={get_pretty_app_name(self.get_arg('android-app-name'))}" + ]) else: command.extend(["--tool=%s" % "mitmproxy"]) # XXX See bug 1712337, we need a single point where we can get the binary used from diff --git a/python/mozperftest/mozperftest/test/alert.py b/python/mozperftest/mozperftest/test/alert.py index e6cb079707274..2d13eb132af4f 100644 --- a/python/mozperftest/mozperftest/test/alert.py +++ b/python/mozperftest/mozperftest/test/alert.py @@ -462,12 +462,10 @@ def run(self, metadata): text=False, ) if test not in self.perfherder_data: - failed_commands.append( - { - "cmd": cmd, - "test": test, - } - ) + failed_commands.append({ + "cmd": cmd, + "test": test, + }) # Output results in a more readable manner for test, perfherder_data in self.perfherder_data.items(): diff --git a/python/mozperftest/mozperftest/test/androidlog.py b/python/mozperftest/mozperftest/test/androidlog.py index 88bf01f2feae9..95d480326a952 100644 --- a/python/mozperftest/mozperftest/test/androidlog.py +++ b/python/mozperftest/mozperftest/test/androidlog.py @@ -50,13 +50,11 @@ def __call__(self, metadata): "transform-subtest-name": self.get_arg("subtest-name"), } - metadata.add_result( - { - "results": str(self._get_logcat()), - "transformer": "LogCatTimeTransformer", - "transformer-options": options, - "name": "LogCat", - } - ) + metadata.add_result({ + "results": str(self._get_logcat()), + "transformer": "LogCatTimeTransformer", + "transformer-options": options, + "name": "LogCat", + }) return metadata diff --git a/python/mozperftest/mozperftest/test/browsertime/runner.py b/python/mozperftest/mozperftest/test/browsertime/runner.py index 4600807350b7a..da2a12cf4b4d1 100644 --- a/python/mozperftest/mozperftest/test/browsertime/runner.py +++ b/python/mozperftest/mozperftest/test/browsertime/runner.py @@ -353,9 +353,10 @@ def run(self, metadata): existing = self.get_arg("browsertime-existing-results") if existing: - metadata.add_result( - {"results": existing, "name": self._test_script["name"]} - ) + metadata.add_result({ + "results": existing, + "name": self._test_script["name"], + }) return metadata cycles = self.get_arg("cycles", 1) @@ -464,8 +465,9 @@ def _one_cycle(self, metadata, result_dir): if exit_code != 0: raise NodeException(exit_code) - metadata.add_result( - {"results": str(result_dir), "name": self._test_script["name"]} - ) + metadata.add_result({ + "results": str(result_dir), + "name": self._test_script["name"], + }) return metadata diff --git a/python/mozperftest/mozperftest/test/browsertime/visualtools.py b/python/mozperftest/mozperftest/test/browsertime/visualtools.py index c46175760a266..ddaf8dff7d2dc 100644 --- a/python/mozperftest/mozperftest/test/browsertime/visualtools.py +++ b/python/mozperftest/mozperftest/test/browsertime/visualtools.py @@ -1,8 +1,8 @@ # 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/. -""" Collects visualmetrics dependencies. -""" +"""Collects visualmetrics dependencies.""" + import contextlib import os import subprocess diff --git a/python/mozperftest/mozperftest/test/mochitest.py b/python/mozperftest/mozperftest/test/mochitest.py index 5d72ee6e64cf7..1fc977cc91e73 100644 --- a/python/mozperftest/mozperftest/test/mochitest.py +++ b/python/mozperftest/mozperftest/test/mochitest.py @@ -138,13 +138,11 @@ def _enable_gecko_profiling(self): if self.get_arg("gecko-profile"): gecko_profile_args.append("--profiler") - gecko_profile_args.extend( - [ - f"--setenv=MOZ_PROFILER_STARTUP_FEATURES={gecko_profile_features}", - f"--setenv=MOZ_PROFILER_STARTUP_FILTERS={gecko_profile_threads}", - f"--setenv=MOZ_PROFILER_STARTUP_ENTRIES={gecko_profile_entries}", - ] - ) + gecko_profile_args.extend([ + f"--setenv=MOZ_PROFILER_STARTUP_FEATURES={gecko_profile_features}", + f"--setenv=MOZ_PROFILER_STARTUP_FILTERS={gecko_profile_threads}", + f"--setenv=MOZ_PROFILER_STARTUP_ENTRIES={gecko_profile_entries}", + ]) if gecko_profile_interval: gecko_profile_args.append( f"--setenv=MOZ_PROFILER_STARTUP_INTERVAL={gecko_profile_interval}" @@ -192,23 +190,19 @@ def _setup_mochitest_android_args(self, metadata): if not ON_TRY: os.environ["MOZ_HOST_BIN"] = self.mach_cmd.bindir - mochitest_android_args.extend( - [ - f"--setenv=MOZ_HOST_BIN={os.environ['MOZ_HOST_BIN']}", - ] - ) + mochitest_android_args.extend([ + f"--setenv=MOZ_HOST_BIN={os.environ['MOZ_HOST_BIN']}", + ]) else: os.environ["MOZ_HOST_BIN"] = str( Path(os.getenv("MOZ_FETCHES_DIR"), "hostutils") ) - mochitest_android_args.extend( - [ - f"--setenv=MOZ_HOST_BIN={os.environ['MOZ_HOST_BIN']}", - f"--remote-webserver={os.environ['HOST_IP']}", - "--http-port=8854", - "--ssl-port=4454", - ] - ) + mochitest_android_args.extend([ + f"--setenv=MOZ_HOST_BIN={os.environ['MOZ_HOST_BIN']}", + f"--remote-webserver={os.environ['HOST_IP']}", + "--http-port=8854", + "--ssl-port=4454", + ]) return mochitest_android_args @@ -240,8 +234,7 @@ def remote_run(self, test, metadata): ) if not manifest_flavor: raise MissingMochitestInformation( - "Mochitest flavor needs to be provided" - "(e.g. plain, browser-chrome, ...)" + "Mochitest flavor needs to be provided(e.g. plain, browser-chrome, ...)" ) manifest_path = Path(test.parent, manifest_name) @@ -307,7 +300,6 @@ def run(self, metadata): results = [] cycles = self.get_arg("cycles", 1) for cycle in range(1, cycles + 1): - metadata.run_hook( "before_cycle", metadata, self.env, cycle, metadata.script ) @@ -358,13 +350,11 @@ def run(self, metadata): if len(results) == 0: raise NoPerfMetricsError("mochitest") - metadata.add_result( - { - "name": test_name, - "framework": {"name": "mozperftest"}, - "transformer": "mozperftest.test.mochitest:MochitestData", - "results": results, - } - ) + metadata.add_result({ + "name": test_name, + "framework": {"name": "mozperftest"}, + "transformer": "mozperftest.test.mochitest:MochitestData", + "results": results, + }) return metadata diff --git a/python/mozperftest/mozperftest/test/shellscript.py b/python/mozperftest/mozperftest/test/shellscript.py index 8d2aadca4d614..314bc53b8ded9 100644 --- a/python/mozperftest/mozperftest/test/shellscript.py +++ b/python/mozperftest/mozperftest/test/shellscript.py @@ -200,14 +200,12 @@ def output_timeout_handler(proc): shutil.copytree(testing_dir, output_dir) self.env.set_arg("output", output_dir) - metadata.add_result( - { - "name": test["name"], - "framework": {"name": "mozperftest"}, - "transformer": "mozperftest.test.shellscript:ShellScriptData", - "shouldAlert": True, - "results": self.parse_metrics(), - } - ) + metadata.add_result({ + "name": test["name"], + "framework": {"name": "mozperftest"}, + "transformer": "mozperftest.test.shellscript:ShellScriptData", + "shouldAlert": True, + "results": self.parse_metrics(), + }) return metadata diff --git a/python/mozperftest/mozperftest/test/webpagetest.py b/python/mozperftest/mozperftest/test/webpagetest.py index 77a9119d1e90b..1b1a6f25b5cb5 100644 --- a/python/mozperftest/mozperftest/test/webpagetest.py +++ b/python/mozperftest/mozperftest/test/webpagetest.py @@ -358,22 +358,20 @@ def confirm_correct_browser_and_location(self, data, options): def add_wpt_run_to_metadata(self, wbt_run, metadata, website): requested_values = self.extract_desired_values_from_wpt_run(wbt_run) if requested_values is not None: - metadata.add_result( - { - "name": ("WebPageTest:" + re.match(r"(^.\w+)", website)[0]), - "framework": {"name": "mozperftest"}, - "transformer": "mozperftest.test.webpagetest:WebPageTestData", - "shouldAlert": True, - "results": [ - { - "values": [metric_value], - "name": metric_name, - "shouldAlert": True, - } - for metric_name, metric_value in requested_values.items() - ], - } - ) + metadata.add_result({ + "name": ("WebPageTest:" + re.match(r"(^.\w+)", website)[0]), + "framework": {"name": "mozperftest"}, + "transformer": "mozperftest.test.webpagetest:WebPageTestData", + "shouldAlert": True, + "results": [ + { + "values": [metric_value], + "name": metric_name, + "shouldAlert": True, + } + for metric_name, metric_value in requested_values.items() + ], + }) def extract_desired_values_from_wpt_run(self, wpt_run): view_types = ["firstView"] diff --git a/python/mozperftest/mozperftest/test/xpcshell.py b/python/mozperftest/mozperftest/test/xpcshell.py index bbcdad1ce44aa..0dc014bb888b9 100644 --- a/python/mozperftest/mozperftest/test/xpcshell.py +++ b/python/mozperftest/mozperftest/test/xpcshell.py @@ -166,17 +166,15 @@ def run(self, metadata): if len(results.items()) == 0: raise NoPerfMetricsError("xpcshell") - metadata.add_result( - { - "name": test.name, - "framework": {"name": "mozperftest"}, - "transformer": "mozperftest.test.xpcshell:XPCShellData", - "results": [ - {"values": measures, "name": subtest} - for subtest, measures in results.items() - ], - } - ) + metadata.add_result({ + "name": test.name, + "framework": {"name": "mozperftest"}, + "transformer": "mozperftest.test.xpcshell:XPCShellData", + "results": [ + {"values": measures, "name": subtest} + for subtest, measures in results.items() + ], + }) return metadata diff --git a/python/mozperftest/mozperftest/tests/test_alert.py b/python/mozperftest/mozperftest/tests/test_alert.py index fbf2a323cf2d2..c6caf2eed38de 100644 --- a/python/mozperftest/mozperftest/tests/test_alert.py +++ b/python/mozperftest/mozperftest/tests/test_alert.py @@ -45,9 +45,7 @@ def test_alert_basic_command(alert_json, expected_command): "mozperftest.test.alert.requests.get" ) as mocked_request, mock.patch( "mozperftest.test.alert.mozprocess" - ) as mocked_mozprocess, ( - MOCK_DATA_DIR / alert_json - ).open() as f: + ) as mocked_mozprocess, (MOCK_DATA_DIR / alert_json).open() as f: mocked_response = mock.MagicMock() mocked_response.configure_mock(status_code=200) mocked_response.json.return_value = json.load(f) @@ -94,9 +92,7 @@ def test_alert_basic_command_test_specification(alert_json, tests, expected_comm "mozperftest.test.alert.requests.get" ) as mocked_request, mock.patch( "mozperftest.test.alert.mozprocess" - ) as mocked_mozprocess, ( - MOCK_DATA_DIR / alert_json - ).open() as f: + ) as mocked_mozprocess, (MOCK_DATA_DIR / alert_json).open() as f: mocked_response = mock.MagicMock() mocked_response.configure_mock(status_code=200) mocked_response.json.return_value = json.load(f) @@ -298,9 +294,7 @@ def test_alert_exact_command( "mozperftest.test.alert.requests.get" ) as mocked_request, mock.patch( "mozperftest.test.alert.mozprocess" - ) as mocked_mozprocess, ( - MOCK_DATA_DIR / alert_json - ).open() as alert_file, ( + ) as mocked_mozprocess, (MOCK_DATA_DIR / alert_json).open() as alert_file, ( MOCK_DATA_DIR / task_info_json ).open() as task_file: mocked_alert_response = mock.MagicMock() @@ -337,9 +331,7 @@ def test_alert_basic_command_failed(): "mozperftest.test.alert.requests.get" ) as mocked_request, mock.patch( "mozperftest.test.alert.mozprocess" - ) as mocked_mozprocess, ( - MOCK_DATA_DIR / alert_json - ).open() as f: + ) as mocked_mozprocess, (MOCK_DATA_DIR / alert_json).open() as f: mocked_response = mock.MagicMock() mocked_response.configure_mock(status_code=200) mocked_response.json.return_value = json.load(f) diff --git a/python/mozperftest/mozperftest/tests/test_argparser.py b/python/mozperftest/mozperftest/tests/test_argparser.py index 35051772b1f4b..831b0c2c9d7aa 100644 --- a/python/mozperftest/mozperftest/tests/test_argparser.py +++ b/python/mozperftest/mozperftest/tests/test_argparser.py @@ -31,18 +31,20 @@ def test_argparser_defaults(): def test_options(): assert Options.args["--proxy"]["help"] == "Activates the proxy layer" assert Options.args["--no-browsertime"]["help"] == ( - "Deactivates the " "browsertime layer" + "Deactivates the browsertime layer" ) def test_layer_option(): parser = PerftestArgumentParser() - assert parser.parse_args(["--notebook-metrics"]) == parser.parse_args( - ["--notebook-metrics", "--notebook"] - ) - assert parser.parse_known_args(["--notebook-metrics"]) == parser.parse_known_args( - ["--notebook-metrics", "--notebook"] - ) + assert parser.parse_args(["--notebook-metrics"]) == parser.parse_args([ + "--notebook-metrics", + "--notebook", + ]) + assert parser.parse_known_args(["--notebook-metrics"]) == parser.parse_known_args([ + "--notebook-metrics", + "--notebook", + ]) def test_bad_test_date(): diff --git a/python/mozperftest/mozperftest/tests/test_browsertime.py b/python/mozperftest/mozperftest/tests/test_browsertime.py index 6345d116ca5af..d094fedc56852 100644 --- a/python/mozperftest/mozperftest/tests/test_browsertime.py +++ b/python/mozperftest/mozperftest/tests/test_browsertime.py @@ -290,9 +290,9 @@ def test_add_options(): "mozperftest.test.browsertime.runner.BrowsertimeRunner._setup_node_packages" ) def test_install_url(*mocked): - url = "https://here/tarball/" + "".join( - [random.choice(string.hexdigits[:-6]) for c in range(40)] - ) + url = "https://here/tarball/" + "".join([ + random.choice(string.hexdigits[:-6]) for c in range(40) + ]) mach, metadata, env = get_running_env( browsertime_install_url=url, tests=[EXAMPLE_TEST], diff --git a/python/mozperftest/mozperftest/tests/test_change_detector.py b/python/mozperftest/mozperftest/tests/test_change_detector.py index f9cf6c644d500..663c1458e5350 100644 --- a/python/mozperftest/mozperftest/tests/test_change_detector.py +++ b/python/mozperftest/mozperftest/tests/test_change_detector.py @@ -50,49 +50,43 @@ async def test_change_detector_basic(kwargs=None, return_value=({}, {})): @pytest.mark.asyncio async def test_change_detector_with_task_name(): - await test_change_detector_basic( - { - "task_names": ["test-platform/opt-browsertime-test"], + await test_change_detector_basic({ + "task_names": ["test-platform/opt-browsertime-test"], + "new_test_name": None, + "platform": None, + "new_platform": None, + "base_branch": "try", + "new_branch": "try", + "base_revision": "99", + "new_revision": "99", + }) + + +@pytest.mark.asyncio +async def test_change_detector_option_failure(): + with pytest.raises(Exception): + await test_change_detector_basic({ + "test_name": None, "new_test_name": None, - "platform": None, + "platform": "test-platform/opt", "new_platform": None, "base_branch": "try", "new_branch": "try", "base_revision": "99", "new_revision": "99", - } - ) - - -@pytest.mark.asyncio -async def test_change_detector_option_failure(): - with pytest.raises(Exception): - await test_change_detector_basic( - { - "test_name": None, - "new_test_name": None, - "platform": "test-platform/opt", - "new_platform": None, - "base_branch": "try", - "new_branch": "try", - "base_revision": "99", - "new_revision": "99", - } - ) + }) with pytest.raises(Exception): - await test_change_detector_basic( - { - "test_name": "browsertime-test", - "new_test_name": None, - "platform": None, - "new_platform": None, - "base_branch": "try", - "new_branch": "try", - "base_revision": "99", - "new_revision": "99", - } - ) + await test_change_detector_basic({ + "test_name": "browsertime-test", + "new_test_name": None, + "platform": None, + "new_platform": None, + "base_branch": "try", + "new_branch": "try", + "base_revision": "99", + "new_revision": "99", + }) @pytest.mark.asyncio diff --git a/python/mozperftest/mozperftest/tests/test_functionaltestrunner.py b/python/mozperftest/mozperftest/tests/test_functionaltestrunner.py index 20f8362d60a07..e9c55abec008d 100644 --- a/python/mozperftest/mozperftest/tests/test_functionaltestrunner.py +++ b/python/mozperftest/mozperftest/tests/test_functionaltestrunner.py @@ -12,9 +12,7 @@ def test_functionaltestrunner_pass(): "mozperftest.test.functionaltestrunner.load_class_from_path" ) as load_class_path_mock, mock.patch( "mozperftest.test.functionaltestrunner.FunctionalTestProcessor" - ), mock.patch( - "mozperftest.test.functionaltestrunner.mozlog" - ): + ), mock.patch("mozperftest.test.functionaltestrunner.mozlog"): test_mock = mock.MagicMock() test_mock.test.return_value = 0 load_class_path_mock.return_value = test_mock diff --git a/python/mozperftest/mozperftest/tests/test_influx.py b/python/mozperftest/mozperftest/tests/test_influx.py index 99382ab0ea399..b19752cb7ddc1 100644 --- a/python/mozperftest/mozperftest/tests/test_influx.py +++ b/python/mozperftest/mozperftest/tests/test_influx.py @@ -62,20 +62,18 @@ def mocks(): responses.add( responses.GET, re.compile(secrets), - body=json.dumps( - { - "secret": { - "influx_host": "influxdb", - "influx_port": 0, - "influx_user": "admin", - "influx_password": "pass", - "influx_db": "db", - "grafana_key": "xxx", - "grafana_host": "grafana", - "grafana_port": 0, - } + body=json.dumps({ + "secret": { + "influx_host": "influxdb", + "influx_port": 0, + "influx_user": "admin", + "influx_password": "pass", + "influx_db": "db", + "grafana_key": "xxx", + "grafana_host": "grafana", + "grafana_port": 0, } - ), + }), status=200, ) diff --git a/python/mozperftest/mozperftest/tests/test_mochitest.py b/python/mozperftest/mozperftest/tests/test_mochitest.py index 6535009077c25..6cb3a9584647f 100644 --- a/python/mozperftest/mozperftest/tests/test_mochitest.py +++ b/python/mozperftest/mozperftest/tests/test_mochitest.py @@ -207,9 +207,7 @@ def test_mochitest_profiling(fake_file_path): "mozperftest.test.functionaltestrunner.FunctionalTestRunner.test" ) as test_mock, mock.patch( "mozperftest.test.mochitest.install_requirements_file" - ), mock.patch( - "mozperftest.test.mochitest.Path" - ): + ), mock.patch("mozperftest.test.mochitest.Path"): test_mock.return_value = (0, mock.MagicMock()) try: with pytest.raises(NoPerfMetricsError): diff --git a/python/mozperftest/mozperftest/tests/test_notebookupload.py b/python/mozperftest/mozperftest/tests/test_notebookupload.py index f586e0d699278..9d1f3b162ab66 100644 --- a/python/mozperftest/mozperftest/tests/test_notebookupload.py +++ b/python/mozperftest/mozperftest/tests/test_notebookupload.py @@ -54,9 +54,9 @@ def test_notebookupload_with_filter(notebook, no_filter): for data in data_dict["data"]: assert type(data["value"]) in (int, float) - notebook.assert_has_calls( - [mock.call().post_to_iodide(["scatterplot"], start_local_server=True)] - ) + notebook.assert_has_calls([ + mock.call().post_to_iodide(["scatterplot"], start_local_server=True) + ]) @pytest.mark.parametrize("stats", [False, True]) @@ -88,9 +88,9 @@ def test_compare_to_success(notebook, stats): else: assert any("statistics" in element["subtest"] for element in kwargs["data"]) - notebook.assert_has_calls( - [mock.call().post_to_iodide(["compare"], start_local_server=True)] - ) + notebook.assert_has_calls([ + mock.call().post_to_iodide(["compare"], start_local_server=True) + ]) @pytest.mark.parametrize("filepath", ["invalidPath", str(BT_DATA)]) diff --git a/python/mozperftest/mozperftest/tests/test_perfherder.py b/python/mozperftest/mozperftest/tests/test_perfherder.py index 7f6f99c3f52b4..d37e77dd0e26c 100644 --- a/python/mozperftest/mozperftest/tests/test_perfherder.py +++ b/python/mozperftest/mozperftest/tests/test_perfherder.py @@ -229,14 +229,12 @@ def test_perfherder_simple_names(): # Check if only firstPaint/resource metrics were obtained and # that simplifications occurred - assert all( - [ - "firstPaint" in subtest["name"] - or "duration" in subtest["name"] - or "count" in subtest["name"] - for subtest in output["suites"][0]["subtests"] - ] - ) + assert all([ + "firstPaint" in subtest["name"] + or "duration" in subtest["name"] + or "count" in subtest["name"] + for subtest in output["suites"][0]["subtests"] + ]) found_all = {"firstPaint": False, "count": False, "duration": False} for subtest in output["suites"][0]["subtests"]: @@ -253,23 +251,19 @@ def test_perfherder_simple_names(): # Statistics are not simplified by default assert ( - len( - [ - subtest - for subtest in output["suites"][0]["subtests"] - if "statistics" in subtest["name"] - ] - ) + len([ + subtest + for subtest in output["suites"][0]["subtests"] + if "statistics" in subtest["name"] + ]) == 27 ) assert ( - len( - [ - subtest - for subtest in output["suites"][0]["subtests"] - if "statistics" not in subtest["name"] - ] - ) + len([ + subtest + for subtest in output["suites"][0]["subtests"] + if "statistics" not in subtest["name"] + ]) == 3 ) @@ -305,14 +299,12 @@ def test_perfherder_names_simplified_with_no_exclusions(): # In this case, some metrics will be called "median", "mean", etc. # since those are the simplifications of the first statistics entries # that were found. - assert not all( - [ - "firstPaint" in subtest["name"] - or "duration" in subtest["name"] - or "count" in subtest["name"] - for subtest in output["suites"][0]["subtests"] - ] - ) + assert not all([ + "firstPaint" in subtest["name"] + or "duration" in subtest["name"] + or "count" in subtest["name"] + for subtest in output["suites"][0]["subtests"] + ]) found_all = {"firstPaint": False, "count": False, "duration": False} for subtest in output["suites"][0]["subtests"]: @@ -326,23 +318,19 @@ def test_perfherder_names_simplified_with_no_exclusions(): # Only a portion of the metrics should still have statistics in # their name due to a naming conflict that only emits a warning assert ( - len( - [ - subtest - for subtest in output["suites"][0]["subtests"] - if "statistics" in subtest["name"] - ] - ) + len([ + subtest + for subtest in output["suites"][0]["subtests"] + if "statistics" in subtest["name"] + ]) == 18 ) assert ( - len( - [ - subtest - for subtest in output["suites"][0]["subtests"] - if "statistics" not in subtest["name"] - ] - ) + len([ + subtest + for subtest in output["suites"][0]["subtests"] + if "statistics" not in subtest["name"] + ]) == 12 ) @@ -370,9 +358,11 @@ def test_perfherder_with_extra_metadata_options(): output = json.loads(f.read()) assert len(output["suites"]) == 1 - assert sorted(output["suites"][0]["extraOptions"]) == sorted( - ["option", "second-option", "simpleperf"] - ) + assert sorted(output["suites"][0]["extraOptions"]) == sorted([ + "option", + "second-option", + "simpleperf", + ]) def test_perfherder_with_extra_options(): @@ -397,9 +387,10 @@ def test_perfherder_with_extra_options(): output = json.loads(f.read()) assert len(output["suites"]) == 1 - assert sorted(output["suites"][0]["extraOptions"]) == sorted( - ["option", "second-option"] - ) + assert sorted(output["suites"][0]["extraOptions"]) == sorted([ + "option", + "second-option", + ]) def test_perfherder_with_alerting(): @@ -425,20 +416,16 @@ def test_perfherder_with_alerting(): assert len(output["suites"]) == 1 assert sorted(output["suites"][0]["extraOptions"]) == sorted(["option"]) - assert all( - [ - subtest["shouldAlert"] - for subtest in output["suites"][0]["subtests"] - if "resource" in subtest["name"] - ] - ) - assert not all( - [ - subtest["shouldAlert"] - for subtest in output["suites"][0]["subtests"] - if "firstPaint" in subtest["name"] - ] - ) + assert all([ + subtest["shouldAlert"] + for subtest in output["suites"][0]["subtests"] + if "resource" in subtest["name"] + ]) + assert not all([ + subtest["shouldAlert"] + for subtest in output["suites"][0]["subtests"] + if "firstPaint" in subtest["name"] + ]) def test_perfherder_with_subunits(): @@ -463,20 +450,16 @@ def test_perfherder_with_subunits(): output = json.loads(f.read()) assert len(output["suites"]) == 1 - assert all( - [ - subtest["unit"] == "a-unit" - for subtest in output["suites"][0]["subtests"] - if "resource" in subtest["name"] - ] - ) - assert all( - [ - subtest["unit"] == "ms" - for subtest in output["suites"][0]["subtests"] - if "firstPaint" in subtest["name"] - ] - ) + assert all([ + subtest["unit"] == "a-unit" + for subtest in output["suites"][0]["subtests"] + if "resource" in subtest["name"] + ]) + assert all([ + subtest["unit"] == "ms" + for subtest in output["suites"][0]["subtests"] + if "firstPaint" in subtest["name"] + ]) def test_perfherder_with_supraunits(): @@ -503,20 +486,16 @@ def test_perfherder_with_supraunits(): assert len(output["suites"]) == 1 assert output["suites"][0]["unit"] == "new-unit" - assert all( - [ - subtest["unit"] == "a-unit" - for subtest in output["suites"][0]["subtests"] - if "resource" in subtest["name"] - ] - ) - assert all( - [ - subtest["unit"] == "new-unit" - for subtest in output["suites"][0]["subtests"] - if "firstPaint" in subtest["name"] - ] - ) + assert all([ + subtest["unit"] == "a-unit" + for subtest in output["suites"][0]["subtests"] + if "resource" in subtest["name"] + ]) + assert all([ + subtest["unit"] == "new-unit" + for subtest in output["suites"][0]["subtests"] + if "firstPaint" in subtest["name"] + ]) def test_perfherder_transforms(): @@ -560,18 +539,16 @@ def processor(groups): return (float(groups[0]) * 1000) + float(groups[1]) re_w_group = r".*Displayed.*org\.mozilla\.fennec_aurora.*\+([\d]+)s([\d]+)ms.*" - metadata.add_result( - { - "results": str(HERE / "data" / "home_activity.txt"), - "transformer": "LogCatTimeTransformer", - "transformer-options": { - "first-timestamp": re_w_group, - "processor": processor, - "transform-subtest-name": "TimeToDisplayed", - }, - "name": "LogCat", - } - ) + metadata.add_result({ + "results": str(HERE / "data" / "home_activity.txt"), + "transformer": "LogCatTimeTransformer", + "transformer-options": { + "first-timestamp": re_w_group, + "processor": processor, + "transform-subtest-name": "TimeToDisplayed", + }, + "name": "LogCat", + }) with temp_file() as output: env.set_arg("output", output) diff --git a/python/mozperftest/mozperftest/tests/test_perftestnotebook.py b/python/mozperftest/mozperftest/tests/test_perftestnotebook.py index 58debe9343a0d..6fe350e673a4e 100644 --- a/python/mozperftest/mozperftest/tests/test_perftestnotebook.py +++ b/python/mozperftest/mozperftest/tests/test_perftestnotebook.py @@ -66,9 +66,10 @@ def mocked_open(self, *args, **kwargs): assert list_of_calls.count(mock.call().__enter__()) == 3 browser.assert_called_with(str(upload_file_path)) - server.assert_has_calls( - [mock.call().serve_forever(), mock.call().server_close()] - ) + server.assert_has_calls([ + mock.call().serve_forever(), + mock.call().server_close(), + ]) if __name__ == "__main__": diff --git a/python/mozperftest/mozperftest/tests/test_runner.py b/python/mozperftest/mozperftest/tests/test_runner.py index 4b65775e99814..bfbc7f9337f20 100644 --- a/python/mozperftest/mozperftest/tests/test_runner.py +++ b/python/mozperftest/mozperftest/tests/test_runner.py @@ -48,17 +48,13 @@ def test_side_by_side(arg, patched_mozperftest_tools): "mozperftest.runner._create_artifacts_dir", return_value="fake_path" ) as _, mock.patch( "mozperftest.runner._save_params", return_value="fake_path" - ) as _, mock.patch( - "sys.modules", return_value=mock.MagicMock() - ) as _: - main( - [ - "tools", - "side-by-side", - "-t", - "fake-test-name", - ] - ) + ) as _, mock.patch("sys.modules", return_value=mock.MagicMock()) as _: + main([ + "tools", + "side-by-side", + "-t", + "fake-test-name", + ]) if __name__ == "__main__": diff --git a/python/mozperftest/mozperftest/tests/test_simpleperf.py b/python/mozperftest/mozperftest/tests/test_simpleperf.py index d5a917a354b5a..e6953352e39e9 100644 --- a/python/mozperftest/mozperftest/tests/test_simpleperf.py +++ b/python/mozperftest/mozperftest/tests/test_simpleperf.py @@ -580,9 +580,7 @@ def test_local_simpleperf_symbolicate_timeout(tmp_path): ) as mock_popen, mock.patch( "mozperftest.system.simpleperf.find_node_executable", return_value=[str(node_path)], - ), mock.patch.object( - profiler, "_cleanup" - ) as mock_cleanup: + ), mock.patch.object(profiler, "_cleanup") as mock_cleanup: # Mock processes import_process = make_mock_process(context=True) @@ -682,14 +680,9 @@ def test_ci_simpleperf_symbolicate(tmp_path): clear=False, ), mock.patch("mozperftest.system.simpleperf.ON_TRY", True), mock.patch( "mozperftest.utils.ON_TRY", True - ), mock.patch( - "tempfile.mkdtemp", return_value=str(mock_work_dir_path) - ), mock.patch( + ), mock.patch("tempfile.mkdtemp", return_value=str(mock_work_dir_path)), mock.patch( "shutil.rmtree" - ) as mock_rmtree, mock.patch( - "subprocess.Popen" - ) as mock_popen: - + ) as mock_rmtree, mock.patch("subprocess.Popen") as mock_popen: # Mock processes import_process = make_mock_process(context=True) @@ -839,17 +832,12 @@ def test_ci_simpleperf_symbolicate_timeout(tmp_path): "MOZ_FETCHES_DIR": str(mock_fetch_path), }, clear=False, - ), mock.patch( - "shutil.rmtree" - ) as mock_rmtree, mock.patch( + ), mock.patch("shutil.rmtree") as mock_rmtree, mock.patch( "subprocess.Popen" ) as mock_popen, mock.patch( "mozperftest.system.simpleperf.find_node_executable", return_value=[str(node_path)], - ), mock.patch.object( - profiler, "_cleanup" - ) as mock_cleanup: - + ), mock.patch.object(profiler, "_cleanup") as mock_cleanup: # Mock processes import_process = make_mock_process(context=True) diff --git a/python/mozperftest/mozperftest/tests/test_utils.py b/python/mozperftest/mozperftest/tests/test_utils.py index 3a9b87e2ec36f..e4fc120636919 100644 --- a/python/mozperftest/mozperftest/tests/test_utils.py +++ b/python/mozperftest/mozperftest/tests/test_utils.py @@ -87,15 +87,13 @@ def test_install_package(): vem.bin_path = "someplace" with mock.patch("subprocess.check_call") as mock_check_call: assert install_package(vem, "foo") - mock_check_call.assert_called_once_with( - [ - vem.python_path, - "-m", - "pip", - "install", - "foo", - ] - ) + mock_check_call.assert_called_once_with([ + vem.python_path, + "-m", + "pip", + "install", + "foo", + ]) def test_install_requirements_file(): @@ -105,19 +103,17 @@ def test_install_requirements_file(): "mozperftest.utils.os" ): assert install_requirements_file(vem, "foo") - mock_check_call.assert_called_once_with( - [ - vem.python_path, - "-m", - "pip", - "install", - "-r", - "foo", - "--no-index", - "--find-links", - "https://pypi.pub.build.mozilla.org/pub/", - ] - ) + mock_check_call.assert_called_once_with([ + vem.python_path, + "-m", + "pip", + "install", + "-r", + "foo", + "--no-index", + "--find-links", + "https://pypi.pub.build.mozilla.org/pub/", + ]) @mock.patch("pip._internal.req.constructors.install_req_from_line", new=_req) diff --git a/python/mozperftest/mozperftest/tests/test_xpcshell.py b/python/mozperftest/mozperftest/tests/test_xpcshell.py index efdb4a53875e8..ec8e0092360ff 100644 --- a/python/mozperftest/mozperftest/tests/test_xpcshell.py +++ b/python/mozperftest/mozperftest/tests/test_xpcshell.py @@ -28,17 +28,17 @@ def runTests(self, args): self.log.log_raw({"action": "log", "message": "message"}) # these are the metrics sent by the scripts - self.log.log_raw( - { - "action": "log", - "message": '"perfMetrics"', - "extra": {"metrics1": 1, "metrics2": 2}, - } - ) - - self.log.log_raw( - {"action": "log", "message": '"perfMetrics"', "extra": {"metrics3": 3}} - ) + self.log.log_raw({ + "action": "log", + "message": '"perfMetrics"', + "extra": {"metrics1": 1, "metrics2": 2}, + }) + + self.log.log_raw({ + "action": "log", + "message": '"perfMetrics"', + "extra": {"metrics3": 3}, + }) self.log.test_end("test end") self.log.suite_end("suite end") diff --git a/python/mozperftest/mozperftest/utils.py b/python/mozperftest/mozperftest/utils.py index f48c065fd2bd6..1cd8404609bd5 100644 --- a/python/mozperftest/mozperftest/utils.py +++ b/python/mozperftest/mozperftest/utils.py @@ -236,9 +236,13 @@ def install_package(virtualenv_manager, package, ignore_failure=False): return True with silence(): try: - subprocess.check_call( - [virtualenv_manager.python_path, "-m", "pip", "install", package] - ) + subprocess.check_call([ + virtualenv_manager.python_path, + "-m", + "pip", + "install", + package, + ]) return True except Exception: if not ignore_failure: @@ -281,19 +285,17 @@ def install_requirements_file( cwd = os.getcwd() try: os.chdir(Path(requirements_file).parent) - subprocess.check_call( - [ - virtualenv_manager.python_path, - "-m", - "pip", - "install", - "-r", - requirements_file, - "--no-index", - "--find-links", - "https://pypi.pub.build.mozilla.org/pub/", - ] - ) + subprocess.check_call([ + virtualenv_manager.python_path, + "-m", + "pip", + "install", + "-r", + requirements_file, + "--no-index", + "--find-links", + "https://pypi.pub.build.mozilla.org/pub/", + ]) return True except Exception: if not ignore_failure: diff --git a/python/mozrelease/mozrelease/attribute_builds.py b/python/mozrelease/mozrelease/attribute_builds.py index 9a91a21d1b82b..51c36c382cebd 100644 --- a/python/mozrelease/mozrelease/attribute_builds.py +++ b/python/mozrelease/mozrelease/attribute_builds.py @@ -181,13 +181,11 @@ def main(): work = [] for i in args.input: fn = os.path.basename(i) - work.append( - { - "input": i, - "output": os.path.join(args.output, fn), - "attribution": args.attribution, - } - ) + work.append({ + "input": i, + "output": os.path.join(args.output, fn), + "attribution": args.attribution, + }) else: log.error("No configuration found. Set ATTRIBUTION_CONFIG or pass arguments.") return 1 diff --git a/python/mozrelease/mozrelease/balrog.py b/python/mozrelease/mozrelease/balrog.py index b38bf9bfca98d..dfd6790a94e11 100644 --- a/python/mozrelease/mozrelease/balrog.py +++ b/python/mozrelease/mozrelease/balrog.py @@ -62,10 +62,8 @@ def generate_update_properties(context, config): conditions = _generate_conditions(context, entry.get("conditions", {})) if conditions is not None: - result.append( - { - "fields": fields, - "for": conditions, - } - ) + result.append({ + "fields": fields, + "for": conditions, + }) return result diff --git a/python/mozrelease/mozrelease/buglist_creator.py b/python/mozrelease/mozrelease/buglist_creator.py index ab6bdb4485ba8..a970016210213 100644 --- a/python/mozrelease/mozrelease/buglist_creator.py +++ b/python/mozrelease/mozrelease/buglist_creator.py @@ -18,7 +18,7 @@ BUG_NUMBER_REGEX = re.compile(r"bug \d+", re.IGNORECASE) CHANGELOG_TO_FROM_STRING = "{product}_{version}_RELEASE" CHANGESET_URL_TEMPLATE = ( - "{repo}/{logtype}" "?rev={to_version}+%25+{from_version}&revcount=1000" + "{repo}/{logtype}?rev={to_version}+%25+{from_version}&revcount=1000" ) FULL_CHANGESET_TEMPLATE = "* [Full Mercurial changelog]({url})\n" LIST_DESCRIPTION_TEMPLATE = "Comparing Mercurial tag {from_version} to {to_version}:\n" @@ -245,10 +245,8 @@ def email_release_drivers( notify = Notify(notify_options) for address in addresses: - notify.email( - { - "address": address, - "subject": subject, - "content": content, - } - ) + notify.email({ + "address": address, + "subject": subject, + "content": content, + }) diff --git a/python/mozrelease/mozrelease/mach_commands.py b/python/mozrelease/mozrelease/mach_commands.py index 00027e3da98be..35630698ae66f 100644 --- a/python/mozrelease/mozrelease/mach_commands.py +++ b/python/mozrelease/mozrelease/mach_commands.py @@ -59,8 +59,7 @@ def buglist(command_context, version, product, revision, repo): required=True, action="append", dest="addresses", - help="The email address to send the bug list to " - "(may be specified more than once.", + help="The email address to send the bug list to (may be specified more than once.", ) @CommandArgument( "--version", diff --git a/python/mozrelease/mozrelease/paths.py b/python/mozrelease/mozrelease/paths.py index df8907ec636cd..0114304aeb902 100644 --- a/python/mozrelease/mozrelease/paths.py +++ b/python/mozrelease/mozrelease/paths.py @@ -59,34 +59,28 @@ def getReleaseInstallerPath( MozillaVersion(version) > MozillaVersion(last_linux_bz2_version) ): compression = "xz" - return "/".join( - [ - p.strip("/") - for p in [ - platform, - locale, - "%s-%s.tar.%s" % (productName, version, compression), - ] + return "/".join([ + p.strip("/") + for p in [ + platform, + locale, + "%s-%s.tar.%s" % (productName, version, compression), ] - ) + ]) elif "mac" in platform: - return "/".join( - [ - p.strip("/") - for p in [platform, locale, "%s %s.dmg" % (brandName, version)] - ] - ) + return "/".join([ + p.strip("/") + for p in [platform, locale, "%s %s.dmg" % (brandName, version)] + ]) elif platform.startswith("win"): - return "/".join( - [ - p.strip("/") - for p in [ - platform, - locale, - "%s Setup %s.exe" % (brandName, version), - ] + return "/".join([ + p.strip("/") + for p in [ + platform, + locale, + "%s Setup %s.exe" % (brandName, version), ] - ) + ]) else: raise "Unsupported platform" elif platform.startswith("android"): diff --git a/python/mozrelease/mozrelease/scriptworker_canary.py b/python/mozrelease/mozrelease/scriptworker_canary.py index dc60ccc0a6283..d91b9d4b35f83 100644 --- a/python/mozrelease/mozrelease/scriptworker_canary.py +++ b/python/mozrelease/mozrelease/scriptworker_canary.py @@ -57,9 +57,7 @@ def configure_ssh(ssh_key_secret): ssh_key_file.chmod(0o600) hgrc_content = ( - "[ui]\n" - "username = trybld\n" - "ssh = ssh -i {path} -l {user}\n".format( + "[ui]\nusername = trybld\nssh = ssh -i {path} -l {user}\n".format( path=ssh_key_file, user=ssh_key["user"] ) ) @@ -90,14 +88,12 @@ def push_canary(scriptworkers, addresses, ssh_key_secret): mach = Path(GECKO) / "mach" base_command = [str(mach), "try", "scriptworker", "--closed-tree", "--push-to-vcs"] for address in addresses: - base_command.extend( - [ - "--route", - f"notify.email.{address}.on-failed", - "--route", - f"notify.email.{address}.on-exception", - ] - ) + base_command.extend([ + "--route", + f"notify.email.{address}.on-failed", + "--route", + f"notify.email.{address}.on-exception", + ]) with configure_ssh(ssh_key_secret): env = os.environ.copy() diff --git a/python/mozrelease/mozrelease/update_verify.py b/python/mozrelease/mozrelease/update_verify.py index 326517ca5c6bd..1634cdd2c9548 100644 --- a/python/mozrelease/mozrelease/update_verify.py +++ b/python/mozrelease/mozrelease/update_verify.py @@ -188,20 +188,18 @@ def addRelease( locales = sorted(list(locales.split())) if isinstance(patch_types, str): patch_types = list(patch_types.split()) - self.releases.append( - { - "release": release, - "build_id": build_id, - "locales": locales, - "patch_types": patch_types, - "from": from_path, - "ftp_server_from": ftp_server_from, - "ftp_server_to": ftp_server_to, - "mar_channel_IDs": mar_channel_IDs, - "platform": platform, - "updater_package": updater_package, - } - ) + self.releases.append({ + "release": release, + "build_id": build_id, + "locales": locales, + "patch_types": patch_types, + "from": from_path, + "ftp_server_from": ftp_server_from, + "ftp_server_to": ftp_server_to, + "mar_channel_IDs": mar_channel_IDs, + "platform": platform, + "updater_package": updater_package, + }) def addLocaleToRelease(self, build_id, locale, from_path=None): r = self.getRelease(build_id, from_path) diff --git a/python/mozterm/test/test_widgets.py b/python/mozterm/test/test_widgets.py index 04cb507acda30..1c4b944342d0a 100644 --- a/python/mozterm/test/test_widgets.py +++ b/python/mozterm/test/test_widgets.py @@ -31,12 +31,10 @@ def terminal(): ) def test_footer(terminal): footer = Footer(terminal=terminal) - footer.write( - [ - ("bright_black", "foo"), - ("green", "bar"), - ] - ) + footer.write([ + ("bright_black", "foo"), + ("green", "bar"), + ]) value = terminal.stream.getvalue() expected = "\x1b7\x1b[90mfoo\x1b(B\x1b[m \x1b[32mbar\x1b(B\x1b[m\x1b8" assert value == expected diff --git a/python/mozversioncontrol/mozversioncontrol/repo/git.py b/python/mozversioncontrol/mozversioncontrol/repo/git.py index 1f39adeff99c3..7bd3e70503dbb 100644 --- a/python/mozversioncontrol/mozversioncontrol/repo/git.py +++ b/python/mozversioncontrol/mozversioncontrol/repo/git.py @@ -415,24 +415,22 @@ def data(content): # adding or modifying the files from `changed_files`. # fast-import will output the sha1 for that temporary commit on stdout # (via `get-mark`). - fast_import = "\n".join( - [ - f"commit refs/machtry/{branch}", - "mark :1", - f"author {author}", - f"committer {committer}", - data(commit_message), - f"from {current_head}", - "\n".join( - f"M 100644 inline {path}\n{data(content)}" - for path, content in (changed_files or {}).items() - ), - f"reset refs/machtry/{branch}", - "from 0000000000000000000000000000000000000000", - "get-mark :1", - "", - ] - ) + fast_import = "\n".join([ + f"commit refs/machtry/{branch}", + "mark :1", + f"author {author}", + f"committer {committer}", + data(commit_message), + f"from {current_head}", + "\n".join( + f"M 100644 inline {path}\n{data(content)}" + for path, content in (changed_files or {}).items() + ), + f"reset refs/machtry/{branch}", + "from 0000000000000000000000000000000000000000", + "get-mark :1", + "", + ]) cmd = (str(self._tool), "fast-import", "--quiet") stdout = subprocess.check_output( diff --git a/python/mozversioncontrol/mozversioncontrol/repo/mercurial.py b/python/mozversioncontrol/mozversioncontrol/repo/mercurial.py index d5e3bd7ad76f0..5c23950abe16c 100644 --- a/python/mozversioncontrol/mozversioncontrol/repo/mercurial.py +++ b/python/mozversioncontrol/mozversioncontrol/repo/mercurial.py @@ -427,12 +427,10 @@ def _update_mercurial_repo(self, url, dest: Path, revision): print(f"Ensuring {url} is up to date at {dest}") env = os.environ.copy() - env.update( - { - "HGPLAIN": "1", - "HGRCPATH": "!", - } - ) + env.update({ + "HGPLAIN": "1", + "HGRCPATH": "!", + }) try: subprocess.check_call(pull_args, cwd=str(cwd), env=env) diff --git a/python/mozversioncontrol/test/test_commit.py b/python/mozversioncontrol/test/test_commit.py index a9e245652449d..333f1ffeddd3a 100644 --- a/python/mozversioncontrol/test/test_commit.py +++ b/python/mozversioncontrol/test/test_commit.py @@ -121,9 +121,9 @@ def find_diff_marker(patch: str, filename: str): ] assert matches, f"No diff marker found for '{filename}'" - assert ( - len(matches) == 1 - ), f"More than one diff marker for '{filename}': {matches}" + assert len(matches) == 1, ( + f"More than one diff marker for '{filename}': {matches}" + ) return matches[0] diff --git a/python/mozversioncontrol/test/test_get_mozilla_remote_args.py b/python/mozversioncontrol/test/test_get_mozilla_remote_args.py index 621d0ec92db92..07fd17440a78a 100644 --- a/python/mozversioncontrol/test/test_get_mozilla_remote_args.py +++ b/python/mozversioncontrol/test/test_get_mozilla_remote_args.py @@ -51,17 +51,17 @@ def test_get_mozilla_remote_args(is_cinnabar, expected_remotes, repo): remotes = vcs.get_mozilla_remote_args() - assert remotes == [ - "--remotes" - ], "Default `--remotes` passed without finding official remote." + assert remotes == ["--remotes"], ( + "Default `--remotes` passed without finding official remote." + ) repo.execute_next_step() remotes = sorted(vcs.get_mozilla_remote_args()) - assert ( - remotes == expected_remotes - ), "Multiple non-try remote arguments should be found." + assert remotes == expected_remotes, ( + "Multiple non-try remote arguments should be found." + ) if __name__ == "__main__": diff --git a/python/mozversioncontrol/test/test_try_commit.py b/python/mozversioncontrol/test/test_try_commit.py index 35912bb8b358b..9c847a6125077 100644 --- a/python/mozversioncontrol/test/test_try_commit.py +++ b/python/mozversioncontrol/test/test_try_commit.py @@ -22,17 +22,17 @@ def test_try_commit(repo): except MissingVCSExtension: pytest.xfail("Requires the Mercurial evolve extension.") - assert ( - vcs.head_ref == initial_head_ref - ), "We should have reverted to previous head after try_commit" + assert vcs.head_ref == initial_head_ref, ( + "We should have reverted to previous head after try_commit" + ) # Create an empty commit. with vcs.try_commit(commit_message) as head: assert vcs.get_changed_files(rev=head) == [] - assert ( - vcs.head_ref == initial_head_ref - ), "We should have reverted to previous head after try_commit" + assert vcs.head_ref == initial_head_ref, ( + "We should have reverted to previous head after try_commit" + ) if __name__ == "__main__": diff --git a/security/manager/ssl/gen_cert_header.py b/security/manager/ssl/gen_cert_header.py index d1fa552f61731..752f646ec356a 100644 --- a/security/manager/ssl/gen_cert_header.py +++ b/security/manager/ssl/gen_cert_header.py @@ -34,7 +34,7 @@ def write_header(output, array_name, certificates): output.write(f" {line}\n") output.write("};\n") output.write( - f'const mozilla::Span {array_name}[] = {{ {", ".join(certificate_names)} }};\n' + f"const mozilla::Span {array_name}[] = {{ {', '.join(certificate_names)} }};\n" ) diff --git a/security/manager/tools/crtshToIdentifyingStruct/crtshToIdentifyingStruct.py b/security/manager/tools/crtshToIdentifyingStruct/crtshToIdentifyingStruct.py index 4170e5d93385b..e04cd2ea5f645 100644 --- a/security/manager/tools/crtshToIdentifyingStruct/crtshToIdentifyingStruct.py +++ b/security/manager/tools/crtshToIdentifyingStruct/crtshToIdentifyingStruct.py @@ -12,6 +12,7 @@ Requires Python 3. """ + import argparse import io import re diff --git a/security/manager/tools/pytlsbinding.py b/security/manager/tools/pytlsbinding.py index 07f210bd9b253..539ae5204af02 100644 --- a/security/manager/tools/pytlsbinding.py +++ b/security/manager/tools/pytlsbinding.py @@ -28,7 +28,6 @@ (SHA-256) are supported. """ - import base64 import hashlib import json diff --git a/security/manager/tools/regen_root_ca_metadata.py b/security/manager/tools/regen_root_ca_metadata.py index 8063e27680eb9..3de176b6dc942 100755 --- a/security/manager/tools/regen_root_ca_metadata.py +++ b/security/manager/tools/regen_root_ca_metadata.py @@ -271,12 +271,12 @@ def write_root_hashes(path, certdata, known_root_hashes): tmpl = Template(ROOT_HASHES_ENTRY_TEMPLATE) for root in certdata: root_hash = known_root_hashes[root.sha256base64()] - digest_half_1 = "".join( - [f"0x{c:02x}, " for c in root_hash.digest[: len(root_hash.digest) >> 1]] - ).removesuffix(" ") - digest_half_2 = "".join( - [f"0x{c:02x}, " for c in root_hash.digest[len(root_hash.digest) >> 1 :]] - ).removesuffix(", ") + digest_half_1 = "".join([ + f"0x{c:02x}, " for c in root_hash.digest[: len(root_hash.digest) >> 1] + ]).removesuffix(" ") + digest_half_2 = "".join([ + f"0x{c:02x}, " for c in root_hash.digest[len(root_hash.digest) >> 1 :] + ]).removesuffix(", ") f.write( tmpl.substitute( label=root_hash.label, diff --git a/taskcluster/android_taskgraph/__init__.py b/taskcluster/android_taskgraph/__init__.py index 116e7d7637765..46e1711444dc2 100644 --- a/taskcluster/android_taskgraph/__init__.py +++ b/taskcluster/android_taskgraph/__init__.py @@ -20,15 +20,13 @@ def register(graph_config): Import all modules that are siblings of this one, triggering decorators in the process. """ - _import_modules( - [ - "job", - "parameters", - "target_tasks", - "util.group_by", - "worker_types", - ] - ) + _import_modules([ + "job", + "parameters", + "target_tasks", + "util.group_by", + "worker_types", + ]) def _import_modules(modules): diff --git a/taskcluster/android_taskgraph/job.py b/taskcluster/android_taskgraph/job.py index f8635c76675c3..ca434dc5c39cf 100644 --- a/taskcluster/android_taskgraph/job.py +++ b/taskcluster/android_taskgraph/job.py @@ -24,31 +24,27 @@ Optional("json"): bool, } -gradlew_schema = Schema( - { - Required("using"): "gradlew", - Optional("pre-gradlew"): [[str]], - Required("gradlew"): [str], - Optional("post-gradlew"): [[str]], - # Base work directory used to set up the task. - Required("workdir"): str, - Optional("use-caches"): Any(bool, [str]), - Optional("secrets"): [secret_schema], - Optional("dummy-secrets"): [dummy_secret_schema], - } -) - -run_commands_schema = Schema( - { - Required("using"): "run-commands", - Optional("pre-commands"): [[str]], - Required("commands"): [[taskref_or_string]], - Required("workdir"): str, - Optional("use-caches"): Any(bool, [str]), - Optional("secrets"): [secret_schema], - Optional("dummy-secrets"): [dummy_secret_schema], - } -) +gradlew_schema = Schema({ + Required("using"): "gradlew", + Optional("pre-gradlew"): [[str]], + Required("gradlew"): [str], + Optional("post-gradlew"): [[str]], + # Base work directory used to set up the task. + Required("workdir"): str, + Optional("use-caches"): Any(bool, [str]), + Optional("secrets"): [secret_schema], + Optional("dummy-secrets"): [dummy_secret_schema], +}) + +run_commands_schema = Schema({ + Required("using"): "run-commands", + Optional("pre-commands"): [[str]], + Required("commands"): [[taskref_or_string]], + Required("workdir"): str, + Optional("use-caches"): Any(bool, [str]), + Optional("secrets"): [secret_schema], + Optional("dummy-secrets"): [dummy_secret_schema], +}) @run_job_using("docker-worker", "run-commands", schema=run_commands_schema) @@ -78,15 +74,13 @@ def configure_gradlew(config, job, taskdesc): fetches_dir = "/builds/worker/fetches" topsrc_dir = "/builds/worker/checkouts/gecko" - worker.setdefault("env", {}).update( - { - "ANDROID_SDK_ROOT": path.join(fetches_dir, "android-sdk-linux"), - "GRADLE_USER_HOME": path.join( - topsrc_dir, "mobile/android/gradle/dotgradle-offline" - ), - "MOZ_BUILD_DATE": config.params["moz_build_date"], - } - ) + worker.setdefault("env", {}).update({ + "ANDROID_SDK_ROOT": path.join(fetches_dir, "android-sdk-linux"), + "GRADLE_USER_HOME": path.join( + topsrc_dir, "mobile/android/gradle/dotgradle-offline" + ), + "MOZ_BUILD_DATE": config.params["moz_build_date"], + }) worker["env"].setdefault( "MOZCONFIG", path.join( @@ -103,14 +97,12 @@ def configure_gradlew(config, job, taskdesc): for secret in run.pop("dummy-secrets", []) ] secrets = [_generate_secret_command(secret) for secret in run.get("secrets", [])] - worker["env"].update( - { - "PRE_GRADLEW": _convert_commands_to_string(run.pop("pre-gradlew", [])), - "GET_SECRETS": _convert_commands_to_string(dummy_secrets + secrets), - "GRADLEW_ARGS": " ".join(run.pop("gradlew")), - "POST_GRADLEW": _convert_commands_to_string(run.pop("post-gradlew", [])), - } - ) + worker["env"].update({ + "PRE_GRADLEW": _convert_commands_to_string(run.pop("pre-gradlew", [])), + "GET_SECRETS": _convert_commands_to_string(dummy_secrets + secrets), + "GRADLEW_ARGS": " ".join(run.pop("gradlew")), + "POST_GRADLEW": _convert_commands_to_string(run.pop("post-gradlew", [])), + }) run["command"] = ( "/builds/worker/checkouts/gecko/taskcluster/scripts/builder/build-android.sh" ) diff --git a/taskcluster/android_taskgraph/transforms/beetmover_android_app.py b/taskcluster/android_taskgraph/transforms/beetmover_android_app.py index 6f8d8c50f39c0..9d2aad6fdd63b 100644 --- a/taskcluster/android_taskgraph/transforms/beetmover_android_app.py +++ b/taskcluster/android_taskgraph/transforms/beetmover_android_app.py @@ -102,15 +102,13 @@ def make_task_worker(config, tasks): locale = task["attributes"].get("locale") build_type = task["attributes"]["build-type"] - task["worker"].update( - { - "implementation": "beetmover", - "release-properties": craft_release_properties(config, task), - "artifact-map": generate_beetmover_artifact_map( - config, task, platform=build_type, locale=locale - ), - } - ) + task["worker"].update({ + "implementation": "beetmover", + "release-properties": craft_release_properties(config, task), + "artifact-map": generate_beetmover_artifact_map( + config, task, platform=build_type, locale=locale + ), + }) if locale: task["worker"]["locale"] = locale diff --git a/taskcluster/android_taskgraph/transforms/build_android_app.py b/taskcluster/android_taskgraph/transforms/build_android_app.py index 88a81c350bdc3..034f33b6232dc 100644 --- a/taskcluster/android_taskgraph/transforms/build_android_app.py +++ b/taskcluster/android_taskgraph/transforms/build_android_app.py @@ -6,7 +6,6 @@ build-apk and build-bundle kinds. """ - from taskgraph.transforms.base import TransformSequence from taskgraph.util import path @@ -82,30 +81,26 @@ def add_shippable_secrets(config, tasks): task.pop("include-shippable-secrets", False) and config.params["level"] == "3" ): - secrets.extend( - [ - { - "key": key, - "name": _get_secret_index(task["name"]), - "path": target_file, - } - for key, target_file in _get_secrets_keys_and_target_files(task) - ] - ) + secrets.extend([ + { + "key": key, + "name": _get_secret_index(task["name"]), + "path": target_file, + } + for key, target_file in _get_secrets_keys_and_target_files(task) + ]) else: - dummy_secrets.extend( - [ - { - "content": fake_value, - "path": target_file, - } - for fake_value, target_file in ( - ("faketoken", ".adjust_token"), - ("faketoken", ".mls_token"), - ("https://fake@sentry.prod.mozaws.net/368", ".sentry_token"), - ) - ] - ) + dummy_secrets.extend([ + { + "content": fake_value, + "path": target_file, + } + for fake_value, target_file in ( + ("faketoken", ".adjust_token"), + ("faketoken", ".mls_token"), + ("https://fake@sentry.prod.mozaws.net/368", ".sentry_token"), + ) + ]) yield task @@ -120,16 +115,14 @@ def _get_secrets_keys_and_target_files(task): if task["name"].startswith("fenix-"): gradle_build_type = task["run"]["gradle-build-type"] - secrets.extend( - [ - ( - "firebase", - f"app/src/{gradle_build_type}/res/values/firebase.xml", - ), - ("wallpaper_url", ".wallpaper_url"), - ("pocket_consumer_key", ".pocket_consumer_key"), - ] - ) + secrets.extend([ + ( + "firebase", + f"app/src/{gradle_build_type}/res/values/firebase.xml", + ), + ("wallpaper_url", ".wallpaper_url"), + ("pocket_consumer_key", ".pocket_consumer_key"), + ]) return secrets @@ -221,13 +214,11 @@ def add_disable_optimization(config, tasks): def add_nightly_version(config, tasks): for task in tasks: if task.pop("include-nightly-version", False): - task["run"]["gradlew"].extend( - [ - # We only set the `official` flag here. The actual version name will be determined - # by Gradle (depending on the Gecko/A-C version being used) - "-Pofficial" - ] - ) + task["run"]["gradlew"].extend([ + # We only set the `official` flag here. The actual version name will be determined + # by Gradle (depending on the Gecko/A-C version being used) + "-Pofficial" + ]) yield task @@ -235,9 +226,10 @@ def add_nightly_version(config, tasks): def add_release_version(config, tasks): for task in tasks: if task.pop("include-release-version", False): - task["run"]["gradlew"].extend( - ["-PversionName={}".format(config.params["version"]), "-Pofficial"] - ) + task["run"]["gradlew"].extend([ + "-PversionName={}".format(config.params["version"]), + "-Pofficial", + ]) yield task @@ -271,19 +263,17 @@ def add_artifacts(config, tasks): apk_name = artifact_template["name"].format( gradle_build=gradle_build, **apk ) - artifacts.append( - { - "type": artifact_template["type"], - "name": apk_name, - "path": artifact_template["path"].format( - gradle_build_type=gradle_build_type, - gradle_build=gradle_build, - apk_path=apk_path, - source_project_name=source_project_name, - **apk, - ), - } - ) + artifacts.append({ + "type": artifact_template["type"], + "name": apk_name, + "path": artifact_template["path"].format( + gradle_build_type=gradle_build_type, + gradle_build=gradle_build, + apk_path=apk_path, + source_project_name=source_project_name, + **apk, + ), + }) apks[apk["abi"]] = { "name": apk_name, } @@ -297,19 +287,17 @@ def add_artifacts(config, tasks): else: aab_filename = f"app-{gradle_build}-{gradle_build_type}.aab" - artifacts.append( - { - "type": artifact_template["type"], - "name": artifact_template["name"], - "path": artifact_template["path"].format( - gradle_build_type=gradle_build_type, - gradle_build=gradle_build, - source_project_name=source_project_name, - variant_name=variant_name, - aab_filename=aab_filename, - ), - } - ) + artifacts.append({ + "type": artifact_template["type"], + "name": artifact_template["name"], + "path": artifact_template["path"].format( + gradle_build_type=gradle_build_type, + gradle_build=gradle_build, + source_project_name=source_project_name, + variant_name=variant_name, + aab_filename=aab_filename, + ), + }) task["attributes"]["aab"] = artifact_template["name"] yield task diff --git a/taskcluster/android_taskgraph/transforms/build_components.py b/taskcluster/android_taskgraph/transforms/build_components.py index d4e1f8c508ece..2413a92b4fcbb 100644 --- a/taskcluster/android_taskgraph/transforms/build_components.py +++ b/taskcluster/android_taskgraph/transforms/build_components.py @@ -148,15 +148,13 @@ def add_artifacts(config, tasks): ]: if key in task: optional_artifact_template = task.pop(key, {}) - build_artifact_definitions.append( - { - "type": optional_artifact_template["type"], - "name": optional_artifact_template["name"], - "path": optional_artifact_template["path"].format( - component_path=get_path(component) - ), - } - ) + build_artifact_definitions.append({ + "type": optional_artifact_template["type"], + "name": optional_artifact_template["name"], + "path": optional_artifact_template["path"].format( + component_path=get_path(component) + ), + }) if artifact_template: all_extensions = get_extensions(component) @@ -185,22 +183,20 @@ def add_artifacts(config, tasks): artifact_full_name = artifact_template["name"].format( artifact_file_name=artifact_file_name, ) - build_artifact_definitions.append( - { - "type": artifact_template["type"], - "name": artifact_full_name, - "path": artifact_template["path"].format( - component_path=get_path(component), - component=component, - version=craft_path_version( - version, - task["attributes"]["build-type"], - nightly_version, - ), - artifact_file_name=artifact_file_name, + build_artifact_definitions.append({ + "type": artifact_template["type"], + "name": artifact_full_name, + "path": artifact_template["path"].format( + component_path=get_path(component), + component=component, + version=craft_path_version( + version, + task["attributes"]["build-type"], + nightly_version, ), - } - ) + artifact_file_name=artifact_file_name, + ), + }) artifacts[extension] = artifact_full_name diff --git a/taskcluster/android_taskgraph/transforms/notify.py b/taskcluster/android_taskgraph/transforms/notify.py index d4fe097e3ee78..ad09253bf8c2d 100644 --- a/taskcluster/android_taskgraph/transforms/notify.py +++ b/taskcluster/android_taskgraph/transforms/notify.py @@ -38,12 +38,10 @@ def add_notify_email(config, tasks): } routes = task.setdefault("routes", []) - routes.extend( - [ - f"notify.email.{address}.on-{reason}" - for address in email_config["to-addresses"] - for reason in email_config["on-reasons"] - ] - ) + routes.extend([ + f"notify.email.{address}.on-{reason}" + for address in email_config["to-addresses"] + for reason in email_config["on-reasons"] + ]) yield task diff --git a/taskcluster/android_taskgraph/transforms/push_android_app.py b/taskcluster/android_taskgraph/transforms/push_android_app.py index a074b039bb2ec..0c396ed722ec8 100644 --- a/taskcluster/android_taskgraph/transforms/push_android_app.py +++ b/taskcluster/android_taskgraph/transforms/push_android_app.py @@ -6,7 +6,6 @@ kind. """ - from taskgraph.transforms.base import TransformSequence from taskgraph.util.schema import resolve_keyed_by @@ -31,6 +30,6 @@ def resolve_keys(config, tasks): **{ "build-type": task["attributes"]["build-type"], "level": config.params["level"], - } + }, ) yield task diff --git a/taskcluster/android_taskgraph/transforms/signing.py b/taskcluster/android_taskgraph/transforms/signing.py index 6f55aa1ba73b3..421329a69ac49 100644 --- a/taskcluster/android_taskgraph/transforms/signing.py +++ b/taskcluster/android_taskgraph/transforms/signing.py @@ -27,7 +27,7 @@ def resolve_keys(config, tasks): **{ "build-type": task["attributes"]["build-type"], "level": config.params["level"], - } + }, ) yield task @@ -65,8 +65,7 @@ def filter_out_checksums(config, tasks): def set_detached_signature_artifacts(config, tasks): for task in tasks: task["attributes"]["artifacts"] = { - extension - + _DETACHED_SIGNATURE_EXTENSION: path + extension + _DETACHED_SIGNATURE_EXTENSION: path + _DETACHED_SIGNATURE_EXTENSION for extension, path in task["attributes"]["artifacts"].items() } diff --git a/taskcluster/android_taskgraph/transforms/startup_tests_deps.py b/taskcluster/android_taskgraph/transforms/startup_tests_deps.py index 1d14866b70832..df9ae291c47fa 100644 --- a/taskcluster/android_taskgraph/transforms/startup_tests_deps.py +++ b/taskcluster/android_taskgraph/transforms/startup_tests_deps.py @@ -22,7 +22,7 @@ def add_android_startup_test_dependencies(config, jobs): if job_build_type in t.attributes.get("build-type", "") ] if matching_tasks: - job.setdefault("dependencies", {}).update( - {t.label: t.label for t in matching_tasks} - ) + job.setdefault("dependencies", {}).update({ + t.label: t.label for t in matching_tasks + }) yield job diff --git a/taskcluster/android_taskgraph/transforms/ui_tests.py b/taskcluster/android_taskgraph/transforms/ui_tests.py index 182c189e97554..370c0c570b4d2 100644 --- a/taskcluster/android_taskgraph/transforms/ui_tests.py +++ b/taskcluster/android_taskgraph/transforms/ui_tests.py @@ -96,16 +96,14 @@ def apk_path(component_fragment, variant, apk_filename): run = task.setdefault("run", {}) post_gradlew = run.setdefault("post-gradlew", []) - post_gradlew.append( - [ - "python3", - "taskcluster/scripts/tests/test-lab.py", - flank_config, - apk_app, - "--apk_test", - apk_test, - ] - ) + post_gradlew.append([ + "python3", + "taskcluster/scripts/tests/test-lab.py", + flank_config, + apk_app, + "--apk_test", + apk_test, + ]) yield task diff --git a/taskcluster/android_taskgraph/transforms/upstream_artifacts.py b/taskcluster/android_taskgraph/transforms/upstream_artifacts.py index 5c0906136baba..72a45d979a27b 100644 --- a/taskcluster/android_taskgraph/transforms/upstream_artifacts.py +++ b/taskcluster/android_taskgraph/transforms/upstream_artifacts.py @@ -35,23 +35,19 @@ def build_upstream_artifacts(config, tasks): only_archs = task.pop("only-archs", []) for dep in get_dependencies(config, task): paths = list(dep.attributes.get("artifacts", {}).values()) - paths.extend( - [ - apk_metadata["name"] - for arch, apk_metadata in dep.attributes.get("apks", {}).items() - if not only_archs or arch in only_archs - ] - ) + paths.extend([ + apk_metadata["name"] + for arch, apk_metadata in dep.attributes.get("apks", {}).items() + if not only_archs or arch in only_archs + ]) if dep.attributes.get("aab"): paths.extend([dep.attributes.get("aab")]) if paths: - worker_definition["upstream-artifacts"].append( - { - "taskId": {"task-reference": f"<{dep.kind}>"}, - "taskType": _get_task_type(dep.kind), - "paths": sorted(paths), - } - ) + worker_definition["upstream-artifacts"].append({ + "taskId": {"task-reference": f"<{dep.kind}>"}, + "taskType": _get_task_type(dep.kind), + "paths": sorted(paths), + }) task.setdefault("worker", {}).update(worker_definition) yield task diff --git a/taskcluster/android_taskgraph/util/group_by.py b/taskcluster/android_taskgraph/util/group_by.py index 2770c056264d4..fdd818917a9be 100644 --- a/taskcluster/android_taskgraph/util/group_by.py +++ b/taskcluster/android_taskgraph/util/group_by.py @@ -25,13 +25,11 @@ def component_grouping(config, tasks): and task.attributes.get("is_final_chunked_task", True) ] for (_, build_type), group_tasks in groups.items(): - group_tasks.extend( - [ - task - for task in tasks_for_all_components - if task.attributes.get("build-type") == build_type - ] - ) + group_tasks.extend([ + task + for task in tasks_for_all_components + if task.attributes.get("build-type") == build_type + ]) return groups.values() diff --git a/taskcluster/android_taskgraph/util/scriptworker.py b/taskcluster/android_taskgraph/util/scriptworker.py index 9171d09b5603a..8d05199de1d2e 100644 --- a/taskcluster/android_taskgraph/util/scriptworker.py +++ b/taskcluster/android_taskgraph/util/scriptworker.py @@ -115,14 +115,12 @@ def generate_beetmover_upstream_artifacts( if not paths: continue - upstream_artifacts.append( - { - "taskId": {"task-reference": f"<{dep}>"}, - "taskType": map_config["tasktype_map"].get(dep), - "paths": sorted(paths), - "locale": current_locale, - } - ) + upstream_artifacts.append({ + "taskId": {"task-reference": f"<{dep}>"}, + "taskType": map_config["tasktype_map"].get(dep), + "paths": sorted(paths), + "locale": current_locale, + }) upstream_artifacts.sort(key=lambda u: u["paths"]) return upstream_artifacts @@ -271,17 +269,17 @@ def generate_beetmover_artifact_map(config, job, **kwargs): else: folder_prefix = f"{version}-candidates/build{build_number}/android/" - kwargs.update( - {"locale": locale, "version": version, "folder_prefix": folder_prefix} - ) + kwargs.update({ + "locale": locale, + "version": version, + "folder_prefix": folder_prefix, + }) kwargs.update(**platforms) paths = jsone.render(paths, kwargs) - artifacts.append( - { - "taskId": {"task-reference": f"<{dep}>"}, - "locale": locale, - "paths": paths, - } - ) + artifacts.append({ + "taskId": {"task-reference": f"<{dep}>"}, + "locale": locale, + "paths": paths, + }) return artifacts diff --git a/taskcluster/android_taskgraph/worker_types.py b/taskcluster/android_taskgraph/worker_types.py index 5a249116700db..7f8394142ab82 100644 --- a/taskcluster/android_taskgraph/worker_types.py +++ b/taskcluster/android_taskgraph/worker_types.py @@ -53,12 +53,10 @@ def build_scriptworker_beetmover_payload(config, task, task_def): } scope_prefix = config.graph_config["scriptworker"]["scope-prefix"] - task_def["scopes"].extend( - [ - "{}:beetmover:action:{}".format(scope_prefix, worker["action"]), - "{}:beetmover:bucket:{}".format(scope_prefix, worker["bucket"]), - ] - ) + task_def["scopes"].extend([ + "{}:beetmover:action:{}".format(scope_prefix, worker["action"]), + "{}:beetmover:bucket:{}".format(scope_prefix, worker["bucket"]), + ]) @payload_builder( diff --git a/taskcluster/docker/funsize-update-generator/scripts/funsize.py b/taskcluster/docker/funsize-update-generator/scripts/funsize.py index 0fd4a076ce826..3683af82b37f7 100644 --- a/taskcluster/docker/funsize-update-generator/scripts/funsize.py +++ b/taskcluster/docker/funsize-update-generator/scripts/funsize.py @@ -63,7 +63,7 @@ def strtobool(value: str): if value in false_vals: return 0 - raise ValueError(f'Expected one of: {", ".join(true_vals + false_vals)}') + raise ValueError(f"Expected one of: {', '.join(true_vals + false_vals)}") def verify_signature(mar, cert): 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 b3f0e3b70195b..ddbfc0d5d586c 100644 --- a/taskcluster/docker/snap-coreXX-build/snap-tests/basic_tests.py +++ b/taskcluster/docker/snap-coreXX-build/snap-tests/basic_tests.py @@ -251,9 +251,10 @@ def is_debug_build(self): return self._is_debug_build def need_allow_system_access(self): - geckodriver_output = subprocess.check_output( - [self._EXE_PATH, "--help"] - ).decode() + geckodriver_output = subprocess.check_output([ + self._EXE_PATH, + "--help", + ]).decode() return "--allow-system-access" in geckodriver_output def update_channel(self): @@ -414,16 +415,16 @@ def assert_rendering(self, exp, element_or_driver): (left, upper, right, lower) = bbox assert right >= left, f"Inconsistent boundaries right={right} left={left}" - assert ( - lower >= upper - ), f"Inconsistent boundaries lower={lower} upper={upper}" + assert lower >= upper, ( + f"Inconsistent boundaries lower={lower} upper={upper}" + ) if ((right - left) <= 2) or ((lower - upper) <= 2): self._logger.info("Difference is a <= 2 pixels band, ignoring") return - assert ( - diff_px_on_bbox <= allowance - ), "Mismatching screenshots for {}".format(exp["reference"]) + assert diff_px_on_bbox <= allowance, ( + "Mismatching screenshots for {}".format(exp["reference"]) + ) class SnapTests(SnapTestsBase): @@ -451,9 +452,9 @@ def test_about_support(self, exp): ) self._wait.until(lambda d: len(distributionid_box.text) > 0) self._logger.info(f"about:support distribution ID: {distributionid_box.text}") - assert ( - distributionid_box.text == exp["distribution_id"] - ), "distribution_id should match" + assert distributionid_box.text == exp["distribution_id"], ( + "distribution_id should match" + ) windowing_protocol = self._driver.execute_script( "return document.querySelector('th[data-l10n-id=\"graphics-window-protocol\"').parentNode.lastChild.textContent;" @@ -471,18 +472,18 @@ def test_about_buildconfig(self, exp): ) self._wait.until(lambda d: len(source_link.text) > 0) self._logger.info(f"about:buildconfig source: {source_link.text}") - assert source_link.text.startswith( - exp["source_repo"] - ), "source repo should exists and match" + assert source_link.text.startswith(exp["source_repo"]), ( + "source repo should exists and match" + ) build_flags_box = self._wait.until( EC.visibility_of_element_located((By.CSS_SELECTOR, "p:last-child")) ) self._wait.until(lambda d: len(build_flags_box.text) > 0) self._logger.info(f"about:support buildflags: {build_flags_box.text}") - assert ( - build_flags_box.text.find(exp["official"]) >= 0 - ), "official build flag should be there" + assert build_flags_box.text.find(exp["official"]) >= 0, ( + "official build flag should be there" + ) return True @@ -499,9 +500,10 @@ def test_youtube(self, exp): self._logger.info("Wait for consent form") try: self._wait.until( - EC.visibility_of_element_located( - (By.CSS_SELECTOR, "button[aria-label*=Accept]") - ) + EC.visibility_of_element_located(( + By.CSS_SELECTOR, + "button[aria-label*=Accept]", + )) ).click() except TimeoutException: self._logger.info("Wait for consent form: timed out, maybe it is not here") @@ -513,9 +515,10 @@ def test_youtube(self, exp): self._logger.info("Wait for cable proposal") try: self._wait.until( - EC.visibility_of_element_located( - (By.CSS_SELECTOR, "button[aria-label*=Dismiss]") - ) + EC.visibility_of_element_located(( + By.CSS_SELECTOR, + "button[aria-label*=Dismiss]", + )) ).click() except TimeoutException: self._logger.info( @@ -547,9 +550,9 @@ def test_youtube(self, exp): self._logger.info( "video duration: {}".format(video.get_property("duration")) ) - assert ( - video.get_property("duration") > exp["duration"] - ), "youtube video should have duration" + assert video.get_property("duration") > exp["duration"], ( + "youtube video should have duration" + ) self._wait.until( lambda d: video.get_property("currentTime") > exp["playback"] @@ -557,9 +560,9 @@ def test_youtube(self, exp): self._logger.info( "video played: {}".format(video.get_property("currentTime")) ) - assert ( - video.get_property("currentTime") > exp["playback"] - ), "youtube video should perform playback" + assert video.get_property("currentTime") > exp["playback"], ( + "youtube video should perform playback" + ) except TimeoutException as ex: self._logger.info("video detection timed out") self._logger.info(f"video: {video}") @@ -579,30 +582,34 @@ def wait_for_enable_drm(self): ) enable_drm_button = self._wait.until( - EC.visibility_of_element_located( - (By.CSS_SELECTOR, ".notification-button[label='Enable DRM']") - ) + EC.visibility_of_element_located(( + By.CSS_SELECTOR, + ".notification-button[label='Enable DRM']", + )) ) self._logger.info("Enabling DRMs") enable_drm_button.click() self._wait.until( - EC.invisibility_of_element_located( - (By.CSS_SELECTOR, ".notification-button[label='Enable DRM']") - ) + EC.invisibility_of_element_located(( + By.CSS_SELECTOR, + ".notification-button[label='Enable DRM']", + )) ) self._logger.info("Installing DRMs") self._wait.until( - EC.visibility_of_element_located( - (By.CSS_SELECTOR, ".infobar[value='drmContentCDMInstalling']") - ) + EC.visibility_of_element_located(( + By.CSS_SELECTOR, + ".infobar[value='drmContentCDMInstalling']", + )) ) self._logger.info("Waiting for DRMs installation to complete") self._longwait.until( - EC.invisibility_of_element_located( - (By.CSS_SELECTOR, ".infobar[value='drmContentCDMInstalling']") - ) + EC.invisibility_of_element_located(( + By.CSS_SELECTOR, + ".infobar[value='drmContentCDMInstalling']", + )) ) self._driver.set_context("content") @@ -620,24 +627,25 @@ def test_youtube_film(self, exp): # Wait for duration to be set to something self._logger.info("Wait for video to start") video = self._wait.until( - EC.visibility_of_element_located( - (By.CSS_SELECTOR, "video.html5-main-video") - ) + EC.visibility_of_element_located(( + By.CSS_SELECTOR, + "video.html5-main-video", + )) ) 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"] - ), "youtube video should have duration" + assert video.get_property("duration") > exp["duration"], ( + "youtube video should have duration" + ) self._driver.execute_script("arguments[0].click();", video) video.send_keys("k") self._wait.until(lambda d: video.get_property("currentTime") > exp["playback"]) self._logger.info("video played: {}".format(video.get_property("currentTime"))) - assert ( - video.get_property("currentTime") > exp["playback"] - ), "youtube video should perform playback" + assert video.get_property("currentTime") > exp["playback"], ( + "youtube video should perform playback" + ) return True 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 dbae1906d0b7c..d50b2499f4b9a 100644 --- a/taskcluster/docker/snap-coreXX-build/snap-tests/qa_tests.py +++ b/taskcluster/docker/snap-coreXX-build/snap-tests/qa_tests.py @@ -108,9 +108,10 @@ def _test_audio_playback( self._logger.info("find video") video = self._wait.until( - EC.visibility_of_element_located( - (By.CSS_SELECTOR, video_selector or "video") - ) + EC.visibility_of_element_located(( + By.CSS_SELECTOR, + video_selector or "video", + )) ) self._wait.until(lambda d: type(video.get_property("duration")) is float) assert video.get_property("duration") > 0.0, "