Skip to content

Commit

Permalink
Merge branch 'v0.12.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
meevee98 committed Apr 26, 2023
2 parents 163f990 + 6d90527 commit 5f2652c
Show file tree
Hide file tree
Showing 16 changed files with 49 additions and 12 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]


## [0.12.3] - 2023-04-26
### Fixed
- Fixed incorrect import error raised when importing modules in the same directory of the importer file


## [0.12.2] - 2023-03-30
### Added
- Included extra data to manifest and new types to better interface with manifest
Expand Down Expand Up @@ -432,6 +437,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0


[Unreleased]: https://github.com/CityOfZion/neo3-boa/compare/master...development
[0.12.3]: https://github.com/CityOfZion/neo3-boa/releases/tag/v0.12.3
[0.12.2]: https://github.com/CityOfZion/neo3-boa/releases/tag/v0.12.2
[0.12.1]: https://github.com/CityOfZion/neo3-boa/releases/tag/v0.12.1
[0.12.0]: https://github.com/CityOfZion/neo3-boa/releases/tag/v0.12.0
Expand Down
2 changes: 1 addition & 1 deletion boa3/internal/analyser/analyser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import ast
from typing import Dict, List, Optional

from boa3.builtin.compile_time import NeoMetadata
from boa3.internal import constants
from boa3.internal.analyser.astanalyser import IAstAnalyser
from boa3.internal.analyser.astoptimizer import AstOptimizer
from boa3.internal.analyser.constructanalyser import ConstructAnalyser
from boa3.internal.analyser.moduleanalyser import ModuleAnalyser
from boa3.internal.analyser.supportedstandard.standardanalyser import StandardAnalyser
from boa3.internal.analyser.typeanalyser import TypeAnalyser
from boa3.builtin.compile_time import NeoMetadata
from boa3.internal.compiler.compiledmetadata import CompiledMetadata
from boa3.internal.exception.CompilerError import CompilerError
from boa3.internal.exception.CompilerWarning import CompilerWarning
Expand Down
3 changes: 3 additions & 0 deletions boa3/internal/analyser/importanalyser.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,16 @@ def __init__(self, import_target: str, root_folder: str,
self._find_package(import_target, importer_file)
return

importer_file_dir = os.path.dirname(importer_file)
sys.path.append(self.root_folder)
sys.path.append(importer_file_dir)
try:
import_spec = importlib.util.find_spec(import_target)
module_origin: str = import_spec.origin
except BaseException:
return
finally:
sys.path.remove(importer_file_dir)
sys.path.remove(self.root_folder)

self._importer_file = importer_file
Expand Down
2 changes: 1 addition & 1 deletion boa3/internal/analyser/moduleanalyser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import os
from typing import Any, Dict, Iterable, List, Optional, Tuple, Union

from boa3.builtin.compile_time import NeoMetadata
from boa3.internal import constants
from boa3.internal.analyser.astanalyser import IAstAnalyser
from boa3.internal.analyser.importanalyser import ImportAnalyser
from boa3.internal.analyser.model.ManifestSymbol import ManifestSymbol
from boa3.internal.analyser.model.functionarguments import FunctionArguments
from boa3.internal.analyser.model.optimizer import UndefinedType
from boa3.internal.analyser.model.symbolscope import SymbolScope
from boa3.builtin.compile_time import NeoMetadata
from boa3.internal.exception import CompilerError, CompilerWarning
from boa3.internal.model.builtin.builtin import Builtin
from boa3.internal.model.builtin.decorator import ContractDecorator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
from inspect import isclass
from typing import Dict, List, Optional

from boa3.internal.compiler.codegenerator.variablegenerationdata import VariableGenerationData
from boa3.internal import constants
from boa3.internal.analyser.astanalyser import IAstAnalyser
from boa3.internal.compiler.codegenerator.codegenerator import CodeGenerator
from boa3.internal.compiler.codegenerator.generatordata import GeneratorData
from boa3.internal.compiler.codegenerator.variablegenerationdata import VariableGenerationData
from boa3.internal.compiler.codegenerator.vmcodemapping import VMCodeMapping
from boa3.internal.constants import SYS_VERSION_INFO
from boa3.internal.model.builtin.builtin import Builtin
Expand Down
2 changes: 1 addition & 1 deletion boa3/internal/compiler/compiledmetadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from typing import Union

from boa3.internal import constants
from boa3.builtin.compile_time import NeoMetadata
from boa3.internal import constants
from boa3.internal.neo3.core.types import UInt160


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from typing import Any, List

from boa3.builtin.compile_time import public
from boa3_test.test_sc.import_test.FromImportTyping import EmptyList as RootImportedFunction
from package_with_import.Module import EmptyList as FileDirImportedFunction


@public
def call_imported_from_root() -> list:
a: List[Any] = RootImportedFunction()
return a


@public
def call_imported_from_file_dir() -> list:
a: List[Any] = FileDirImportedFunction()
return a
2 changes: 1 addition & 1 deletion boa3_test/tests/compiler_tests/test_function.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from boa3.internal import constants
from boa3.boa3 import Boa3
from boa3.internal import constants
from boa3.internal.exception import CompilerError
from boa3.internal.neo.vm.opcode.Opcode import Opcode
from boa3.internal.neo.vm.type.Integer import Integer
Expand Down
11 changes: 11 additions & 0 deletions boa3_test/tests/compiler_tests/test_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,17 @@ def test_from_import_user_module_with_alias(self):
result = self.run_smart_contract(engine, path, 'Main')
self.assertEqual([], result)

def test_from_import_user_module_from_root_and_file_directories(self):
path = self.get_contract_path('FromImportUserModuleFromRootAndFileDir.py')
self.compile_and_save(path, root_folder=self.get_dir_path(self.test_root_dir))

engine = TestEngine()
result = self.run_smart_contract(engine, path, 'call_imported_from_root')
self.assertEqual([], result)

result = self.run_smart_contract(engine, path, 'call_imported_from_file_dir')
self.assertEqual([], result)

def test_import_non_existent_package(self):
path = self.get_contract_path('ImportNonExistentPackage.py')
self.assertCompilerLogs(CompilerError.UnresolvedReference, path)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json

from boa3.internal import constants
from boa3.boa3 import Boa3
from boa3.internal import constants
from boa3.internal.exception import CompilerError, CompilerWarning
from boa3.internal.model.builtin.interop.interop import Interop
from boa3.internal.neo.vm.opcode.Opcode import Opcode
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from boa3.internal import constants
from boa3.boa3 import Boa3
from boa3.internal import constants
from boa3.internal.exception import CompilerError, CompilerWarning
from boa3.internal.model.builtin.interop.interop import Interop
from boa3.internal.neo import to_script_hash
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json

from boa3.internal import constants
from boa3.boa3 import Boa3
from boa3.internal import constants
from boa3.internal.exception import CompilerError
from boa3.internal.neo.vm.type.String import String
from boa3_test.tests.boa_test import BoaTest
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import hashlib

from boa3.internal import constants
from boa3.boa3 import Boa3
from boa3.internal import constants
from boa3.internal.exception import CompilerError
from boa3.internal.model.type.type import Type
from boa3.internal.neo.vm.opcode.Opcode import Opcode
Expand Down
2 changes: 1 addition & 1 deletion boa3_test/tests/compiler_tests/test_native/test_ledger.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from boa3.internal import constants
from boa3.boa3 import Boa3
from boa3.internal import constants
from boa3.internal.exception import CompilerError
from boa3.internal.model.builtin.interop.interop import Interop
from boa3.internal.neo.vm.opcode.Opcode import Opcode
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from boa3.internal import constants
from boa3.boa3 import Boa3
from boa3.internal import constants
from boa3.internal.exception import CompilerError
from boa3.internal.model.builtin.interop.interop import Interop
from boa3.internal.neo.vm.opcode.Opcode import Opcode
Expand Down
2 changes: 1 addition & 1 deletion boa3_test/tests/compiler_tests/test_while.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from boa3.internal import constants
from boa3.boa3 import Boa3
from boa3.internal import constants
from boa3.internal.exception import CompilerError
from boa3.internal.neo.vm.opcode.Opcode import Opcode
from boa3.internal.neo.vm.type.Integer import Integer
Expand Down

0 comments on commit 5f2652c

Please sign in to comment.