Skip to content

Commit

Permalink
ast/interpreter: fix some low hanging type issues
Browse files Browse the repository at this point in the history
  • Loading branch information
dcbaker committed Dec 14, 2023
1 parent aa67d0f commit 8c5dfad
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions mesonbuild/ast/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
if T.TYPE_CHECKING:
from .visitor import AstVisitor
from ..interpreter import Interpreter
from ..interpreterbase import TYPE_nkwargs, TYPE_var
from ..interpreterbase import SubProject, TYPE_nkwargs, TYPE_var
from ..mparser import (
AndNode,
ComparisonNode,
Expand Down Expand Up @@ -84,8 +84,9 @@ class MockRunTarget(MesonInterpreterObject):
_T = T.TypeVar('_T')
_V = T.TypeVar('_V')


class AstInterpreter(InterpreterBase):
def __init__(self, source_root: str, subdir: str, subproject: str, visitors: T.Optional[T.List[AstVisitor]] = None):
def __init__(self, source_root: str, subdir: str, subproject: SubProject, visitors: T.Optional[T.List[AstVisitor]] = None):
super().__init__(source_root, subdir, subproject)
self.visitors = visitors if visitors is not None else []
self.processed_buildfiles: T.Set[str] = set()
Expand Down
8 changes: 4 additions & 4 deletions mesonbuild/ast/introspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from .. import coredata as cdata
from ..build import Executable, Jar, SharedLibrary, SharedModule, StaticLibrary
from ..compilers import detect_compiler_for
from ..interpreterbase import InvalidArguments
from ..interpreterbase import InvalidArguments, SubProject
from ..mesonlib import MachineChoice, OptionKey
from ..mparser import BaseNode, ArithmeticNode, ArrayNode, ElementaryNode, IdNode, FunctionNode, BaseStringNode
from .interpreter import AstInterpreter
Expand Down Expand Up @@ -51,7 +51,7 @@ def __init__(self,
backend: str,
visitors: T.Optional[T.List[AstVisitor]] = None,
cross_file: T.Optional[str] = None,
subproject: str = '',
subproject: SubProject = SubProject(''),
subproject_dir: str = 'subprojects',
env: T.Optional[environment.Environment] = None):
visitors = visitors if visitors is not None else []
Expand Down Expand Up @@ -126,7 +126,7 @@ def func_project(self, node: BaseNode, args: T.List[TYPE_var], kwargs: T.Dict[st
if os.path.isdir(subprojects_dir):
for i in os.listdir(subprojects_dir):
if os.path.isdir(os.path.join(subprojects_dir, i)):
self.do_subproject(i)
self.do_subproject(SubProject(i))

self.coredata.init_backend_options(self.backend)
options = {k: v for k, v in self.environment.options.items() if k.is_backend()}
Expand All @@ -135,7 +135,7 @@ def func_project(self, node: BaseNode, args: T.List[TYPE_var], kwargs: T.Dict[st
self._add_languages(proj_langs, True, MachineChoice.HOST)
self._add_languages(proj_langs, True, MachineChoice.BUILD)

def do_subproject(self, dirname: str) -> None:
def do_subproject(self, dirname: SubProject) -> None:
subproject_dir_abs = os.path.join(self.environment.get_source_dir(), self.subproject_dir)
subpr = os.path.join(subproject_dir_abs, dirname)
try:
Expand Down

0 comments on commit 8c5dfad

Please sign in to comment.