Skip to content

Commit

Permalink
Merge pull request #2384 from charles-cooper/next
Browse files Browse the repository at this point in the history
Refactor module structure
  • Loading branch information
charles-cooper authored Jul 19, 2021
2 parents a433212 + e7a3b3b commit 8b71a61
Show file tree
Hide file tree
Showing 127 changed files with 482 additions and 424 deletions.
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ dev-init:
test:
pytest

# run pytest but bail out on first error. useful for dev workflow
quicktest:
python setup.py test --addopts -x

mypy:
tox -e mypy

lint:
tox -e lint

Expand Down
2 changes: 1 addition & 1 deletion tests/cli/vyper_json/test_get_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import pytest

from vyper.cli.vyper_json import get_input_dict_settings
from vyper.evm.opcodes import DEFAULT_EVM_VERSION
from vyper.exceptions import JSONError
from vyper.opcodes import DEFAULT_EVM_VERSION


def test_unknown_evm():
Expand Down
6 changes: 3 additions & 3 deletions tests/compiler/LLL/test_compile_lll.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import pytest

from vyper import compile_lll
from vyper.parser.parser import LLLnode
from vyper.parser.s_expressions import parse_s_exp
from vyper.lll import compile_lll
from vyper.lll.s_expressions import parse_s_exp
from vyper.old_codegen.parser import LLLnode

