summaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2024-09-04 09:39:38 -0700
committerEli Schwartz <eschwartz93@gmail.com>2024-09-08 22:50:21 -0400
commitf83dca32fe340727ada08b46d70bfc6dbba52d84 (patch)
tree77a970ae24e09628c9e3cdac5eae746173fd3cf4 /mesonbuild
parent58c6b13c4e970223eae09fd88992d32cb1624ba9 (diff)
downloadmeson-f83dca32fe340727ada08b46d70bfc6dbba52d84.tar.gz
interpreterbase: Use explicit `TypeAlias` annotation to allow recursive types
And fix all of the issues that pop up once we remove the use of `Any`, which hides so many problems.
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/interpreterbase/baseobjects.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/mesonbuild/interpreterbase/baseobjects.py b/mesonbuild/interpreterbase/baseobjects.py
index 9a119a98a..a5ccccedc 100644
--- a/mesonbuild/interpreterbase/baseobjects.py
+++ b/mesonbuild/interpreterbase/baseobjects.py
@@ -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]):