tor-browser

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

commit 45fd8b48b2906e1b83e0307502e655ce430ef702
parent ae18720af721cd7a28915bd1b7db5d1f0b1a8bf6
Author: serge-sans-paille <sguelton@mozilla.com>
Date:   Mon,  3 Nov 2025 16:07:51 +0000

Bug 1996759 - Register NullableBooleanType as a regular TYPE_CLASSES r=ahochheiden

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

Diffstat:
Mpython/mach/mach/config.py | 25+++++++++++++++++++++++++
Mpython/mach/mach/settings.py | 27+--------------------------
2 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/python/mach/mach/config.py b/python/mach/mach/config.py @@ -83,6 +83,30 @@ class BooleanType(ConfigType): return "true" if value else "false" +class NullableBooleanType(ConfigType): + """ConfigType for nullable boolean: True, False, or None.""" + + @staticmethod + def validate(value): + if value is not None and not isinstance(value, bool): + raise TypeError() + + @staticmethod + def from_config(config, section, option): + value = config.get(section, option).lower() + if value == "true": + return True + elif value == "false": + return False + return None + + @staticmethod + def to_config(value): + if value is None: + return "unknown" + return "true" if value else "false" + + class IntegerType(ConfigType): @staticmethod def validate(value): @@ -118,6 +142,7 @@ class PathType(StringType): TYPE_CLASSES = { "string": StringType, "boolean": BooleanType, + "nullable_boolean": NullableBooleanType, "int": IntegerType, "pos_int": PositiveIntegerType, "path": PathType, diff --git a/python/mach/mach/settings.py b/python/mach/mach/settings.py @@ -2,34 +2,9 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this file, # You can obtain one at http://mozilla.org/MPL/2.0/. -from mach.config import ConfigType from mach.decorators import SettingsProvider -class NullableBooleanType(ConfigType): - """ConfigType for nullable boolean: True, False, or None.""" - - @staticmethod - def validate(value): - if value is not None and not isinstance(value, bool): - raise TypeError() - - @staticmethod - def from_config(config, section, option): - value = config.get(section, option).lower() - if value == "true": - return True - elif value == "false": - return False - return None - - @staticmethod - def to_config(value): - if value is None: - return "unknown" - return "true" if value else "false" - - @SettingsProvider class MachSettings: @classmethod @@ -57,7 +32,7 @@ class MachSettings: ), ( "mach_telemetry.is_employee", - NullableBooleanType, + "nullable_boolean", "Cached value for whether the user is a Mozilla employee " "(None=unknown, True=employee, False=not an employee)", None,