aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/interpreterbase
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2021-12-04 21:11:51 -0500
committerEli Schwartz <eschwartz@archlinux.org>2022-01-10 18:36:57 -0500
commit4b351aef26a19b4c73f6ef295f64da1c74bc713d (patch)
tree44f0b5c34c6bfb06360ffc22870ff423fc9305e2 /mesonbuild/interpreterbase
parent98a41ec24e77d7670ea83fd986853d0fe7cb2f5b (diff)
downloadmeson-4b351aef26a19b4c73f6ef295f64da1c74bc713d.zip
meson-4b351aef26a19b4c73f6ef295f64da1c74bc713d.tar.gz
meson-4b351aef26a19b4c73f6ef295f64da1c74bc713d.tar.bz2
first pass at migrating to dataclasses
In some cases, init variables that accept None as a sentinel and immediately overwrite with [], are migrated to dataclass field factories. \o/ Note: dataclasses by default cannot provide eq methods, as they then become unhashable. In the future we may wish to opt into declaring them frozen, instead/additionally.
Diffstat (limited to 'mesonbuild/interpreterbase')
-rw-r--r--mesonbuild/interpreterbase/decorators.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/mesonbuild/interpreterbase/decorators.py b/mesonbuild/interpreterbase/decorators.py
index 0f493f2..c6fcaa0 100644
--- a/mesonbuild/interpreterbase/decorators.py
+++ b/mesonbuild/interpreterbase/decorators.py
@@ -19,6 +19,7 @@ from .exceptions import InterpreterException, InvalidArguments
from .operator import MesonOperator
from ._unholder import _unholder
+from dataclasses import dataclass
from functools import wraps
import abc
import itertools
@@ -99,10 +100,9 @@ def disablerIfNotFound(f: TV_func) -> TV_func:
return ret
return T.cast(TV_func, wrapped)
+@dataclass(repr=False, eq=False)
class permittedKwargs:
-
- def __init__(self, permitted: T.Set[str]):
- self.permitted = permitted # type: T.Set[str]
+ permitted: T.Set[str]
def __call__(self, f: TV_func) -> TV_func:
@wraps(f)
@@ -575,6 +575,7 @@ def typed_kwargs(name: str, *types: KwargInfo) -> T.Callable[..., T.Any]:
return inner
+# This cannot be a dataclass due to https://github.com/python/mypy/issues/5374
class FeatureCheckBase(metaclass=abc.ABCMeta):
"Base class for feature version checks"
@@ -738,6 +739,7 @@ class FeatureDeprecated(FeatureCheckBase):
mlog.warning(*args, location=self.location)
+# This cannot be a dataclass due to https://github.com/python/mypy/issues/5374
class FeatureCheckKwargsBase(metaclass=abc.ABCMeta):
@property