|
|
|
@ -15,7 +15,7 @@ from abc import ABCMeta |
|
|
|
|
from contextlib import AbstractContextManager |
|
|
|
|
|
|
|
|
|
if T.TYPE_CHECKING: |
|
|
|
|
from typing_extensions import Protocol |
|
|
|
|
from typing_extensions import Protocol, TypeAlias |
|
|
|
|
|
|
|
|
|
# Object holders need the actual interpreter |
|
|
|
|
from ..interpreter import Interpreter |
|
|
|
@ -28,8 +28,8 @@ if T.TYPE_CHECKING: |
|
|
|
|
|
|
|
|
|
TV_func = T.TypeVar('TV_func', bound=T.Callable[..., T.Any]) |
|
|
|
|
|
|
|
|
|
TYPE_elementary = T.Union[str, int, bool, T.List[T.Any], T.Dict[str, T.Any]] |
|
|
|
|
TYPE_var = T.Union[TYPE_elementary, HoldableObject, 'MesonInterpreterObject'] |
|
|
|
|
TYPE_elementary: TypeAlias = T.Union[str, int, bool, T.Sequence['TYPE_elementary'], T.Dict[str, 'TYPE_elementary']] |
|
|
|
|
TYPE_var: TypeAlias = T.Union[TYPE_elementary, HoldableObject, 'MesonInterpreterObject', T.Sequence['TYPE_var'], T.Dict[str, 'TYPE_var']] |
|
|
|
|
TYPE_nvar = T.Union[TYPE_var, mparser.BaseNode] |
|
|
|
|
TYPE_kwargs = T.Dict[str, TYPE_var] |
|
|
|
|
TYPE_nkwargs = T.Dict[str, TYPE_nvar] |
|
|
|
@ -122,7 +122,7 @@ class MutableInterpreterObject: |
|
|
|
|
''' Dummy class to mark the object type as mutable ''' |
|
|
|
|
|
|
|
|
|
HoldableTypes = (HoldableObject, int, bool, str, list, dict) |
|
|
|
|
TYPE_HoldableTypes = T.Union[TYPE_elementary, HoldableObject] |
|
|
|
|
TYPE_HoldableTypes = T.Union[TYPE_var, HoldableObject] |
|
|
|
|
InterpreterObjectTypeVar = T.TypeVar('InterpreterObjectTypeVar', bound=TYPE_HoldableTypes) |
|
|
|
|
|
|
|
|
|
class ObjectHolder(InterpreterObject, T.Generic[InterpreterObjectTypeVar]): |
|
|
|
|