From af0587cb490dfa2c2a00c2426c10d1de11d34fdd Mon Sep 17 00:00:00 2001 From: Daniel Mensinger Date: Sun, 26 Sep 2021 11:09:23 +0200 Subject: interpreter: Holderify arrays and dicts This is the final refactoring for extracting the bultin object logic out of Interpreterbase. I decided to do both arrays and dicts in one go since splitting it would have been a lot more confusing. --- mesonbuild/interpreterbase/_unholder.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'mesonbuild/interpreterbase/_unholder.py') diff --git a/mesonbuild/interpreterbase/_unholder.py b/mesonbuild/interpreterbase/_unholder.py index 221c52c..7157d17 100644 --- a/mesonbuild/interpreterbase/_unholder.py +++ b/mesonbuild/interpreterbase/_unholder.py @@ -16,14 +16,8 @@ from .baseobjects import InterpreterObject, MesonInterpreterObject, ObjectHolder from .exceptions import InvalidArguments from ..mesonlib import HoldableObject, MesonBugException -import typing as T - -def _unholder(obj: T.Union[TYPE_var, InterpreterObject]) -> TYPE_var: - if isinstance(obj, list): - return [_unholder(x) for x in obj] - elif isinstance(obj, dict): - return {k: _unholder(v) for k, v in obj.items()} - elif isinstance(obj, ObjectHolder): +def _unholder(obj: InterpreterObject) -> TYPE_var: + if isinstance(obj, ObjectHolder): assert isinstance(obj.held_object, HoldableTypes) return obj.held_object elif isinstance(obj, MesonInterpreterObject): -- cgit v1.1