diff --git a/mesonbuild/arglist.py b/mesonbuild/arglist.py index 54d7157e2ccf..14d7fe6f61bf 100644 --- a/mesonbuild/arglist.py +++ b/mesonbuild/arglist.py @@ -11,10 +11,6 @@ import re import typing as T -if T.TYPE_CHECKING: - from .linkers.linkers import StaticLinker - from .compilers import Compiler - # execinfo is a compiler lib on BSD UNIXY_COMPILER_INTERNAL_LIBS = ['m', 'c', 'pthread', 'dl', 'rt', 'execinfo'] @@ -94,9 +90,12 @@ class CompilerArgs(T.MutableSequence[str]): # TODO: these should probably move too always_dedup_args = tuple('-l' + lib for lib in UNIXY_COMPILER_INTERNAL_LIBS) - def __init__(self, compiler: T.Union['Compiler', 'StaticLinker'], - iterable: T.Optional[T.Iterable[str]] = None): - self.compiler = compiler + def __init__(self, compiler: T.Any, iterable: T.Optional[T.Iterable[str]] = None): + # Must be here to avoid cyclic import. + from .linkers.linkers import StaticLinker + from .compilers import Compiler + assert(isinstance(compiler, (StaticLinker, Compiler))) + self.compiler: T.Union['Compiler', 'StaticLinker'] = compiler self._container: T.List[str] = list(iterable) if iterable is not None else [] self.pre: T.Deque[str] = collections.deque() self.post: T.Deque[str] = collections.deque()