Skip to content

Commit

Permalink
fix: inconsistent flat
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Sep 28, 2024
1 parent f13b2bb commit c01fe0e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 24 deletions.
7 changes: 5 additions & 2 deletions ape_vyper/flattener.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from ape.logging import logger
from ape.managers import ProjectManager
from ape.utils import ManagerAccessMixin
from ape.utils import ManagerAccessMixin, get_relative_path
from ethpm_types.source import Content

from ape_vyper._utils import get_version_pragma_spec
Expand Down Expand Up @@ -65,7 +65,10 @@ def _flatten_source(
flattened_modules = ""
modules_prefixes: set[str] = set()

for import_path in sorted(imports):
# Source by source ID for greater consistency..
for import_path in sorted(
imports, key=lambda p: f"{get_relative_path(p.absolute(), pm.path)}"
):
import_info = imports[import_path]

# Vyper imported interface names come from their file names
Expand Down
44 changes: 22 additions & 22 deletions tests/functional/test_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,28 +56,6 @@ def dev_revert_source(project):
def implementThisPlease(role: bytes32) -> bool: view
# Showing importing interface from module.
interface Ballot:
def delegated(addr: address) -> bool: view
@internal
def moduleMethod2() -> bool:
return True
# This source is also imported from `zero_four.py` to test
# multiple imports across sources during flattening.
@internal
def moduleMethod() -> bool:
return True
@external
def callModule2FunctionFromAnotherSource(role: bytes32) -> bool:
return self.moduleMethod2()
# @dev Returns the address of the current owner.
# @notice If you declare a variable as `public`,
# Vyper automatically generates an `external`
Expand Down Expand Up @@ -155,6 +133,28 @@ def _transfer_ownership(new_owner: address):
log OwnershipTransferred(old_owner, new_owner)
# Showing importing interface from module.
interface Ballot:
def delegated(addr: address) -> bool: view
@internal
def moduleMethod2() -> bool:
return True
# This source is also imported from `zero_four.py` to test
# multiple imports across sources during flattening.
@internal
def moduleMethod() -> bool:
return True
@external
def callModule2FunctionFromAnotherSource(role: bytes32) -> bool:
return self.moduleMethod2()
implements: IFaceZeroFour
Expand Down

0 comments on commit c01fe0e

Please sign in to comment.