Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 23 commits into
base: master
Choose a base branch
from

Conversation

charles-cooper
Copy link
Member

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.

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

Commit message for the final, squashed PR. (Optional, but reviewers will appreciate it! Please see our commit message style guide for what we would ideally like to see in a commit message.)

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
Copy link

codecov bot commented Oct 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.09%. Comparing base (4d693b7) to head (b42801e).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4275   +/-   ##
=======================================
  Coverage   92.09%   92.09%           
=======================================
  Files         119      119           
  Lines       16931    16933    +2     
  Branches     2865     2865           
=======================================
+ Hits        15593    15595    +2     
  Misses        919      919           
  Partials      419      419           

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

@charles-cooper
Copy link
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
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
Collaborator

let's please add some tests

@cyberthirst
Copy link
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
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
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
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
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?

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