Skip to content

Commit

Permalink
fix: import error with nested packages folder, extends import check
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidMinarsch committed Aug 19, 2022
1 parent 0a69dbc commit 6f768c3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion aea/components/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def _extract_imported_packages_as_ids(
# import packages.{author}.{type_plural}.{name}
#
import_statements = re.findall(
rf"^(from|import) ({PACKAGES}\.[A-Za-z0-9_]+\.{cls.package_type_plural_regex}\.[A-Za-z0-9_]+)",
rf"^( from|from| import|import) ({PACKAGES}\.[A-Za-z0-9_]+\.{cls.package_type_plural_regex}\.[A-Za-z0-9_]+)",
module_content,
flags=re.MULTILINE,
)
Expand Down
14 changes: 10 additions & 4 deletions tests/data/packages/default_author/contracts/stub_1/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,15 @@
from aea.contracts.base import Contract
from aea.crypto.base import LedgerApi

from packages.default_author.contracts.stub_0.contract import ( # type: ignore # noqa: F401
MyScaffoldContract as MC,
)

try:
from tests.data.packages.default_author.contracts.stub_0.contract import ( # type: ignore # noqa: F401
MyScaffoldContract as MC,
)
except ModuleNotFoundError:
from packages.default_author.contracts.stub_0.contract import ( # type: ignore # noqa: F401
MyScaffoldContract as MC,
)


class MyScaffoldContract(Contract):
Expand All @@ -41,7 +47,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
"""Init contract."""
super().__init__(*args, **kwargs)
print("Contract stub_1 initialized.")
raise Exception()
raise Exception("Raised on purpose!")

@classmethod
def get_raw_transaction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license: Apache-2.0
aea_version: '>=1.0.0, <2.0.0'
fingerprint:
__init__.py: bafybeiajra74lxu4xlg4qcvqlhj7yndibsorbu24zgqgv7p3s2arjdhsdu
contract.py: bafybeig4v5lt7ln6r3dyyf6v3hak5gnvzfzdh4bdkuter3b4526lwxcnzm
contract.py: bafybeihxbf5fw25u6kqis446cbkptg7pj2n5o7xfmrbcnunttywyktknj4
fingerprint_ignore_patterns: []
class_name: MyScaffoldContract
contract_interface_paths: {}
Expand Down
2 changes: 1 addition & 1 deletion tests/data/packages/hashes.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
default_author/contracts/stub_0,bafybeidicpfgwqbr54v5pca77wu6ifnf23idf5htpdrudhbwxzaavm3wyy
default_author/contracts/stub_1,bafybeiamxbawlj3x5nq2qdolzfp65valyrhh55tszf733l3u5nxuvgkwhy
default_author/contracts/stub_1,bafybeibpmdrfhgz33ubww57rmmzn56g67e5xe462xiulk2p2ttezgujn5a
fetchai/protocols/t_protocol,bafybeih4ciqba3x4b2yijkxurkqwiafixxy7jgghfkvtzmsxxuawq4rmvm
fetchai/protocols/t_protocol_no_ct,bafybeibf4fp2loabpr334vko47o64dkbumso2gmpeylvk35yzkdbup4wti
open_aea/connections/scaffold,bafybeifucsl5zfe4if4zfaddud77lzwgg7emv3mr3x3us57py7vbhktb24
Expand Down

0 comments on commit 6f768c3

Please sign in to comment.