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]: include imported structs in interface output #4362

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

Conversation

sandbubbles
Copy link
Collaborator

What I did

Included structs from imported modules in the -f interface output. Fix the #4298 issue.

How I did it

Added a function that recursively walks imported modules and collects structs. It contains visited set to track which imports were already handled.

How to verify it

Added test cases and previous test cases work.

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

@sandbubbles
Copy link
Collaborator Author

sandbubbles commented Nov 16, 2024

Should the name of a struct include module name, id?

@charles-cooper charles-cooper marked this pull request as ready for review November 23, 2024 20:35
@@ -159,6 +161,19 @@ def build_interface_output(compiler_data: CompilerData) -> str:
return out


def _get_structs(m: ModuleT, visited: set[ModuleT] = None) -> [StructT]:
Copy link
Member

Choose a reason for hiding this comment

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

we can use ModuleT.reachable_imports here instead of implementing the recursion

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I kept the recursion because for building the import paths for the output - a.b.c. struct.

if m in visited:
return []
visited.add(m)
structs = list(m.interface.structs.values())
Copy link
Member

Choose a reason for hiding this comment

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

hmm. what if two modules have a struct with the same name?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah, that's what i was getting at with #4362 (comment), I'll prepend it.

vyper/compiler/output.py Fixed Show fixed Hide fixed
Copy link

codecov bot commented Dec 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.06%. Comparing base (a29b49d) to head (26abe45).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4362      +/-   ##
==========================================
- Coverage   91.86%   91.06%   -0.80%     
==========================================
  Files         119      119              
  Lines       16640    16653      +13     
  Branches     2801     2804       +3     
==========================================
- Hits        15286    15165     -121     
- Misses        929     1040     +111     
- Partials      425      448      +23     

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

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.

2 participants