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

fix[ux]: raise VersionException with source info #3920

Merged
merged 13 commits into from
Apr 9, 2024

Conversation

tserg
Copy link
Collaborator

@tserg tserg commented Apr 8, 2024

What I did

Fix #3910.

How I did it

How to verify it

See test

Commit message

this commit adds source code information to the exception thrown in
`validate_version_pragma()` to improve user experience when dealing with
imports with invalid (or incompatible) version pragmas.

Description for the changelog

Cute Animal Picture

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

@codecov-commenter
Copy link

codecov-commenter commented Apr 8, 2024

Codecov Report

Attention: Patch coverage is 40.00000% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 51.22%. Comparing base (8fcbde2) to head (e829677).

Files Patch % Lines
vyper/ast/pre_parser.py 25.00% 3 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff             @@
##           master    #3920       +/-   ##
===========================================
- Coverage   90.03%   51.22%   -38.82%     
===========================================
  Files          95       95               
  Lines       14411    14411               
  Branches     3193     3193               
===========================================
- Hits        12975     7382     -5593     
- Misses       1011     6436     +5425     
- Partials      425      593      +168     

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

@@ -176,7 +177,7 @@ def pre_parse(code: str) -> tuple[Settings, ModificationOffsets, dict, str]:
if settings.compiler_version is not None:
raise StructureException("compiler version specified twice!", start)
compiler_version = contents.removeprefix("@version ").strip()
validate_version_pragma(compiler_version, start)
validate_version_pragma(compiler_version, line, start)
Copy link
Member

Choose a reason for hiding this comment

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

i don't think this works if the version pragma is not on the first line?


def test_version_conflict_with_imports(make_input_bundle, mock_version):
lib_version = "~=0.3.10"
contract_version = "0.4.0"
Copy link
Member

Choose a reason for hiding this comment

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

i'm not sure this is necessary (it's also brittle, the test will start failing for the wrong reason after 0.4.0 release)

tserg and others added 3 commits April 9, 2024 22:14
Co-authored-by: Charles Cooper <cooper.charles.m@gmail.com>
Copy link
Member

@charles-cooper charles-cooper left a comment

Choose a reason for hiding this comment

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

lgtm. thanks!

@charles-cooper
Copy link
Member

failing fuzz is unrelated (see #3918)

@charles-cooper charles-cooper enabled auto-merge (squash) April 9, 2024 15:53
@charles-cooper charles-cooper changed the title chore[ux]: raise VersionException with source info fix[ux]: raise VersionException with source info Apr 9, 2024
@charles-cooper charles-cooper enabled auto-merge (squash) April 9, 2024 15:53
@charles-cooper charles-cooper merged commit 3ea2ae1 into vyperlang:master Apr 9, 2024
150 checks passed
electriclilies pushed a commit to electriclilies/vyper that referenced this pull request Apr 27, 2024
this commit adds source code information to the exception thrown in
`validate_version_pragma()` to improve user experience when dealing with
imports with invalid (or incompatible) version pragmas.
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.

VersionException error is not helpful with imports
3 participants