fail_list = [
[-(2 ** 255) - 3],
Expand Down
4 changes: 2 additions & 2 deletions tests/compiler/LLL/test_optimize_lll.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

from vyper import optimizer
from vyper.parser.parser import LLLnode
from vyper.lll import optimizer
from vyper.old_codegen.parser import LLLnode

optimize_list = [
(["ne", 1, 0], ["ne", 1, 0]), # noop
Expand Down
2 changes: 1 addition & 1 deletion tests/compiler/test_opcodes.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

import vyper
from vyper import opcodes
from vyper.evm import opcodes
from vyper.exceptions import CompilerPanic


Expand Down
4 changes: 2 additions & 2 deletions tests/compiler/test_sha3_32.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from vyper import compile_lll, optimizer
from vyper.parser.parser_utils import LLLnode
from vyper.lll import compile_lll, optimizer
from vyper.old_codegen.parser_utils import LLLnode


def test_sha3_32():
Expand Down
5 changes: 3 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
from web3 import Web3
from web3.providers.eth_tester import EthereumTesterProvider

from vyper import compile_lll, compiler, optimizer
from vyper.parser.parser_utils import LLLnode
from vyper import compiler
from vyper.lll import compile_lll, optimizer
from vyper.old_codegen.parser_utils import LLLnode

from .base_conftest import (
VyperContract,
Expand Down
6 changes: 3 additions & 3 deletions tests/fixtures/memorymock.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

from vyper.parser.context import Context
from vyper.types import BaseType
from vyper.old_codegen.context import Context
from vyper.old_codegen.types import BaseType


class ContextMock(Context):
Expand Down Expand Up @@ -45,5 +45,5 @@ def pytest_collection_modifyitems(items, config):
@pytest.fixture
def memory_mocker(monkeypatch, request):
if request.param:
monkeypatch.setattr("vyper.parser.context.Context", ContextMock)
monkeypatch.setattr("vyper.old_codegen.context.Context", ContextMock)
ContextMock.set_mock_var_size(request.param)
2 changes: 1 addition & 1 deletion tests/functional/context/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

from vyper import ast as vy_ast
from vyper.context.namespace import get_namespace
from vyper.semantics.namespace import get_namespace


@pytest.fixture(scope="session")
Expand Down
6 changes: 3 additions & 3 deletions tests/functional/context/test_namespace.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import pytest

from vyper.context import environment
from vyper.context.namespace import get_namespace
from vyper.context.types import get_types
from vyper.exceptions import (
CompilerPanic,
NamespaceCollision,
UndeclaredDefinition,
)
from vyper.semantics import environment
from vyper.semantics.namespace import get_namespace
from vyper.semantics.types import get_types


def test_get_namespace():
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/context/types/test_event.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from vyper.context.types.meta.event import Event
from vyper.semantics.types.user.event import Event

EVENT_ID_TESTS = [
(
Expand Down
24 changes: 12 additions & 12 deletions tests/functional/context/types/test_pure_types.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import pytest

from vyper.context.types.value.address import AddressPrimitive
from vyper.context.types.value.array_value import (
BytesArrayPrimitive,
StringPrimitive,
)
from vyper.context.types.value.boolean import BoolPrimitive
from vyper.context.types.value.bytes_fixed import Bytes32Primitive
from vyper.context.types.value.numeric import (
DecimalPrimitive,
Int128Primitive,
Uint256Primitive,
)
from vyper.exceptions import (
InvalidLiteral,
OverflowException,
StructureException,
UnexpectedNodeType,
UnexpectedValue,
)
from vyper.semantics.types.value.address import AddressPrimitive
from vyper.semantics.types.value.array_value import (
BytesArrayPrimitive,
StringPrimitive,
)
from vyper.semantics.types.value.boolean import BoolPrimitive
from vyper.semantics.types.value.bytes_fixed import Bytes32Primitive
from vyper.semantics.types.value.numeric import (
DecimalPrimitive,
Int128Primitive,
Uint256Primitive,
)

BASE_SOURCE = """
"Add a docstring so the target test node doesn't become one."
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/context/types/test_size_in_bytes.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

from vyper.context.types.bases import DataLocation
from vyper.context.types.utils import get_type_from_annotation
from vyper.semantics.types.bases import DataLocation
from vyper.semantics.types.utils import get_type_from_annotation

BASE_TYPES = ["int128", "uint256", "bool", "address", "bytes32"]
ARRAY_VALUE_TYPES = ["String", "Bytes"]
Expand Down
6 changes: 3 additions & 3 deletions tests/functional/context/types/test_type_from_abi.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import pytest

from vyper.context.types import get_primitive_types
from vyper.context.types.indexable.sequence import ArrayDefinition
from vyper.context.types.utils import get_type_from_abi
from vyper.exceptions import UnknownType
from vyper.semantics.types import get_primitive_types
from vyper.semantics.types.indexable.sequence import ArrayDefinition
from vyper.semantics.types.utils import get_type_from_abi

BASE_TYPES = ["int128", "uint256", "bool", "address", "bytes32"]

Expand Down
10 changes: 5 additions & 5 deletions tests/functional/context/types/test_type_from_annotation.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import pytest

from vyper.context.types import get_primitive_types
from vyper.context.types.bases import DataLocation
from vyper.context.types.indexable.mapping import MappingDefinition
from vyper.context.types.indexable.sequence import ArrayDefinition
from vyper.context.types.utils import get_type_from_annotation
from vyper.exceptions import (
ArrayIndexException,
InvalidType,
StructureException,
UndeclaredDefinition,
)
from vyper.semantics.types import get_primitive_types
from vyper.semantics.types.bases import DataLocation
from vyper.semantics.types.indexable.mapping import MappingDefinition
from vyper.semantics.types.indexable.sequence import ArrayDefinition
from vyper.semantics.types.utils import get_type_from_annotation

BASE_TYPES = ["int128", "uint256", "bool", "address", "bytes32"]
ARRAY_VALUE_TYPES = ["String", "Bytes"]
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/context/validation/test_array_index.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import pytest

from vyper.ast import parse_to_ast
from vyper.context.validation import validate_semantics
from vyper.exceptions import (
ArrayIndexException,
InvalidReference,
InvalidType,
TypeMismatch,
UndeclaredDefinition,
)
from vyper.semantics.validation import validate_semantics


@pytest.mark.parametrize("value", ["address", "Bytes[10]", "decimal", "bool"])
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import pytest

from vyper.ast import parse_to_ast
from vyper.context.validation.module import ModuleNodeVisitor
from vyper.exceptions import CallViolation
from vyper.semantics.validation.module import ModuleNodeVisitor


def test_cyclic_function_call(namespace):
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/context/validation/test_for_loop.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import pytest

from vyper.ast import parse_to_ast
from vyper.context.validation import validate_semantics
from vyper.exceptions import ImmutableViolation
from vyper.semantics.validation import validate_semantics


def test_modify_iterator_function_outside_loop(namespace):
Expand Down
10 changes: 5 additions & 5 deletions tests/functional/context/validation/test_potential_types.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import pytest

from vyper.context.types.indexable.sequence import ArrayDefinition
from vyper.context.types.value.address import AddressDefinition
from vyper.context.types.value.boolean import BoolDefinition
from vyper.context.types.value.numeric import Int128Definition
from vyper.context.validation.utils import get_possible_types_from_node
from vyper.exceptions import (
ArrayIndexException,
InvalidOperation,
Expand All @@ -14,6 +9,11 @@
UndeclaredDefinition,
UnknownAttribute,
)
from vyper.semantics.types.indexable.sequence import ArrayDefinition
from vyper.semantics.types.value.address import AddressDefinition
from vyper.semantics.types.value.boolean import BoolDefinition
from vyper.semantics.types.value.numeric import Int128Definition
from vyper.semantics.validation.utils import get_possible_types_from_node

INTEGER_LITERALS = [(42, 31337), (-1, 1), (69, 2 ** 128)]
DECIMAL_LITERALS = [("4.2", "-1.337")]
Expand Down
2 changes: 1 addition & 1 deletion tests/functions/folding/test_abs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from hypothesis import strategies as st

from vyper import ast as vy_ast
from vyper import functions as vy_fn
from vyper import builtin_functions as vy_fn
from vyper.exceptions import OverflowException


Expand Down
2 changes: 1 addition & 1 deletion tests/functions/folding/test_addmod_mulmod.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from hypothesis import strategies as st

from vyper import ast as vy_ast
from vyper import functions as vy_fn
from vyper import builtin_functions as vy_fn

st_uint256 = st.integers(min_value=0, max_value=2 ** 256 - 1)

Expand Down
2 changes: 1 addition & 1 deletion tests/functions/folding/test_bitwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from hypothesis import strategies as st

from vyper import ast as vy_ast
from vyper import functions as vy_fn
from vyper import builtin_functions as vy_fn

st_uint256 = st.integers(min_value=0, max_value=2 ** 256 - 1)

Expand Down
2 changes: 1 addition & 1 deletion tests/functions/folding/test_floor_ceil.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from hypothesis import strategies as st

from vyper import ast as vy_ast
from vyper import functions as vy_fn
from vyper import builtin_functions as vy_fn

st_decimals = st.decimals(
min_value=-(2 ** 32), max_value=2 ** 32, allow_nan=False, allow_infinity=False, places=10,
Expand Down
2 changes: 1 addition & 1 deletion tests/functions/folding/test_fold_as_wei_value.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from hypothesis import strategies as st

from vyper import ast as vy_ast
from vyper import functions as vy_fn
from vyper import builtin_functions as vy_fn

denoms = [x for k in vy_fn.AsWeiValue.wei_denoms.keys() for x in k]

Expand Down
2 changes: 1 addition & 1 deletion tests/functions/folding/test_keccak_sha.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from hypothesis import strategies as st

from vyper import ast as vy_ast
from vyper import functions as vy_fn
from vyper import builtin_functions as vy_fn

alphabet = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!"#$%&()*+,-./:;<=>?@[]^_`{|}~' # NOQA: E501

Expand Down
2 changes: 1 addition & 1 deletion tests/functions/folding/test_len.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

from vyper import ast as vy_ast
from vyper import functions as vy_fn
from vyper import builtin_functions as vy_fn


@pytest.mark.parametrize("length", [0, 1, 32, 33, 64, 65, 1024])
Expand Down
2 changes: 1 addition & 1 deletion tests/functions/folding/test_min_max.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from hypothesis import strategies as st

from vyper import ast as vy_ast
from vyper import functions as vy_fn
from vyper import builtin_functions as vy_fn

st_decimals = st.decimals(
min_value=-(2 ** 32), max_value=2 ** 32, allow_nan=False, allow_infinity=False, places=10,
Expand Down
2 changes: 1 addition & 1 deletion tests/functions/folding/test_powmod.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from hypothesis import strategies as st

from vyper import ast as vy_ast
from vyper import functions as vy_fn
from vyper import builtin_functions as vy_fn

st_uint256 = st.integers(min_value=0, max_value=256)

Expand Down
5 changes: 4 additions & 1 deletion tests/fuzzing/test_exponents.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
from hypothesis import example, given, settings
from hypothesis import strategies as st

from vyper.parser.expr import calculate_largest_base, calculate_largest_power
from vyper.old_codegen.expr import (
calculate_largest_base,
calculate_largest_power,
)


@pytest.mark.fuzzing
Expand Down
2 changes: 1 addition & 1 deletion tests/parser/features/test_clampers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
from eth_utils import keccak

from vyper.opcodes import EVM_VERSIONS
from vyper.evm.opcodes import EVM_VERSIONS


def _make_tx(w3, address, signature, values):
Expand Down
2 changes: 1 addition & 1 deletion tests/parser/functions/test_bitwise.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest

from vyper.compiler import compile_code
from vyper.opcodes import EVM_VERSIONS
from vyper.evm.opcodes import EVM_VERSIONS

code = """
@external
Expand Down
4 changes: 2 additions & 2 deletions tests/parser/functions/test_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import pytest

from vyper.ast.signatures.interface import extract_sigs
from vyper.builtin_interfaces import ERC20, ERC721
from vyper.cli.utils import extract_file_interface_imports
from vyper.compiler import compile_code, compile_codes
from vyper.exceptions import InterfaceViolation, StructureException
from vyper.interfaces import ERC20, ERC721
from vyper.signatures.interface import extract_sigs


def test_basic_extract_interface():
Expand Down
Loading

0 comments on commit 8b71a61

Please sign in to comment.