aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/interpreterbase.py
diff options
context:
space:
mode:
authorRan Benita <ran234@gmail.com>2018-02-23 03:45:13 +0200
committerRan Benita <ran234@gmail.com>2018-02-23 04:35:15 +0200
commit4d8e4654cb9b3958897d2d230a3714b1abc6b9b4 (patch)
treedaf8e0be61c3360820c714fac1750b05950d6583 /mesonbuild/interpreterbase.py
parent6ec401af4b3ac974a1699fa5486e19dd299d77e0 (diff)
downloadmeson-4d8e4654cb9b3958897d2d230a3714b1abc6b9b4.zip
meson-4d8e4654cb9b3958897d2d230a3714b1abc6b9b4.tar.gz
meson-4d8e4654cb9b3958897d2d230a3714b1abc6b9b4.tar.bz2
Warn if non-permitted keyword arguments are given to compiler methods
This can help future generations avoid mistakes like this: https://github.com/xkbcommon/libxkbcommon/commit/edb1c662394578a54b7bbed231d918925e5d8150 To avoid breaking builds, this is currently just an error. After sufficient time has passed this can hopefully become a hard error, similarly to the already-existing `permittedKwargs` warnings.
Diffstat (limited to 'mesonbuild/interpreterbase.py')
-rw-r--r--mesonbuild/interpreterbase.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/mesonbuild/interpreterbase.py b/mesonbuild/interpreterbase.py
index 0539b14..c56e30b 100644
--- a/mesonbuild/interpreterbase.py
+++ b/mesonbuild/interpreterbase.py
@@ -80,6 +80,22 @@ class permittedKwargs:
return wrapped
+class permittedMethodKwargs:
+
+ def __init__(self, permitted):
+ self.permitted = permitted
+
+ def __call__(self, f):
+ @wraps(f)
+ def wrapped(obj, args, kwargs):
+ for k in kwargs:
+ if k not in self.permitted:
+ mlog.warning('''Passed invalid keyword argument "{}".'''.format(k))
+ mlog.warning('This will become a hard error in the future.')
+ return f(obj, args, kwargs)
+ return wrapped
+
+
class InterpreterException(mesonlib.MesonException):
pass