diff options
Diffstat (limited to 'mesonbuild/interpreterbase/decorators.py')
-rw-r--r-- | mesonbuild/interpreterbase/decorators.py | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/mesonbuild/interpreterbase/decorators.py b/mesonbuild/interpreterbase/decorators.py index 7c04483..359fa85 100644 --- a/mesonbuild/interpreterbase/decorators.py +++ b/mesonbuild/interpreterbase/decorators.py @@ -25,10 +25,21 @@ import abc import itertools import copy import typing as T + if T.TYPE_CHECKING: + from typing_extensions import Protocol + from .. import mparser + from .baseobjects import InterpreterObject from .interpreterbase import SubProject + _TV_IntegerObject = T.TypeVar('_TV_IntegerObject', bound=InterpreterObject, contravariant=True) + _TV_ARG1 = T.TypeVar('_TV_ARG1', bound=TYPE_var, contravariant=True) + + class FN_Operator(Protocol[_TV_IntegerObject, _TV_ARG1]): + def __call__(s, self: _TV_IntegerObject, other: _TV_ARG1) -> TYPE_var: ... + _TV_FN_Operator = T.TypeVar('_TV_FN_Operator', bound=FN_Operator) + def get_callee_args(wrapped_args: T.Sequence[T.Any]) -> T.Tuple['mparser.BaseNode', T.List['TYPE_var'], 'TYPE_kwargs', 'SubProject']: # First argument could be InterpreterBase, InterpreterObject or ModuleObject. # In the case of a ModuleObject it is the 2nd argument (ModuleState) that @@ -116,17 +127,6 @@ class permittedKwargs: return f(*wrapped_args, **wrapped_kwargs) return T.cast(TV_func, wrapped) -if T.TYPE_CHECKING: - from .baseobjects import InterpreterObject - from typing_extensions import Protocol - - _TV_IntegerObject = T.TypeVar('_TV_IntegerObject', bound=InterpreterObject, contravariant=True) - _TV_ARG1 = T.TypeVar('_TV_ARG1', bound=TYPE_var, contravariant=True) - - class FN_Operator(Protocol[_TV_IntegerObject, _TV_ARG1]): - def __call__(s, self: _TV_IntegerObject, other: _TV_ARG1) -> TYPE_var: ... - _TV_FN_Operator = T.TypeVar('_TV_FN_Operator', bound=FN_Operator) - def typed_operator(operator: MesonOperator, types: T.Union[T.Type, T.Tuple[T.Type, ...]]) -> T.Callable[['_TV_FN_Operator'], '_TV_FN_Operator']: """Decorator that does type checking for operator calls. |