compilers: Fix annotations for run and cached_compile

Which absolutely should accept `str | File`, but the annotations claim
that only strings are accepted.
pull/9132/head
Dylan Baker 3 years ago
parent 32d3b5c9e2
commit e9639be167
  1. 10
      mesonbuild/compilers/compilers.py
  2. 2
      mesonbuild/compilers/mixins/clike.py
  3. 6
      mesonbuild/coredata.py

@ -667,7 +667,7 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta):
dependencies: T.Optional[T.List['Dependency']] = None) -> T.Tuple[bool, bool]:
raise EnvironmentException('Language %s does not support header symbol checks.' % self.get_display_language())
def run(self, code: str, env: 'Environment', *,
def run(self, code: 'mesonlib.FileOrString', env: 'Environment', *,
extra_args: T.Optional[T.List[str]] = None,
dependencies: T.Optional[T.List['Dependency']] = None) -> RunResult:
raise EnvironmentException('Language %s does not support run checks.' % self.get_display_language())
@ -808,7 +808,7 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta):
yield result
@contextlib.contextmanager
def cached_compile(self, code: str, cdata: coredata.CoreData, *,
def cached_compile(self, code: 'mesonlib.FileOrString', cdata: coredata.CoreData, *,
extra_args: T.Union[None, T.List[str], CompilerArgs] = None,
mode: str = 'link',
temp_dir: T.Optional[str] = None) -> T.Iterator[T.Optional[CompileResult]]:
@ -1200,7 +1200,7 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta):
return args
@contextlib.contextmanager
def _build_wrapper(self, code: str, env: 'Environment',
def _build_wrapper(self, code: 'mesonlib.FileOrString', env: 'Environment',
extra_args: T.Union[None, CompilerArgs, T.List[str]] = None,
dependencies: T.Optional[T.List['Dependency']] = None,
mode: str = 'compile', want_output: bool = False,
@ -1219,7 +1219,7 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta):
with self.cached_compile(code, env.coredata, extra_args=args, mode=mode, temp_dir=env.scratch_dir) as r:
yield r
def compiles(self, code: str, env: 'Environment', *,
def compiles(self, code: 'mesonlib.FileOrString', env: 'Environment', *,
extra_args: T.Union[None, T.List[str], CompilerArgs] = None,
dependencies: T.Optional[T.List['Dependency']] = None,
mode: str = 'compile',
@ -1228,7 +1228,7 @@ class Compiler(HoldableObject, metaclass=abc.ABCMeta):
return p.returncode == 0, p.cached
def links(self, code: str, env: 'Environment', *,
def links(self, code: 'mesonlib.FileOrString', env: 'Environment', *,
extra_args: T.Union[None, T.List[str], CompilerArgs] = None,
dependencies: T.Optional[T.List['Dependency']] = None,
mode: str = 'compile',

@ -462,7 +462,7 @@ class CLikeCompiler(Compiler):
args = cargs + extra_args + largs
return args
def run(self, code: str, env: 'Environment', *,
def run(self, code: 'mesonlib.FileOrString', env: 'Environment', *,
extra_args: T.Optional[T.List[str]] = None,
dependencies: T.Optional[T.List['Dependency']] = None) -> compilers.RunResult:
need_exe_wrapper = env.need_exe_wrapper(self.for_machine)

@ -34,14 +34,14 @@ import typing as T
if T.TYPE_CHECKING:
from . import dependencies
from .compilers.compilers import Compiler, CompileResult # noqa: F401
from .compilers.compilers import Compiler
from .environment import Environment
from .mesonlib import OptionOverrideProxy
from .mesonlib import OptionOverrideProxy, FileOrString
from .cmake.traceparser import CMakeCacheEntry
OptionDictType = T.Union[T.Dict[str, 'UserOption[T.Any]'], OptionOverrideProxy]
KeyedOptionDictType = T.Union[T.Dict['OptionKey', 'UserOption[T.Any]'], OptionOverrideProxy]
CompilerCheckCacheKey = T.Tuple[T.Tuple[str, ...], str, str, T.Tuple[str, ...], str]
CompilerCheckCacheKey = T.Tuple[T.Tuple[str, ...], str, 'FileOrString', T.Tuple[str, ...], str]
version = '0.59.99'
backendlist = ['ninja', 'vs', 'vs2010', 'vs2012', 'vs2013', 'vs2015', 'vs2017', 'vs2019', 'xcode']

Loading…
Cancel
Save