aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2021-08-06 14:50:46 -0700
committerDaniel Mensinger <daniel@mensinger-ka.de>2021-08-20 18:57:19 +0200
commita5c4cf3a3f74262994dffcc1238843882b13cf8f (patch)
treec26ee583ed10abf410d6d9800be61e9e40db29d9 /mesonbuild
parent3a45c5a7ce5e947d7b664211049f7d4023b96ed1 (diff)
downloadmeson-a5c4cf3a3f74262994dffcc1238843882b13cf8f.zip
meson-a5c4cf3a3f74262994dffcc1238843882b13cf8f.tar.gz
meson-a5c4cf3a3f74262994dffcc1238843882b13cf8f.tar.bz2
mesonlib: Fix type annotations
get_compiler_for_source and classify_unity_sources are both wrong, in that they expect to be given a seqence of strings, but they really should take a `Sequence[str | File]`. Additionally, they're using `CompilerType`, which we don't need anymore, and should stop using, most methods for the Compiler are actually defined in the base compiler class.
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/mesonlib/universal.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/mesonbuild/mesonlib/universal.py b/mesonbuild/mesonlib/universal.py
index 65d21ee..54d6c37 100644
--- a/mesonbuild/mesonlib/universal.py
+++ b/mesonbuild/mesonlib/universal.py
@@ -35,8 +35,7 @@ if T.TYPE_CHECKING:
from .._typing import ImmutableListProtocol
from ..build import ConfigurationData
from ..coredata import KeyedOptionDictType, UserOption
- from ..compilers.compilers import CompilerType
- from ..interpreterbase import ObjectHolder
+ from ..compilers.compilers import Compiler
FileOrString = T.Union['File', str]
@@ -453,7 +452,7 @@ class File(HoldableObject):
return os.path.join(self.subdir, self.fname)
-def get_compiler_for_source(compilers: T.Iterable['CompilerType'], src: str) -> 'CompilerType':
+def get_compiler_for_source(compilers: T.Iterable['Compiler'], src: 'FileOrString') -> 'Compiler':
"""Given a set of compilers and a source, find the compiler for that source type."""
for comp in compilers:
if comp.can_compile(src):
@@ -461,8 +460,8 @@ def get_compiler_for_source(compilers: T.Iterable['CompilerType'], src: str) ->
raise MesonException(f'No specified compiler can handle file {src!s}')
-def classify_unity_sources(compilers: T.Iterable['CompilerType'], sources: T.Iterable[str]) -> T.Dict['CompilerType', T.List[str]]:
- compsrclist = {} # type: T.Dict[CompilerType, T.List[str]]
+def classify_unity_sources(compilers: T.Iterable['Compiler'], sources: T.Sequence['FileOrString']) -> T.Dict['Compiler', T.List['FileOrString']]:
+ compsrclist: T.Dict['Compiler', T.List['FileOrString']] = {}
for src in sources:
comp = get_compiler_for_source(compilers, src)
if comp not in compsrclist: