Skip to content

fix[ux]: fix error message for "staticall" typo#4438

Merged
charles-cooper merged 7 commits intovyperlang:masterfrom
charles-cooper:fix/staticall-error2
Jan 9, 2025
Merged

fix[ux]: fix error message for "staticall" typo#4438
charles-cooper merged 7 commits intovyperlang:masterfrom
charles-cooper:fix/staticall-error2

Conversation

@charles-cooper
Copy link
Copy Markdown
Member

@charles-cooper charles-cooper commented Jan 3, 2025

What I did

alternative approach to #4363

How I did it

How to verify it

Commit message

the "staticall" typo is very common, and was raising a hard-to-read
error message from the python parser like "invalid syntax. Perhaps you
forgot a comma?"

this commit adds logic to `ast/parse.py`, so we can add a hint to the
exception after we have successfully gone through the python parser and
have the ability to add source info and a hint.

Description for the changelog

Cute Animal Picture

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

@charles-cooper
Copy link
Copy Markdown
Member Author

the drawback of this approach is that if the bad keyword is separated from the next token by more than one line, the error message does not include the hint. wdyt @cyberthirst @pcaversaccio @fubuloubu ?

@external
def foo():
    staticall \
        foo()

Screenshot from 2025-01-03 10-16-18

@external
def foo():
    staticall \
        \
        foo()

Screenshot from 2025-01-03 10-16-33

@pcaversaccio
Copy link
Copy Markdown
Collaborator

I mean PEP-8 doesn't explicitly prohibit multiple consecutive blank lines within a block of code, but the principle of "Readability counts." (and minimal clutter) implies that more than one consecutive blank line is completely unnecessary. Thus, having such insane line breaks:

@external
def foo():
    staticall \
        \
        foo()    

is not really a pattern that we should support and I'm ok with the drawback of this approach.

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 4, 2025

Codecov Report

Attention: Patch coverage is 10.00000% with 9 lines in your changes missing coverage. Please review.

Project coverage is 49.79%. Comparing base (4507d2a) to head (4a2769e).

Files with missing lines Patch % Lines
vyper/ast/parse.py 0.00% 8 Missing ⚠️
vyper/exceptions.py 50.00% 1 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (4507d2a) and HEAD (4a2769e). Click for more details.

HEAD has 174 uploads less than BASE
Flag BASE (4507d2a) HEAD (4a2769e)
180 6
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #4438       +/-   ##
===========================================
- Coverage   91.94%   49.79%   -42.15%     
===========================================
  Files         119      119               
  Lines       16677    16684        +7     
  Branches     2807     2809        +2     
===========================================
- Hits        15333     8308     -7025     
- Misses        924     7737     +6813     
- Partials      420      639      +219     

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

@charles-cooper charles-cooper marked this pull request as ready for review January 5, 2025 16:47
@charles-cooper charles-cooper changed the title Fix/staticall error2 fix[ux]: fix error message for common typo Jan 5, 2025
@charles-cooper charles-cooper changed the title fix[ux]: fix error message for common typo fix[ux]: fix error message for "staticall" typo Jan 5, 2025
@charles-cooper charles-cooper merged commit 66272e6 into vyperlang:master Jan 9, 2025
@charles-cooper charles-cooper deleted the fix/staticall-error2 branch January 9, 2025 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants