From d936b866506d4a3b7368a318ded5da217dbb6833 Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Mon, 14 Oct 2024 21:28:44 -0400 Subject: [PATCH] small cleanup --- vyper/semantics/types/module.py | 34 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/vyper/semantics/types/module.py b/vyper/semantics/types/module.py index 866d302a78..dabeaf21b6 100644 --- a/vyper/semantics/types/module.py +++ b/vyper/semantics/types/module.py @@ -165,10 +165,10 @@ def _from_lists( struct_list: Optional[list[tuple[str, StructT]]] = None, flag_list: Optional[list[tuple[str, FlagT]]] = None, ) -> "InterfaceT": - functions = {} - events = {} - structs = {} - flags = {} + functions: dict[str, ContractFunctionT] = {} + events: dict[str, EventT] = {} + structs: dict[str, StructT] = {} + flags: dict[str, FlagT] = {} seen_items: dict = {} @@ -179,24 +179,18 @@ def _mark_seen(name, item): raise NamespaceCollision(msg, item.decl_node, prev_decl=prev_decl) seen_items[name] = item - for name, function in function_list: - _mark_seen(name, function) - functions[name] = function + def _process(dst_dict, items): + if items is None: + return - if event_list: - for name, event in event_list: - _mark_seen(name, event) - events[name] = event + for name, item in items: + _mark_seen(name, item) + dst_dict[name] = item - if struct_list: - for name, struct in struct_list: - _mark_seen(name, struct) - structs[name] = struct - - if flag_list: - for name, flag in flag_list: - _mark_seen(name, flag) - flags[name] = flag + _process(functions, function_list) + _process(events, event_list) + _process(structs, struct_list) + _process(flags, flag_list) return cls(interface_name, decl_node, functions, events, structs, flags)