Skip to content

feat[ux]: improve hint for events kwarg upgrade#4275

Merged
charles-cooper merged 24 commits intovyperlang:masterfrom
charles-cooper:feat/improve-event-kwargs-recommendation
Feb 18, 2025
Merged

feat[ux]: improve hint for events kwarg upgrade#4275
charles-cooper merged 24 commits intovyperlang:masterfrom
charles-cooper:feat/improve-event-kwargs-recommendation

Conversation

@charles-cooper
Copy link
Copy Markdown
Member

@charles-cooper charles-cooper commented Oct 5, 2024

What I did

How I did it

How to verify it

try compiling the following file:

from ethereum.ercs import IERC20

def foo():
    log IERC20.Transfer(msg.sender, msg.sender, 123)

Commit message

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. additionally, it migrates
the example contracts in the `examples/` directory so that they stop
emitting warnings.

Description for the changelog

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

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.
@charles-cooper charles-cooper added this to the v0.4.1 milestone Oct 5, 2024
@codecov
Copy link
Copy Markdown

codecov bot commented Oct 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.12%. Comparing base (c75a2da) to head (de3bdff).
Report is 95 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4275   +/-   ##
=======================================
  Coverage   92.12%   92.12%           
=======================================
  Files         119      119           
  Lines       16967    16969    +2     
  Branches     2872     2872           
=======================================
+ Hits        15631    15633    +2     
  Misses        918      918           
  Partials      418      418           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@charles-cooper
Copy link
Copy Markdown
Member Author

there's something interesting going on with examples like

log Transfer(msg.sender, msg.sender, 1)  # 1 is only one character long

i guess mark_tokens() marks the wrong start+end position for the ast node.

@charles-cooper charles-cooper added the release - must release blocker label Oct 11, 2024
@charles-cooper charles-cooper marked this pull request as ready for review October 17, 2024 17:06
@charles-cooper charles-cooper marked this pull request as draft October 17, 2024 17:06
@charles-cooper
Copy link
Copy Markdown
Member Author

i'd say the mark_tokens issue is out of scope -- it should be addressed in #4364

@charles-cooper charles-cooper marked this pull request as ready for review November 21, 2024 07:51
@cyberthirst
Copy link
Copy Markdown
Collaborator

let's please add some tests

@cyberthirst
Copy link
Copy Markdown
Collaborator

it seems that not all nodes have the source assigned?

event Foo:
       a: uint256

@external
def foo(a: uint256):
    log Foo(a)
UserWarning: Instantiating events with positional arguments is deprecated as of v0.4.1 and will be disallowed in a future release. Use kwargs instead e.g.:

Foo(a=)


  contract "tests/custom/test.vy:6", function "foo", line 6:8 
       5 def foo(a: uint256):
  ---> 6     log Foo(a)
  ---------------^
       7

  vyper_warn(msg, node)

notice Foo(a=)

@cyberthirst cyberthirst removed their request for review November 29, 2024 21:01
@charles-cooper
Copy link
Copy Markdown
Member Author

it seems that not all nodes have the source assigned?

event Foo:
       a: uint256

@external
def foo(a: uint256):
    log Foo(a)
UserWarning: Instantiating events with positional arguments is deprecated as of v0.4.1 and will be disallowed in a future release. Use kwargs instead e.g.:

Foo(a=)


  contract "tests/custom/test.vy:6", function "foo", line 6:8 
       5 def foo(a: uint256):
  ---> 6     log Foo(a)
  ---------------^
       7

  vyper_warn(msg, node)

notice Foo(a=)

Yea that's what I mentioned here
#4275 (comment)

@cyberthirst
Copy link
Copy Markdown
Collaborator

Yea that's what I mentioned here #4275 (comment)

oh, that wasn't clear to me from the comment, but i didn't run the attached code

in that case can we add 1 xfail test please?

cyberthirst and others added 2 commits December 6, 2024 11:26
@charles-cooper
Copy link
Copy Markdown
Member Author

note: waiting on #4364. we should update the logs in the examples directory in this PR as well.

recommendation = f"log {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.:"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need e.g. when we have a concrete recommendation?

@charles-cooper charles-cooper enabled auto-merge (squash) February 18, 2025 15:20
@charles-cooper charles-cooper merged commit bb45f50 into vyperlang:master Feb 18, 2025
159 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release - must release blocker

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants