aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/ast
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2022-03-01 23:32:14 -0500
committerEli Schwartz <eschwartz@archlinux.org>2022-03-07 19:01:04 -0500
commita009eacc65ddb447edcfc9fd317ad828d9b3353a (patch)
treeae1c6388bfa45eb0672bbed1d8f18ebe0b3c2819 /mesonbuild/ast
parent187dc656f48ba7a86a14a5c8d9f16a3b2b7d8770 (diff)
downloadmeson-a009eacc65ddb447edcfc9fd317ad828d9b3353a.zip
meson-a009eacc65ddb447edcfc9fd317ad828d9b3353a.tar.gz
meson-a009eacc65ddb447edcfc9fd317ad828d9b3353a.tar.bz2
treewide: string-quote the first argument to T.cast
Using future annotations, type annotations become strings at runtime and don't impact performance. This is not possible to do with T.cast though, because it is a function argument instead of an annotation. Quote the type argument everywhere in order to have the same effect as future annotations. This also allows linters to better detect in some cases that a given import is typing-only.
Diffstat (limited to 'mesonbuild/ast')
-rw-r--r--mesonbuild/ast/interpreter.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/mesonbuild/ast/interpreter.py b/mesonbuild/ast/interpreter.py
index f5a1e5e..fe11870 100644
--- a/mesonbuild/ast/interpreter.py
+++ b/mesonbuild/ast/interpreter.py
@@ -31,7 +31,6 @@ from ..interpreterbase import (
)
from ..interpreter import (
- Interpreter,
StringHolder,
BooleanHolder,
IntegerHolder,
@@ -64,6 +63,9 @@ from ..mparser import (
import os, sys
import typing as T
+if T.TYPE_CHECKING:
+ from ..interpreter import Interpreter
+
class DontCareObject(MesonInterpreterObject):
pass
@@ -378,15 +380,15 @@ class AstInterpreter(InterpreterBase):
mkwargs = {} # type: T.Dict[str, TYPE_nvar]
try:
if isinstance(src, str):
- result = StringHolder(src, T.cast(Interpreter, self)).method_call(node.name, margs, mkwargs)
+ result = StringHolder(src, T.cast('Interpreter', self)).method_call(node.name, margs, mkwargs)
elif isinstance(src, bool):
- result = BooleanHolder(src, T.cast(Interpreter, self)).method_call(node.name, margs, mkwargs)
+ result = BooleanHolder(src, T.cast('Interpreter', self)).method_call(node.name, margs, mkwargs)
elif isinstance(src, int):
- result = IntegerHolder(src, T.cast(Interpreter, self)).method_call(node.name, margs, mkwargs)
+ result = IntegerHolder(src, T.cast('Interpreter', self)).method_call(node.name, margs, mkwargs)
elif isinstance(src, list):
- result = ArrayHolder(src, T.cast(Interpreter, self)).method_call(node.name, margs, mkwargs)
+ result = ArrayHolder(src, T.cast('Interpreter', self)).method_call(node.name, margs, mkwargs)
elif isinstance(src, dict):
- result = DictHolder(src, T.cast(Interpreter, self)).method_call(node.name, margs, mkwargs)
+ result = DictHolder(src, T.cast('Interpreter', self)).method_call(node.name, margs, mkwargs)
except mesonlib.MesonException:
return None