ast: rename module constant to match PEP8 style

pull/10453/head
Dylan Baker 3 years ago committed by Eli Schwartz
parent 3260c0ebdb
commit 2a0082b13a
  1. 4
      mesonbuild/ast/__init__.py
  2. 9
      mesonbuild/ast/introspection.py
  3. 4
      mesonbuild/mintro.py
  4. 4
      mesonbuild/rewriter.py

@ -24,11 +24,11 @@ __all__ = [
'AstVisitor',
'AstPrinter',
'IntrospectionInterpreter',
'build_target_functions',
'BUILD_TARGET_FUNCTIONS',
]
from .interpreter import AstInterpreter
from .introspection import IntrospectionInterpreter, build_target_functions
from .introspection import IntrospectionInterpreter, BUILD_TARGET_FUNCTIONS
from .visitor import AstVisitor
from .postprocess import AstConditionLevel, AstIDGenerator, AstIndentationGenerator
from .printer import AstPrinter, AstJSONPrinter

@ -35,7 +35,12 @@ if T.TYPE_CHECKING:
from ..interpreterbase import TYPE_nvar
from .visitor import AstVisitor
build_target_functions = ['executable', 'jar', 'library', 'shared_library', 'shared_module', 'static_library', 'both_libraries']
# TODO: it would be nice to not have to duplicate this
BUILD_TARGET_FUNCTIONS = [
'executable', 'jar', 'library', 'shared_library', 'shared_module',
'static_library', 'both_libraries'
]
class IntrospectionHelper(argparse.Namespace):
# mimic an argparse namespace
@ -245,7 +250,7 @@ class IntrospectionInterpreter(AstInterpreter):
continue
arg_nodes = arg_node.arguments.copy()
# Pop the first element if the function is a build target function
if isinstance(curr, FunctionNode) and curr.func_name in build_target_functions:
if isinstance(curr, FunctionNode) and curr.func_name in BUILD_TARGET_FUNCTIONS:
arg_nodes.pop(0)
elemetary_nodes = [x for x in arg_nodes if isinstance(x, (str, StringNode))]
inqueue += [x for x in arg_nodes if isinstance(x, (FunctionNode, ArrayNode, IdNode, ArithmeticNode))]

@ -23,7 +23,7 @@ import collections
import json
from . import build, coredata as cdata
from . import mesonlib
from .ast import IntrospectionInterpreter, build_target_functions, AstConditionLevel, AstIDGenerator, AstIndentationGenerator, AstJSONPrinter
from .ast import IntrospectionInterpreter, BUILD_TARGET_FUNCTIONS, AstConditionLevel, AstIDGenerator, AstIndentationGenerator, AstJSONPrinter
from . import mlog
from .backend import backends
from .mparser import BaseNode, FunctionNode, ArrayNode, ArgumentNode, StringNode
@ -166,7 +166,7 @@ def list_targets_from_source(intr: IntrospectionInterpreter) -> T.List[T.Dict[st
args = [] # type: T.List[BaseNode]
if isinstance(n, FunctionNode):
args = list(n.args.arguments)
if n.func_name in build_target_functions:
if n.func_name in BUILD_TARGET_FUNCTIONS:
args.pop(0)
elif isinstance(n, ArrayNode):
args = n.args.arguments

@ -24,7 +24,7 @@
# - reindent?
from __future__ import annotations
from .ast import IntrospectionInterpreter, build_target_functions, AstConditionLevel, AstIDGenerator, AstIndentationGenerator, AstPrinter
from .ast import IntrospectionInterpreter, BUILD_TARGET_FUNCTIONS, AstConditionLevel, AstIDGenerator, AstIndentationGenerator, AstPrinter
from mesonbuild.mesonlib import MesonException
from . import mlog, environment
from functools import wraps
@ -628,7 +628,7 @@ class Rewriter:
args = []
if isinstance(n, FunctionNode):
args = list(n.args.arguments)
if n.func_name in build_target_functions:
if n.func_name in BUILD_TARGET_FUNCTIONS:
args.pop(0)
elif isinstance(n, ArrayNode):
args = n.args.arguments

Loading…
Cancel
Save