From c4cc83943b468828e763ea307431836ca7484c82 Mon Sep 17 00:00:00 2001 From: Charles Cooper Date: Fri, 4 Oct 2024 22:38:02 -0400 Subject: [PATCH] feat[ux]: improve hint for events kwarg upgrade follow-on commit to ebe3c0ccfc2a6935d. the hint in ebe3c0ccfc2a6935d is not specific to the user's source code, and it's a bit laborious for the user to match the call-site to the event def. this commit auto-generates the new call expression for the user to use. --- vyper/semantics/types/user.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/vyper/semantics/types/user.py b/vyper/semantics/types/user.py index 73fa4878c7..948c0145e1 100644 --- a/vyper/semantics/types/user.py +++ b/vyper/semantics/types/user.py @@ -295,10 +295,15 @@ def _ctor_call_return(self, node: vy_ast.Call) -> None: return validate_kwargs(node, self.arguments, self.typeclass) # warn about positional argument depreciation - msg = "Instantiating events with positional arguments is " - msg += "deprecated as of v0.4.1 and will be disallowed " - msg += "in a future release. Use kwargs instead eg. " - msg += "Foo(a=1, b=2)" + rec0 = ", ".join( + f"{argname}={val.node_source_code}" + for argname, val in zip(self.arguments.keys(), node.args) + ) + recommendation = f"{node.func.node_source_code}({rec0})" + msg = "Instantiating events with positional arguments is" + msg += " deprecated as of v0.4.1 and will be disallowed" + msg += " in a future release. Use kwargs instead e.g.:" + msg += f"\n {recommendation}" vyper_warn(msg, node)