From f1a09aabf129d95bca6f2493e6a6899e17fa4d33 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Mon, 29 Jan 2024 13:13:56 -0800 Subject: [PATCH] build: store Build.modules as a set Since it's only used to check membership, a set makes more sense. Also add some documentation to the attribute --- mesonbuild/build.py | 6 +++++- mesonbuild/interpreter/interpreter.py | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 460ed549b..0d9374d40 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -275,7 +275,11 @@ class Build: self.dependency_overrides: PerMachine[T.Dict[T.Tuple, DependencyOverride]] = PerMachineDefaultable.default( environment.is_cross_build(), {}, {}) self.devenv: T.List[EnvironmentVariables] = [] - self.modules: T.List[str] = [] + self.modules: T.Set[str] = set() + """Used to track which modules are enabled in all subprojects. + + Needed for tracking whether a modules options needs to be exposed to the user. + """ def get_build_targets(self): build_targets = OrderedDict() diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py index d7523e7ea..dd73522a0 100644 --- a/mesonbuild/interpreter/interpreter.py +++ b/mesonbuild/interpreter/interpreter.py @@ -632,8 +632,8 @@ class Interpreter(InterpreterBase, HoldableObject): ext_module = NotFoundExtensionModule(real_modname) else: ext_module = module.initialize(self) - assert isinstance(ext_module, (ExtensionModule, NewExtensionModule)), 'for mypy' - self.build.modules.append(real_modname) + assert isinstance(ext_module, (ExtensionModule, NewExtensionModule)) + self.build.modules.add(real_modname) if ext_module.INFO.added: FeatureNew.single_use(f'module {ext_module.INFO.name}', ext_module.INFO.added, self.subproject, location=node) if ext_module.INFO.deprecated: