diff options
author | Daniel Mensinger <daniel@mensinger-ka.de> | 2020-01-06 15:27:38 +0100 |
---|---|---|
committer | Daniel Mensinger <daniel@mensinger-ka.de> | 2020-01-08 15:28:17 +0100 |
commit | 09b53c534f74806ebc49bb2fcdfbae0e3b26fb84 (patch) | |
tree | 4466a6005333d6d1ae7d67cbaf24fb63e104df6a /mesonbuild/cmake | |
parent | f3199edaf8802e2a59fed2f83e825e09b9d4bd0d (diff) | |
download | meson-09b53c534f74806ebc49bb2fcdfbae0e3b26fb84.zip meson-09b53c534f74806ebc49bb2fcdfbae0e3b26fb84.tar.gz meson-09b53c534f74806ebc49bb2fcdfbae0e3b26fb84.tar.bz2 |
types: import typing as T (fixes #6333)
Diffstat (limited to 'mesonbuild/cmake')
-rw-r--r-- | mesonbuild/cmake/client.py | 14 | ||||
-rw-r--r-- | mesonbuild/cmake/common.py | 4 | ||||
-rw-r--r-- | mesonbuild/cmake/executor.py | 18 | ||||
-rw-r--r-- | mesonbuild/cmake/fileapi.py | 14 | ||||
-rw-r--r-- | mesonbuild/cmake/interpreter.py | 62 | ||||
-rw-r--r-- | mesonbuild/cmake/traceparser.py | 28 |
6 files changed, 70 insertions, 70 deletions
diff --git a/mesonbuild/cmake/client.py b/mesonbuild/cmake/client.py index 9cb7f74..b88a673 100644 --- a/mesonbuild/cmake/client.py +++ b/mesonbuild/cmake/client.py @@ -22,7 +22,7 @@ from ..mesonlib import MachineChoice from .. import mlog from contextlib import contextmanager from subprocess import Popen, PIPE, TimeoutExpired -from typing import List, Optional +import typing as T import json import os @@ -110,11 +110,11 @@ class Progress(MessageBase): pass class MessageHello(MessageBase): - def __init__(self, supported_protocol_versions: List[dict]): + def __init__(self, supported_protocol_versions: T.List[dict]): super().__init__('hello', '') self.supported_protocol_versions = supported_protocol_versions - def supports(self, major: int, minor: Optional[int] = None) -> bool: + def supports(self, major: int, minor: T.Optional[int] = None) -> bool: for i in self.supported_protocol_versions: if major == i['major']: if minor is None or minor == i['minor']: @@ -124,7 +124,7 @@ class MessageHello(MessageBase): # Request classes class RequestHandShake(RequestBase): - def __init__(self, src_dir: str, build_dir: str, generator: str, vers_major: int, vers_minor: Optional[int] = None): + def __init__(self, src_dir: str, build_dir: str, generator: str, vers_major: int, vers_minor: T.Optional[int] = None): super().__init__('handshake') self.src_dir = src_dir self.build_dir = build_dir @@ -150,7 +150,7 @@ class RequestHandShake(RequestBase): } class RequestConfigure(RequestBase): - def __init__(self, args: Optional[List[str]] = None): + def __init__(self, args: T.Optional[T.List[str]] = None): super().__init__('configure') self.args = args @@ -187,7 +187,7 @@ class ReplyCompute(ReplyBase): super().__init__(cookie, 'compute') class ReplyCMakeInputs(ReplyBase): - def __init__(self, cookie: str, cmake_root: str, src_dir: str, build_files: List[CMakeBuildFile]): + def __init__(self, cookie: str, cmake_root: str, src_dir: str, build_files: T.List[CMakeBuildFile]): super().__init__(cookie, 'cmakeInputs') self.cmake_root = cmake_root self.src_dir = src_dir @@ -296,7 +296,7 @@ class CMakeClient: raise CMakeException('CMake server query failed') return reply - def do_handshake(self, src_dir: str, build_dir: str, generator: str, vers_major: int, vers_minor: Optional[int] = None) -> None: + def do_handshake(self, src_dir: str, build_dir: str, generator: str, vers_major: int, vers_minor: T.Optional[int] = None) -> None: # CMake prints the hello message on startup msg = self.readMessage() if not isinstance(msg, MessageHello): diff --git a/mesonbuild/cmake/common.py b/mesonbuild/cmake/common.py index 7a0e784..e7da0d7 100644 --- a/mesonbuild/cmake/common.py +++ b/mesonbuild/cmake/common.py @@ -17,7 +17,7 @@ from ..mesonlib import MesonException from .. import mlog -from typing import List +import typing as T class CMakeException(MesonException): pass @@ -31,7 +31,7 @@ class CMakeBuildFile: def __repr__(self): return '<{}: {}; cmake={}; temp={}>'.format(self.__class__.__name__, self.file, self.is_cmake, self.is_temp) -def _flags_to_list(raw: str) -> List[str]: +def _flags_to_list(raw: str) -> T.List[str]: # Convert a raw commandline string into a list of strings res = [] curr = '' diff --git a/mesonbuild/cmake/executor.py b/mesonbuild/cmake/executor.py index 4300656..bf4fa5d 100644 --- a/mesonbuild/cmake/executor.py +++ b/mesonbuild/cmake/executor.py @@ -17,7 +17,7 @@ import subprocess from pathlib import Path -from typing import List, Tuple, Optional, TYPE_CHECKING +import typing as T import re import os import shutil @@ -27,7 +27,7 @@ from .. import mlog, mesonlib from ..mesonlib import PerMachine, Popen_safe, version_compare, MachineChoice from ..environment import Environment -if TYPE_CHECKING: +if T.TYPE_CHECKING: from ..dependencies.base import ExternalProgram @@ -55,7 +55,7 @@ class CMakeExecutor: self.cmakebin = None return - def find_cmake_binary(self, environment: Environment, silent: bool = False) -> Tuple['ExternalProgram', str]: + def find_cmake_binary(self, environment: Environment, silent: bool = False) -> T.Tuple['ExternalProgram', str]: from ..dependencies.base import ExternalProgram # Create an iterator of options @@ -107,7 +107,7 @@ class CMakeExecutor: return CMakeExecutor.class_cmakebin[self.for_machine], CMakeExecutor.class_cmakevers[self.for_machine] - def check_cmake(self, cmakebin: 'ExternalProgram') -> Optional[str]: + def check_cmake(self, cmakebin: 'ExternalProgram') -> T.Optional[str]: if not cmakebin.found(): mlog.log('Did not find CMake {!r}'.format(cmakebin.name)) return None @@ -130,12 +130,12 @@ class CMakeExecutor: cmvers = re.sub(r'\s*cmake version\s*', '', out.split('\n')[0]).strip() return cmvers - def _cache_key(self, args: List[str], build_dir: str, env): + def _cache_key(self, args: T.List[str], build_dir: str, env): fenv = frozenset(env.items()) if env is not None else None targs = tuple(args) return (self.cmakebin, targs, build_dir, fenv) - def _call_real(self, args: List[str], build_dir: str, env) -> Tuple[int, str, str]: + def _call_real(self, args: T.List[str], build_dir: str, env) -> T.Tuple[int, str, str]: os.makedirs(build_dir, exist_ok=True) cmd = self.cmakebin.get_command() + args ret = subprocess.run(cmd, env=env, cwd=build_dir, close_fds=False, @@ -148,7 +148,7 @@ class CMakeExecutor: mlog.debug("Called `{}` in {} -> {}".format(call, build_dir, rc)) return rc, out, err - def call(self, args: List[str], build_dir: str, env=None, disable_cache: bool = False): + def call(self, args: T.List[str], build_dir: str, env=None, disable_cache: bool = False): if env is None: env = os.environ @@ -162,7 +162,7 @@ class CMakeExecutor: cache[key] = self._call_real(args, build_dir, env) return cache[key] - def call_with_fake_build(self, args: List[str], build_dir: str, env=None): + def call_with_fake_build(self, args: T.List[str], build_dir: str, env=None): # First check the cache cache = CMakeExecutor.class_cmake_cache key = self._cache_key(args, build_dir, env) @@ -186,7 +186,7 @@ class CMakeExecutor: p = fallback return p - def choose_compiler(lang: str) -> Tuple[str, str]: + def choose_compiler(lang: str) -> T.Tuple[str, str]: exe_list = [] if lang in compilers: exe_list = compilers[lang].get_exelist() diff --git a/mesonbuild/cmake/fileapi.py b/mesonbuild/cmake/fileapi.py index c62eadb..f219f16 100644 --- a/mesonbuild/cmake/fileapi.py +++ b/mesonbuild/cmake/fileapi.py @@ -13,7 +13,7 @@ # limitations under the License. from .common import CMakeException, CMakeBuildFile, CMakeConfiguration -from typing import Any, List, Tuple +import typing as T from .. import mlog import os import json @@ -34,10 +34,10 @@ class CMakeFileAPI: 'cmakeFiles': self._parse_cmakeFiles, } - def get_cmake_sources(self) -> List[CMakeBuildFile]: + def get_cmake_sources(self) -> T.List[CMakeBuildFile]: return self.cmake_sources - def get_cmake_configurations(self) -> List[CMakeConfiguration]: + def get_cmake_configurations(self) -> T.List[CMakeConfiguration]: return self.cmake_configurations def setup_request(self) -> None: @@ -100,7 +100,7 @@ class CMakeFileAPI: # resolved and the resulting data structure is identical # to the CMake serve output. - def helper_parse_dir(dir_entry: dict) -> Tuple[str, str]: + def helper_parse_dir(dir_entry: dict) -> T.Tuple[str, str]: src_dir = dir_entry.get('source', '.') bld_dir = dir_entry.get('build', '.') src_dir = src_dir if os.path.isabs(src_dir) else os.path.join(source_dir, src_dir) @@ -110,7 +110,7 @@ class CMakeFileAPI: return src_dir, bld_dir - def parse_sources(comp_group: dict, tgt: dict) -> Tuple[List[str], List[str], List[int]]: + def parse_sources(comp_group: dict, tgt: dict) -> T.Tuple[T.List[str], T.List[str], T.List[int]]: gen = [] src = [] idx = [] @@ -279,7 +279,7 @@ class CMakeFileAPI: path = path if os.path.isabs(path) else os.path.join(src_dir, path) self.cmake_sources += [CMakeBuildFile(path, i.get('isCMake', False), i.get('isGenerated', False))] - def _strip_data(self, data: Any) -> Any: + def _strip_data(self, data: T.Any) -> T.Any: if isinstance(data, list): for idx, i in enumerate(data): data[idx] = self._strip_data(i) @@ -293,7 +293,7 @@ class CMakeFileAPI: return data - def _resolve_references(self, data: Any) -> Any: + def _resolve_references(self, data: T.Any) -> T.Any: if isinstance(data, list): for idx, i in enumerate(data): data[idx] = self._resolve_references(i) diff --git a/mesonbuild/cmake/interpreter.py b/mesonbuild/cmake/interpreter.py index 5f887ee..9155d6d 100644 --- a/mesonbuild/cmake/interpreter.py +++ b/mesonbuild/cmake/interpreter.py @@ -25,10 +25,10 @@ from ..environment import Environment from ..mesonlib import MachineChoice, version_compare from ..compilers.compilers import lang_suffixes, header_suffixes, obj_suffixes, lib_suffixes, is_header from subprocess import Popen, PIPE -from typing import Any, List, Dict, Optional, Set, Union, TYPE_CHECKING from threading import Thread from enum import Enum from functools import lru_cache +import typing as T import os, re from ..mparser import ( @@ -48,7 +48,7 @@ from ..mparser import ( ) -if TYPE_CHECKING: +if T.TYPE_CHECKING: from ..build import Build from ..backend.backends import Backend @@ -136,8 +136,8 @@ class OutputTargetMap: self.tgt_map = {} self.build_dir = build_dir - def add(self, tgt: Union['ConverterTarget', 'ConverterCustomTarget']) -> None: - def assign_keys(keys: List[str]) -> None: + def add(self, tgt: T.Union['ConverterTarget', 'ConverterCustomTarget']) -> None: + def assign_keys(keys: T.List[str]) -> None: for i in [x for x in keys if x]: self.tgt_map[i] = tgt keys = [self._target_key(tgt.cmake_name)] @@ -150,16 +150,16 @@ class OutputTargetMap: keys += [self._base_generated_file_key(x) for x in tgt.original_outputs] assign_keys(keys) - def _return_first_valid_key(self, keys: List[str]) -> Optional[Union['ConverterTarget', 'ConverterCustomTarget']]: + def _return_first_valid_key(self, keys: T.List[str]) -> T.Optional[T.Union['ConverterTarget', 'ConverterCustomTarget']]: for i in keys: if i and i in self.tgt_map: return self.tgt_map[i] return None - def target(self, name: str) -> Optional[Union['ConverterTarget', 'ConverterCustomTarget']]: + def target(self, name: str) -> T.Optional[T.Union['ConverterTarget', 'ConverterCustomTarget']]: return self._return_first_valid_key([self._target_key(name)]) - def artifact(self, name: str) -> Optional[Union['ConverterTarget', 'ConverterCustomTarget']]: + def artifact(self, name: str) -> T.Optional[T.Union['ConverterTarget', 'ConverterCustomTarget']]: keys = [] candidates = [name, OutputTargetMap.rm_so_version.sub('', name)] for i in lib_suffixes: @@ -172,11 +172,11 @@ class OutputTargetMap: keys += [self._rel_artifact_key(i), os.path.basename(i), self._base_artifact_key(i)] return self._return_first_valid_key(keys) - def generated(self, name: str) -> Optional[Union['ConverterTarget', 'ConverterCustomTarget']]: + def generated(self, name: str) -> T.Optional[T.Union['ConverterTarget', 'ConverterCustomTarget']]: return self._return_first_valid_key([self._rel_generated_file_key(name), self._base_generated_file_key(name)]) # Utility functions to generate local keys - def _rel_path(self, fname: str) -> Optional[str]: + def _rel_path(self, fname: str) -> T.Optional[str]: fname = os.path.normpath(os.path.join(self.build_dir, fname)) if os.path.commonpath([self.build_dir, fname]) != self.build_dir: return None @@ -185,14 +185,14 @@ class OutputTargetMap: def _target_key(self, tgt_name: str) -> str: return '__tgt_{}__'.format(tgt_name) - def _rel_generated_file_key(self, fname: str) -> Optional[str]: + def _rel_generated_file_key(self, fname: str) -> T.Optional[str]: path = self._rel_path(fname) return '__relgen_{}__'.format(path) if path else None def _base_generated_file_key(self, fname: str) -> str: return '__gen_{}__'.format(os.path.basename(fname)) - def _rel_artifact_key(self, fname: str) -> Optional[str]: + def _rel_artifact_key(self, fname: str) -> T.Optional[str]: path = self._rel_path(fname) return '__relart_{}__'.format(path) if path else None @@ -393,7 +393,7 @@ class ConverterTarget: self.generated = [x for x in self.generated if any([x.endswith(y) for y in supported])] # Make paths relative - def rel_path(x: str, is_header: bool, is_generated: bool) -> Optional[str]: + def rel_path(x: str, is_header: bool, is_generated: bool) -> T.Optional[str]: if not os.path.isabs(x): x = os.path.normpath(os.path.join(self.src_dir, x)) if not os.path.exists(x) and not any([x.endswith(y) for y in obj_suffixes]) and not is_generated: @@ -458,7 +458,7 @@ class ConverterTarget: if tgt: self.depends.append(tgt) - def process_object_libs(self, obj_target_list: List['ConverterTarget'], linker_workaround: bool): + def process_object_libs(self, obj_target_list: T.List['ConverterTarget'], linker_workaround: bool): # Try to detect the object library(s) from the generated input sources temp = [x for x in self.generated if isinstance(x, str)] temp = [os.path.basename(x) for x in temp] @@ -475,7 +475,7 @@ class ConverterTarget: # suffix and just produces object files like `foo.obj`. Thus we have to do our best to # undo this step and guess the correct language suffix of the object file. This is done # by trying all language suffixes meson knows and checking if one of them fits. - candidates = [j] # type: List[str] + candidates = [j] # type: T.List[str] if not any([j.endswith('.' + x) for x in exts]): mlog.warning('Object files do not contain source file extensions, thus falling back to guessing them.', once=True) candidates += ['{}.{}'.format(j, x) for x in exts] @@ -506,8 +506,8 @@ class ConverterTarget: self.compile_opts[lang] += [x for x in opts if x not in self.compile_opts[lang]] @lru_cache(maxsize=None) - def _all_source_suffixes(self) -> List[str]: - suffixes = [] # type: List[str] + def _all_source_suffixes(self) -> T.List[str]: + suffixes = [] # type: T.List[str] for exts in lang_suffixes.values(): suffixes += [x for x in exts] return suffixes @@ -599,7 +599,7 @@ class ConverterCustomTarget: def __repr__(self) -> str: return '<{}: {} {}>'.format(self.__class__.__name__, self.name, self.outputs) - def postprocess(self, output_target_map: OutputTargetMap, root_src_dir: str, subdir: str, build_dir: str, all_outputs: List[str]) -> None: + def postprocess(self, output_target_map: OutputTargetMap, root_src_dir: str, subdir: str, build_dir: str, all_outputs: T.List[str]) -> None: # Default the working directory to the CMake build dir. This # is not 100% correct, since it should be the value of # ${CMAKE_CURRENT_BINARY_DIR} when add_custom_command is @@ -626,7 +626,7 @@ class ConverterCustomTarget: # Ensure that there is no duplicate output in the project so # that meson can handle cases where the same filename is # generated in multiple directories - temp_outputs = [] # type: List[str] + temp_outputs = [] # type: T.List[str] for i in self.outputs: if i in all_outputs: old = str(i) @@ -689,7 +689,7 @@ class ConverterCustomTarget: new_deps += [i] self.depends = list(set(new_deps)) - def get_ref(self, fname: str) -> Optional[CustomTargetReference]: + def get_ref(self, fname: str) -> T.Optional[CustomTargetReference]: fname = os.path.basename(fname) try: if fname in self.conflict_map: @@ -724,7 +724,7 @@ class CMakeInterpreter: self.install_prefix = install_prefix self.env = env self.backend_name = backend.name - self.linkers = set() # type: Set[str] + self.linkers = set() # type: T.Set[str] self.cmake_api = CMakeAPI.SERVER self.client = CMakeClient(self.env) self.fileapi = CMakeFileAPI(self.build_dir) @@ -738,7 +738,7 @@ class CMakeInterpreter: self.project_name = '' self.languages = [] self.targets = [] - self.custom_targets = [] # type: List[ConverterCustomTarget] + self.custom_targets = [] # type: T.List[ConverterCustomTarget] self.trace = CMakeTraceParser() self.output_target_map = OutputTargetMap(self.build_dir) @@ -746,7 +746,7 @@ class CMakeInterpreter: self.generated_targets = {} self.internal_name_map = {} - def configure(self, extra_cmake_options: List[str]) -> None: + def configure(self, extra_cmake_options: T.List[str]) -> None: for_machine = MachineChoice.HOST # TODO make parameter # Find CMake cmake_exe = CMakeExecutor(self.env, '>=3.7', for_machine) @@ -835,7 +835,7 @@ class CMakeInterpreter: if proc.returncode != 0: raise CMakeException('Failed to configure the CMake subproject') - def initialise(self, extra_cmake_options: List[str]) -> None: + def initialise(self, extra_cmake_options: T.List[str]) -> None: # Run configure the old way because doing it # with the server doesn't work for some reason # Additionally, the File API requires a configure anyway @@ -893,7 +893,7 @@ class CMakeInterpreter: self.trace.parse(self.raw_trace) # Find all targets - added_target_names = [] # type: List[str] + added_target_names = [] # type: T.List[str] for i in self.codemodel_configs: for j in i.projects: if not self.project_name: @@ -929,7 +929,7 @@ class CMakeInterpreter: # First pass: Basic target cleanup object_libs = [] - custom_target_outputs = [] # type: List[str] + custom_target_outputs = [] # type: T.List[str] for i in self.custom_targets: i.postprocess(self.output_target_map, self.src_dir, self.subdir, self.build_dir, custom_target_outputs) for i in self.targets: @@ -1029,7 +1029,7 @@ class CMakeInterpreter: processed = {} name_map = {} - def extract_tgt(tgt: Union[ConverterTarget, ConverterCustomTarget, CustomTargetReference]) -> IdNode: + def extract_tgt(tgt: T.Union[ConverterTarget, ConverterCustomTarget, CustomTargetReference]) -> IdNode: tgt_name = None if isinstance(tgt, (ConverterTarget, ConverterCustomTarget)): tgt_name = tgt.name @@ -1039,7 +1039,7 @@ class CMakeInterpreter: res_var = processed[tgt_name]['tgt'] return id_node(res_var) if res_var else None - def detect_cycle(tgt: Union[ConverterTarget, ConverterCustomTarget]) -> None: + def detect_cycle(tgt: T.Union[ConverterTarget, ConverterCustomTarget]) -> None: if tgt.name in processing: raise CMakeException('Cycle in CMake inputs/dependencies detected') processing.append(tgt.name) @@ -1056,7 +1056,7 @@ class CMakeInterpreter: # First handle inter target dependencies link_with = [] - objec_libs = [] # type: List[IdNode] + objec_libs = [] # type: T.List[IdNode] sources = [] generated = [] generated_filenames = [] @@ -1186,7 +1186,7 @@ class CMakeInterpreter: detect_cycle(tgt) tgt_var = tgt.name # type: str - def resolve_source(x: Any) -> Any: + def resolve_source(x: T.Any) -> T.Any: if isinstance(x, ConverterTarget): if x.name not in processed: process_target(x) @@ -1236,7 +1236,7 @@ class CMakeInterpreter: self.internal_name_map = name_map return root_cb - def target_info(self, target: str) -> Optional[Dict[str, str]]: + def target_info(self, target: str) -> T.Optional[T.Dict[str, str]]: # Try resolving the target name # start by checking if there is a 100% match (excluding the name prefix) prx_tgt = generated_target_name_prefix + target @@ -1249,7 +1249,7 @@ class CMakeInterpreter: return self.generated_targets[target] return None - def target_list(self) -> List[str]: + def target_list(self) -> T.List[str]: prx_str = generated_target_name_prefix prx_len = len(prx_str) res = [x for x in self.generated_targets.keys()] diff --git a/mesonbuild/cmake/traceparser.py b/mesonbuild/cmake/traceparser.py index 84b2120..ceb5b02 100644 --- a/mesonbuild/cmake/traceparser.py +++ b/mesonbuild/cmake/traceparser.py @@ -19,7 +19,7 @@ from .common import CMakeException from .generator import parse_generator_expressions from .. import mlog -from typing import List, Tuple, Optional +import typing as T import re import os @@ -35,7 +35,7 @@ class CMakeTraceLine: return s.format(self.file, self.line, self.func, self.args) class CMakeTarget: - def __init__(self, name, target_type, properties=None, imported: bool = False, tline: Optional[CMakeTraceLine] = None): + def __init__(self, name, target_type, properties=None, imported: bool = False, tline: T.Optional[CMakeTraceLine] = None): if properties is None: properties = {} self.name = name @@ -55,9 +55,9 @@ class CMakeTarget: class CMakeGeneratorTarget(CMakeTarget): def __init__(self, name): super().__init__(name, 'CUSTOM', {}) - self.outputs = [] # type: List[str] - self.command = [] # type: List[List[str]] - self.working_dir = None # type: Optional[str] + self.outputs = [] # type: T.List[str] + self.command = [] # type: T.List[T.List[str]] + self.working_dir = None # type: T.Optional[str] class CMakeTraceParser: def __init__(self, permissive: bool = False): @@ -67,8 +67,8 @@ class CMakeTraceParser: # Dict of CMakeTarget self.targets = {} - # List of targes that were added with add_custom_command to generate files - self.custom_targets = [] # type: List[CMakeGeneratorTarget] + # T.List of targes that were added with add_custom_command to generate files + self.custom_targets = [] # type: T.List[CMakeGeneratorTarget] self.permissive = permissive # type: bool @@ -101,7 +101,7 @@ class CMakeTraceParser: if(fn): fn(l) - def get_first_cmake_var_of(self, var_list: List[str]) -> List[str]: + def get_first_cmake_var_of(self, var_list: T.List[str]) -> T.List[str]: # Return the first found CMake variable in list var_list for i in var_list: if i in self.vars: @@ -109,7 +109,7 @@ class CMakeTraceParser: return [] - def get_cmake_var(self, var: str) -> List[str]: + def get_cmake_var(self, var: str) -> T.List[str]: # Return the value of the CMake variable var or an empty list if var does not exist if var in self.vars: return self.vars[var] @@ -382,7 +382,7 @@ class CMakeTraceParser: # option 1 first and fall back to 2, as 1 requires less code and less # synchroniztion for cmake changes. - arglist = [] # type: List[Tuple[str, List[str]]] + arglist = [] # type: T.List[T.Tuple[str, T.List[str]]] name = args.pop(0) values = [] prop_regex = re.compile(r'^[A-Z_]+$') @@ -437,7 +437,7 @@ class CMakeTraceParser: # DOC: https://cmake.org/cmake/help/latest/command/target_link_libraries.html self._parse_common_target_options('target_link_options', 'LINK_LIBRARIES', 'INTERFACE_LINK_LIBRARIES', tline) - def _parse_common_target_options(self, func: str, private_prop: str, interface_prop: str, tline: CMakeTraceLine, ignore: Optional[List[str]] = None, paths: bool = False): + def _parse_common_target_options(self, func: str, private_prop: str, interface_prop: str, tline: CMakeTraceLine, ignore: T.Optional[T.List[str]] = None, paths: bool = False): if ignore is None: ignore = ['BEFORE'] @@ -509,14 +509,14 @@ class CMakeTraceParser: yield CMakeTraceLine(file, line, func, args) - def _guess_files(self, broken_list: List[str]) -> List[str]: + def _guess_files(self, broken_list: T.List[str]) -> T.List[str]: #Try joining file paths that contain spaces reg_start = re.compile(r'^([A-Za-z]:)?/.*/[^./]+$') reg_end = re.compile(r'^.*\.[a-zA-Z]+$') - fixed_list = [] # type: List[str] - curr_str = None # type: Optional[str] + fixed_list = [] # type: T.List[str] + curr_str = None # type: T.Optional[str] for i in broken_list: if curr_str is None: |