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: allow using interface defs from imported modules #3725

Merged
merged 4 commits into from
Jan 12, 2024

Conversation

charles-cooper
Copy link
Member

@charles-cooper charles-cooper commented Jan 12, 2024

What I did

fix #2900

How I did it

How to verify it

see new test

Commit message

- add interface defs to ModuleT's exposed `get_type_members()`
- slight refactor of ModuleT to have a special helper instead of
dispatching to `self.interface`

Description for the changelog

Cute Animal Picture

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

Copy link
Collaborator

@pcaversaccio pcaversaccio left a comment

Choose a reason for hiding this comment

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

The unit test could be enriched with another test using a relative import from the parent directory (i.e. from ..dir.ifaces.IFoo import IFoo) just to ensure that the interface keyword doesn't break path resolution in some weird way.

@codecov-commenter
Copy link

codecov-commenter commented Jan 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (a6dc432) 84.11% compared to head (5a9139b) 83.86%.
Report is 1 commits behind head on master.

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

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3725      +/-   ##
==========================================
- Coverage   84.11%   83.86%   -0.25%     
==========================================
  Files          92       92              
  Lines       13123    13119       -4     
  Branches     2926     2925       -1     
==========================================
- Hits        11038    11002      -36     
- Misses       1663     1693      +30     
- Partials      422      424       +2     

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

@charles-cooper
Copy link
Member Author

The unit test could be enriched with another test using a relative import from the parent directory (i.e. from ..dir.ifaces.IFoo import IFoo) just to ensure that the interface keyword doesn't break path resolution in some weird way.

in vyper you can't use from to import types inside of files. like in python, you can do from my_module import some_type. but in vyper you can't import individual names from a module -- the usage here would be from ..dir import ifaces; ... ; ifaces.IFoo.

@charles-cooper charles-cooper changed the title fix: import interface types from modules fix: allow using interface defs from imported modules Jan 12, 2024
@charles-cooper charles-cooper changed the title fix: allow using interface defs from imported modules fix: allow interface defs from imported modules Jan 12, 2024
@charles-cooper charles-cooper changed the title fix: allow interface defs from imported modules fix: allow using interface defs from imported modules Jan 12, 2024
@charles-cooper charles-cooper enabled auto-merge (squash) January 12, 2024 20:27
@pcaversaccio
Copy link
Collaborator

The unit test could be enriched with another test using a relative import from the parent directory (i.e. from ..dir.ifaces.IFoo import IFoo) just to ensure that the interface keyword doesn't break path resolution in some weird way.

in vyper you can't use from to import types inside of files. like in python, you can do from my_module import some_type. but in vyper you can't import individual names from a module -- the usage here would be from ..dir import ifaces; ... ; ifaces.IFoo.

FWIW, I still use that syntax in snekmate: https://github.com/pcaversaccio/snekmate/blob/main/src%2Ftokens%2FERC20.vy#L75

@charles-cooper charles-cooper merged commit 5c2177b into vyperlang:master Jan 12, 2024
84 checks passed
@charles-cooper
Copy link
Member Author

FWIW, I still use that syntax in snekmate: https://github.com/pcaversaccio/snekmate/blob/main/src%2Ftokens%2FERC20.vy#L75

yea as discussed offline -- that syntax was probably a bug, and it does not work anymore on master (probably as of #3663 ) anyways.

@charles-cooper charles-cooper deleted the fix/import-interfaces branch January 13, 2024 13:24
@pcaversaccio
Copy link
Collaborator

FWIW, I still use that syntax in snekmate: https://github.com/pcaversaccio/snekmate/blob/main/src%2Ftokens%2FERC20.vy#L75

yea as discussed offline -- that syntax was probably a bug, and it does not work anymore on master (probably as of #3663 ) anyways.

Yup, amended in snekmate via pcaversaccio/snekmate#194.

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.

Importing interfaces not as docs describe
4 participants