tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit c936a9217dfd15830f079b3e222bc45146806324
parent 4cd9582b8ef944c596ed89044e6770ccd62464aa
Author: Alex Hochheiden <ahochheiden@mozilla.com>
Date:   Wed, 10 Dec 2025 06:03:26 +0000

Bug 2003412 - Fix PLW1508 warnings: Use string default for os.getenv r=emilio,android-reviewers,jdescottes,tcampbell

https://docs.astral.sh/ruff/rules/invalid-envvar-default/

Differential Revision: https://phabricator.services.mozilla.com/D274700

Diffstat:
Mjs/src/devtools/automation/autospider.py | 2+-
Mmobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/experimentintegration/ping_server/ping_server.py | 2+-
Mpython/mozbuild/mozbuild/build_commands.py | 4++--
Mpython/mozlint/mozlint/formatters/summary.py | 2+-
Mtesting/marionette/harness/marionette_harness/runner/base.py | 2+-
Mtesting/mozbase/mozinfo/mozinfo/mozinfo.py | 2+-
Mtesting/mozbase/mozlog/mozlog/formatters/errorsummary.py | 2+-
Mtesting/mozbase/mozrunner/mozrunner/application.py | 2+-
Mtesting/mozbase/mozrunner/mozrunner/utils.py | 2+-
Mtesting/xpcshell/runxpcshelltests.py | 2+-
Mtools/update-verify/scripts/async_download.py | 2+-
11 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/js/src/devtools/automation/autospider.py b/js/src/devtools/automation/autospider.py @@ -50,7 +50,7 @@ def quote(s): # DIR, but when running under the shell, use POSIX style paths. DIR = directories(os.path, os.getcwd()) -AUTOMATION = env.get("AUTOMATION", False) +AUTOMATION = bool(env.get("AUTOMATION")) parser = argparse.ArgumentParser(description="Run a spidermonkey shell build job") parser.add_argument( diff --git a/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/experimentintegration/ping_server/ping_server.py b/mobile/android/fenix/app/src/androidTest/java/org/mozilla/fenix/experimentintegration/ping_server/ping_server.py @@ -44,5 +44,5 @@ def submit(telemetry): if __name__ == "__main__": - port = int(os.environ.get("PORT", 5000)) + port = int(os.environ.get("PORT", "5000")) app.run(debug=True, host="0.0.0.0", port=port) diff --git a/python/mozbuild/mozbuild/build_commands.py b/python/mozbuild/mozbuild/build_commands.py @@ -157,10 +157,10 @@ def build( configure_args = mozconfig["configure_args"] doing_pgo = configure_args and "MOZ_PGO=1" in configure_args # Force verbosity on automation. - verbose = verbose or bool(os.environ.get("MOZ_AUTOMATION", False)) + verbose = verbose or bool(os.environ.get("MOZ_AUTOMATION")) # Keep going by default on automation so that we exhaust as many errors as # possible. - keep_going = keep_going or bool(os.environ.get("MOZ_AUTOMATION", False)) + keep_going = keep_going or bool(os.environ.get("MOZ_AUTOMATION")) append_env = None # By setting the current process's priority, by default our child processes diff --git a/python/mozlint/mozlint/formatters/summary.py b/python/mozlint/mozlint/formatters/summary.py @@ -12,7 +12,7 @@ from ..util.string import pluralize class SummaryFormatter: def __init__(self, depth=None): - self.depth = depth or int(os.environ.get("MOZLINT_SUMMARY_DEPTH", 1)) + self.depth = depth or int(os.environ.get("MOZLINT_SUMMARY_DEPTH", "1")) def __call__(self, result): paths = set( diff --git a/testing/marionette/harness/marionette_harness/runner/base.py b/testing/marionette/harness/marionette_harness/runner/base.py @@ -434,7 +434,7 @@ class BaseMarionetteArguments(ArgumentParser): "--headless", action="store_true", dest="headless", - default=os.environ.get("MOZ_HEADLESS", False), + default=bool(os.environ.get("MOZ_HEADLESS")), help="Run tests in headless mode.", ) self.add_argument( diff --git a/testing/mozbase/mozinfo/mozinfo/mozinfo.py b/testing/mozbase/mozinfo/mozinfo/mozinfo.py @@ -46,7 +46,7 @@ info = { "bits": unknown, "has_sandbox": unknown, "display": None, - "automation": bool(os.environ.get("MOZ_AUTOMATION", False)), # noqa PLW1508 + "automation": bool(os.environ.get("MOZ_AUTOMATION")), } (system, node, release, version, machine, processor) = platform.uname() (bits, linkage) = platform.architecture() diff --git a/testing/mozbase/mozlog/mozlog/formatters/errorsummary.py b/testing/mozbase/mozlog/mozlog/formatters/errorsummary.py @@ -24,7 +24,7 @@ class ErrorSummaryFormatter(BaseFormatter): self.line_count = 0 self.dump_passing_tests = False - if os.environ.get("MOZLOG_DUMP_ALL_TESTS", False): + if os.environ.get("MOZLOG_DUMP_ALL_TESTS"): self.dump_passing_tests = True def __call__(self, data): diff --git a/testing/mozbase/mozrunner/mozrunner/application.py b/testing/mozbase/mozrunner/mozrunner/application.py @@ -81,7 +81,7 @@ class RemoteContext(metaclass=ABCMeta): return self._remote_profile def which(self, binary): - paths = os.environ.get("PATH", {}).split(os.pathsep) + paths = os.environ.get("PATH", "").split(os.pathsep) if self.bindir is not None and os.path.abspath(self.bindir) not in paths: paths.insert(0, os.path.abspath(self.bindir)) os.environ["PATH"] = os.pathsep.join(paths) diff --git a/testing/mozbase/mozrunner/mozrunner/utils.py b/testing/mozbase/mozrunner/mozrunner/utils.py @@ -217,7 +217,7 @@ def get_stack_fixer_function(utilityPath, symbolsPath, hideErrors=False): if not mozinfo.info.get("debug"): return None - if os.getenv("MOZ_DISABLE_STACK_FIX", 0): + if os.getenv("MOZ_DISABLE_STACK_FIX"): print( "WARNING: No stack-fixing will occur because MOZ_DISABLE_STACK_FIX is set" ) diff --git a/testing/xpcshell/runxpcshelltests.py b/testing/xpcshell/runxpcshelltests.py @@ -188,7 +188,7 @@ class XPCShellTestThread(Thread): if retry is None: # Retry in CI, but report results without retry when run locally to # avoid confusion and ease local debugging. - self.retry = os.environ.get("MOZ_AUTOMATION", 0) != 0 + self.retry = os.environ.get("MOZ_AUTOMATION") is not None self.verbose = verbose self.usingTSan = usingTSan self.usingCrashReporter = usingCrashReporter diff --git a/tools/update-verify/scripts/async_download.py b/tools/update-verify/scripts/async_download.py @@ -19,7 +19,7 @@ log = logging.getLogger(__name__) UV_CACHE_PATH = os.getenv( "UV_CACHE_PATH", os.path.join(path.dirname(__file__), "../release/updates/cache/") ) -UV_PARALLEL_DOWNLOADS = os.getenv("UV_PARALLEL_DOWNLOADS", 20) +UV_PARALLEL_DOWNLOADS = int(os.getenv("UV_PARALLEL_DOWNLOADS", "20")) FTP_SERVER_TO = os.getenv("ftp_server_to", "http://stage.mozilla.org/pub/mozilla.org") FTP_SERVER_FROM = os.getenv(