diff --git a/vyper/ast/natspec.py b/vyper/ast/natspec.py index 3b6ec7951a..41a6703b6e 100644 --- a/vyper/ast/natspec.py +++ b/vyper/ast/natspec.py @@ -11,13 +11,13 @@ USERDOCS_FIELDS = ("notice",) -def parse_natspec(vyper_module_annotated: vy_ast.Module) -> Tuple[dict, dict]: +def parse_natspec(annotated_vyper_module: vy_ast.Module) -> Tuple[dict, dict]: """ Parses NatSpec documentation from a contract. Arguments --------- - vyper_module_annotated : Module + annotated_vyper_module: Module Module-level vyper ast node. interface_codes: Dict, optional Dict containing relevant data for any import statements related to @@ -33,15 +33,15 @@ def parse_natspec(vyper_module_annotated: vy_ast.Module) -> Tuple[dict, dict]: from vyper.semantics.types.function import FunctionVisibility userdoc, devdoc = {}, {} - source: str = vyper_module_annotated.full_source_code + source: str = annotated_vyper_module.full_source_code - docstring = vyper_module_annotated.get("doc_string.value") + docstring = annotated_vyper_module.get("doc_string.value") if docstring: devdoc.update(_parse_docstring(source, docstring, ("param", "return"))) if "notice" in devdoc: userdoc["notice"] = devdoc.pop("notice") - for node in [i for i in vyper_module_annotated.body if i.get("doc_string.value")]: + for node in [i for i in annotated_vyper_module.body if i.get("doc_string.value")]: docstring = node.doc_string.value func_type = node._metadata["func_type"] if func_type.visibility != FunctionVisibility.EXTERNAL: diff --git a/vyper/cli/vyper_compile.py b/vyper/cli/vyper_compile.py index 3fbff31174..d6ba9e180a 100755 --- a/vyper/cli/vyper_compile.py +++ b/vyper/cli/vyper_compile.py @@ -33,8 +33,8 @@ devdoc - Natspec developer documentation combined_json - All of the above format options combined as single JSON output layout - Storage layout of a Vyper contract -ast - Annotated AST in JSON format -unannotated_ast - Unannotated AST in JSON format +ast - AST (not yet annotated) in JSON format +annotated_ast - Annotated AST in JSON format interface - Vyper interface of a contract external_interface - External interface of a contract, used for outside contract calls opcodes - List of opcodes as a string @@ -260,7 +260,7 @@ def compile_files( "abi_python": "abi", "json": "abi", "ast": "ast_dict", - "unannotated_ast": "unannotated_ast_dict", + "annotated_ast": "annotated_ast_dict", "ir_json": "ir_dict", } final_formats = [translate_map.get(i, i) for i in output_formats] diff --git a/vyper/compiler/__init__.py b/vyper/compiler/__init__.py index bc7930af82..0f7d7a8014 100644 --- a/vyper/compiler/__init__.py +++ b/vyper/compiler/__init__.py @@ -13,8 +13,9 @@ OUTPUT_FORMATS = { # requires vyper_module - "unannotated_ast_dict": output.build_ast_dict, - "ast_dict": output.build_annotated_ast_dict, + "ast_dict": output.build_ast_dict, + # requires annotated_vyper_module + "annotated_ast_dict": output.build_annotated_ast_dict, "layout": output.build_layout_output, # requires global_ctx "devdoc": output.build_devdoc, diff --git a/vyper/compiler/output.py b/vyper/compiler/output.py index 181cf02081..8ccf6abee1 100644 --- a/vyper/compiler/output.py +++ b/vyper/compiler/output.py @@ -26,23 +26,23 @@ def build_ast_dict(compiler_data: CompilerData) -> dict: def build_annotated_ast_dict(compiler_data: CompilerData) -> dict: annotated_ast_dict = { "contract_name": str(compiler_data.contract_path), - "ast": ast_to_dict(compiler_data.vyper_module_annotated), + "ast": ast_to_dict(compiler_data.annotated_vyper_module), } return annotated_ast_dict def build_devdoc(compiler_data: CompilerData) -> dict: - userdoc, devdoc = parse_natspec(compiler_data.vyper_module_annotated) + userdoc, devdoc = parse_natspec(compiler_data.annotated_vyper_module) return devdoc def build_userdoc(compiler_data: CompilerData) -> dict: - userdoc, devdoc = parse_natspec(compiler_data.vyper_module_annotated) + userdoc, devdoc = parse_natspec(compiler_data.annotated_vyper_module) return userdoc def build_external_interface_output(compiler_data: CompilerData) -> str: - interface = compiler_data.vyper_module_annotated._metadata["type"].interface + interface = compiler_data.annotated_vyper_module._metadata["type"].interface stem = PurePath(compiler_data.contract_path).stem # capitalize words separated by '_' # ex: test_interface.vy -> TestInterface @@ -61,7 +61,7 @@ def build_external_interface_output(compiler_data: CompilerData) -> str: def build_interface_output(compiler_data: CompilerData) -> str: - interface = compiler_data.vyper_module_annotated._metadata["type"].interface + interface = compiler_data.annotated_vyper_module._metadata["type"].interface out = "" if interface.events: @@ -166,7 +166,7 @@ def _to_dict(func_t): def build_method_identifiers_output(compiler_data: CompilerData) -> dict: - module_t = compiler_data.vyper_module_annotated._metadata["type"] + module_t = compiler_data.annotated_vyper_module._metadata["type"] functions = module_t.function_defs return { @@ -175,7 +175,7 @@ def build_method_identifiers_output(compiler_data: CompilerData) -> dict: def build_abi_output(compiler_data: CompilerData) -> list: - module_t = compiler_data.vyper_module_annotated._metadata["type"] + module_t = compiler_data.annotated_vyper_module._metadata["type"] _ = compiler_data.ir_runtime # ensure _ir_info is generated abi = module_t.interface.to_toplevel_abi_dict() diff --git a/vyper/compiler/phases.py b/vyper/compiler/phases.py index 45cab440b8..6f0224e61b 100644 --- a/vyper/compiler/phases.py +++ b/vyper/compiler/phases.py @@ -53,8 +53,8 @@ class CompilerData: ---------- vyper_module : vy_ast.Module Top-level Vyper AST node - vyper_module_annotated : vy_ast.Module - Annotated Vyper AST + annotated_vyper_module: vy_ast.Module + Annotated/analysed Vyper AST global_ctx : ModuleT Sorted, contextualized representation of the Vyper AST ir_nodes : IRnode @@ -158,7 +158,7 @@ def _annotated_module(self): ) @property - def vyper_module_annotated(self) -> vy_ast.Module: + def annotated_vyper_module(self) -> vy_ast.Module: module, storage_layout = self._annotated_module return module @@ -169,7 +169,7 @@ def storage_layout(self) -> StorageLayout: @property def global_ctx(self) -> ModuleT: - return self.vyper_module_annotated._metadata["type"] + return self.annotated_vyper_module._metadata["type"] @cached_property def _ir_output(self): @@ -198,7 +198,7 @@ def function_signatures(self) -> dict[str, ContractFunctionT]: # ensure codegen is run: _ = self._ir_output - fs = self.vyper_module_annotated.get_children(vy_ast.FunctionDef) + fs = self.annotated_vyper_module.get_children(vy_ast.FunctionDef) return {f.name: f._metadata["func_type"] for f in fs} @cached_property