From dffa93b8530c941f0c8d6bad96eb6cd0489bef27 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Tue, 10 Aug 2021 12:10:28 -0700 Subject: [PATCH] backend/backends: use a TypedDict for introspection data Which is easier to reason about as a human, and narrower, allowing for more accurate type checking. --- mesonbuild/backend/backends.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py index 21e45bd2c..658f03101 100644 --- a/mesonbuild/backend/backends.py +++ b/mesonbuild/backend/backends.py @@ -45,6 +45,16 @@ if T.TYPE_CHECKING: from ..mesonlib import FileMode, FileOrString from ..wrap import WrapMode + from typing_extensions import TypedDict + + class TargetIntrospectionData(TypedDict): + + language: str + compiler : T.List[str] + parameters: T.List[str] + sources: T.List[str] + generated_sources: T.List[str] + # Languages that can mix with C or C++ but don't support unity builds yet # because the syntax we use for unity builds is specific to C/++/ObjC/++. @@ -1666,7 +1676,7 @@ class Backend: i = SubdirInstallData(src_dir, dst_dir, sd.install_mode, sd.exclude, sd.subproject) d.install_subdirs.append(i) - def get_introspection_data(self, target_id: str, target: build.Target) -> T.List[T.Dict[str, T.Union[bool, str, T.List[T.Union[str, T.Dict[str, T.Union[str, T.List[str], bool]]]]]]]: + def get_introspection_data(self, target_id: str, target: build.Target) -> T.List['TargetIntrospectionData']: ''' Returns a list of source dicts with the following format for a given target: [