diff options
| author | Dylan Baker <dylan@pnwbakers.com> | 2025-02-28 09:18:01 -0800 |
|---|---|---|
| committer | Dylan Baker <dylan@pnwbakers.com> | 2025-03-03 11:26:23 -0800 |
| commit | 294eca343d072a18a22d9a0cf932a8e97bdb16ed (patch) | |
| tree | 27c14017d19e94082f63a605a7c9ec40d474efae | |
| parent | 2ed0d5ed3bda03283fac5780794f43967e691749 (diff) | |
| download | meson-294eca343d072a18a22d9a0cf932a8e97bdb16ed.tar.gz | |
options: store the default value in the class
Initially this is just used for getting builtin option default values,
but it could be extended to show the default value of an option in the
summary and in the introspection API.
| -rw-r--r-- | mesonbuild/options.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/mesonbuild/options.py b/mesonbuild/options.py index ab4fcbe0c..a84712783 100644 --- a/mesonbuild/options.py +++ b/mesonbuild/options.py @@ -33,7 +33,7 @@ from .mesonlib import ( from . import mlog if T.TYPE_CHECKING: - from typing_extensions import Literal, TypeAlias, TypedDict + from typing_extensions import Literal, Final, TypeAlias, TypedDict DeprecatedType: TypeAlias = T.Union[bool, str, T.Dict[str, str], T.List[str]] AnyOptionType: TypeAlias = T.Union[ @@ -324,6 +324,8 @@ class UserOption(T.Generic[_T], HoldableObject): def __post_init__(self, value_: _T) -> None: self.value = self.validate_value(value_) + # Final isn't technically allowed in a __post_init__ method + self.default: Final[_T] = self.value # type: ignore[misc] def listify(self, value: T.Any) -> T.List[T.Any]: return [value] |
