aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/ast/introspection.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2020-09-09 10:31:52 -0700
committerGitHub <noreply@github.com>2020-09-09 10:31:52 -0700
commit4c2d0eb9bcedefa3ef06a237a0502afbc581268b (patch)
tree1b08ca5fb0c93573409a7a8954e6e1905f8a5b10 /mesonbuild/ast/introspection.py
parent8d54b7bda30062569c981b50a85a175565a7c15a (diff)
parent057c77f7d08b3372e99065fb3f3cd37f16801a82 (diff)
downloadmeson-4c2d0eb9bcedefa3ef06a237a0502afbc581268b.zip
meson-4c2d0eb9bcedefa3ef06a237a0502afbc581268b.tar.gz
meson-4c2d0eb9bcedefa3ef06a237a0502afbc581268b.tar.bz2
Merge pull request #7657 from mensinda/moreTyping
typing: Strict type annotations
Diffstat (limited to 'mesonbuild/ast/introspection.py')
-rw-r--r--mesonbuild/ast/introspection.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/mesonbuild/ast/introspection.py b/mesonbuild/ast/introspection.py
index 009fdb0..f03f7d2 100644
--- a/mesonbuild/ast/introspection.py
+++ b/mesonbuild/ast/introspection.py
@@ -21,20 +21,25 @@ from .. import compilers, environment, mesonlib, optinterpreter
from .. import coredata as cdata
from ..mesonlib import MachineChoice
from ..interpreterbase import InvalidArguments, TYPE_nvar
-from ..build import Executable, Jar, SharedLibrary, SharedModule, StaticLibrary
+from ..build import BuildTarget, Executable, Jar, SharedLibrary, SharedModule, StaticLibrary
from ..mparser import BaseNode, ArithmeticNode, ArrayNode, ElementaryNode, IdNode, FunctionNode, StringNode
import typing as T
import os
+import argparse
build_target_functions = ['executable', 'jar', 'library', 'shared_library', 'shared_module', 'static_library', 'both_libraries']
-class IntrospectionHelper:
+class IntrospectionHelper(argparse.Namespace):
# mimic an argparse namespace
def __init__(self, cross_file: str):
+ super().__init__()
self.cross_file = cross_file # type: str
self.native_file = None # type: str
self.cmd_line_options = {} # type: T.Dict[str, str]
+ def __eq__(self, other: object) -> bool:
+ return NotImplemented
+
class IntrospectionInterpreter(AstInterpreter):
# Interpreter to detect the options without a build directory
# Most of the code is stolen from interpreter.Interpreter
@@ -182,7 +187,7 @@ class IntrospectionInterpreter(AstInterpreter):
'node': node
}]
- def build_target(self, node: BaseNode, args: T.List[TYPE_nvar], kwargs_raw: T.Dict[str, TYPE_nvar], targetclass) -> T.Optional[T.Dict[str, T.Any]]:
+ def build_target(self, node: BaseNode, args: T.List[TYPE_nvar], kwargs_raw: T.Dict[str, TYPE_nvar], targetclass: T.Type[BuildTarget]) -> T.Optional[T.Dict[str, T.Any]]:
args = self.flatten_args(args)
if not args or not isinstance(args[0], str):
return None