Skip to content

Commit

Permalink
feat[ux]: improve hint for events kwarg upgrade
Browse files Browse the repository at this point in the history
follow-on commit to ebe3c0c. the hint in ebe3c0c 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.
  • Loading branch information
charles-cooper committed Oct 5, 2024
1 parent c02d2d8 commit c4cc839
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions vyper/semantics/types/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit c4cc839

Please sign in to comment.