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

chore: update linter, drop support for python 3.8 and 3.9 #3325

Merged
merged 15 commits into from
Mar 30, 2023
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Python
uses: actions/setup-python@v2
with:
python-version: "3.8"
python-version: "3.10"

- name: Generate Binary
run: >-
Expand All @@ -60,7 +60,7 @@ jobs:
- name: Python
uses: actions/setup-python@v2
with:
python-version: "3.8"
python-version: "3.10"

- name: Generate Binary
run: >-
Expand Down
22 changes: 11 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
steps:
- uses: actions/checkout@v1

- name: Set up Python 3.8
- name: Set up Python 3.10
uses: actions/setup-python@v1
with:
python-version: 3.8
python-version: "3.10"

- name: Install Dependencies
run: pip install .[lint]
Expand All @@ -42,10 +42,10 @@ jobs:
steps:
- uses: actions/checkout@v1

- name: Set up Python 3.8
- name: Set up Python 3.10
uses: actions/setup-python@v1
with:
python-version: 3.8
python-version: "3.10"

- name: Install Tox
run: pip install tox
Expand All @@ -59,10 +59,10 @@ jobs:
steps:
- uses: actions/checkout@v1

- name: Set up Python 3.8
- name: Set up Python 3.10
uses: actions/setup-python@v1
with:
python-version: 3.8
python-version: "3.10"

- name: Install Tox
run: pip install tox
Expand All @@ -75,7 +75,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [["3.8", "38"], ["3.9", "39"], ["3.10", "310"]]
python-version: [["3.10", "310"]]
# run in default (optimized) and --no-optimize mode
flag: ["core", "no-opt"]

Expand Down Expand Up @@ -126,10 +126,10 @@ jobs:
steps:
- uses: actions/checkout@v1

- name: Set up Python 3.8
- name: Set up Python 3.10
uses: actions/setup-python@v1
with:
python-version: 3.8
python-version: "3.10"

- name: Install Tox
run: pip install tox
Expand Down Expand Up @@ -167,10 +167,10 @@ jobs:
steps:
- uses: actions/checkout@v1

- name: Set up Python 3.8
- name: Set up Python 3.10
uses: actions/setup-python@v1
with:
python-version: 3.8
python-version: "3.10"

- name: Install Tox
run: pip install tox
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ repos:
- "types-setuptools"

default_language_version:
python: python3.8
python: python3.10
11 changes: 9 additions & 2 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,22 @@

version: 2

# Set the version of Python and other tools you might need
build:
# TODO: update to `latest` once supported
# https://github.com/readthedocs/readthedocs.org/issues/8861
os: ubuntu-22.04
tools:
python: "3.10"

# Build from the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py

formats: all


# Explicitly set the version of Python and its requirements
# Optionally declare the Python requirements required to build your docs
python:
version: 3.8
install:
- requirements: requirements-docs.txt
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.8-slim
FROM python:3.10-slim

# Specify label-schema specific arguments and labels.
ARG BUILD_DATE
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

[tool.black]
line-length = 100
target-version = ['py37', 'py38', 'py39']
target-version = ['py310']
include = '\.pyi?$'
exclude = '''
/(
Expand Down
9 changes: 3 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@
"hypothesis[lark]>=5.37.1,<6.0",
],
"lint": [
"black==21.9b0",
"click<8.1.0", # temporary pin - black21.9b0 fails with 8.1.0
"black==23.3.0",
"flake8==3.9.2",
"flake8-bugbear==20.1.4",
"flake8-use-fstring==1.1",
"isort==5.9.3",
"mypy==0.910",
],
"docs": ["recommonmark", "sphinx>=3.0,<4.0", "sphinx_rtd_theme>=0.5,<0.6"],
"docs": ["recommonmark", "sphinx>=6.0,<7.0", "sphinx_rtd_theme>=1.2,<1.3"],
"dev": ["ipython", "pre-commit", "pyinstaller", "twine"],
}

Expand Down Expand Up @@ -89,7 +88,7 @@ def _global_version(version):
keywords="ethereum evm smart contract language",
include_package_data=True,
packages=find_packages(exclude=("tests", "docs")),
python_requires=">=3.8,<4",
python_requires=">=3.10,<4",
py_modules=["vyper"],
install_requires=[
"asttokens>=2.0.5,<3",
Expand All @@ -112,8 +111,6 @@ def _global_version(version):
classifiers=[
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
],
package_data={"vyper.ast": ["grammar.lark"]},
Expand Down
4 changes: 2 additions & 2 deletions tests/ast/nodes/test_evaluate_binop_decimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from vyper.exceptions import OverflowException, TypeMismatch, ZeroDivisionException

st_decimals = st.decimals(
min_value=-(2 ** 32), max_value=2 ** 32, allow_nan=False, allow_infinity=False, places=10
min_value=-(2**32), max_value=2**32, allow_nan=False, allow_infinity=False, places=10
)


Expand Down Expand Up @@ -75,7 +75,7 @@ def foo({input_value}) -> decimal:
try:
vy_ast.folding.replace_literal_ops(vyper_ast)
expected = vyper_ast.body[0].value.value
is_valid = -(2 ** 127) <= expected < 2 ** 127
is_valid = -(2**127) <= expected < 2**127
except (OverflowException, ZeroDivisionException):
# for overflow or division/modulus by 0, expect the contract call to revert
is_valid = False
Expand Down
5 changes: 2 additions & 3 deletions tests/ast/nodes/test_evaluate_binop_int.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from vyper import ast as vy_ast
from vyper.exceptions import ZeroDivisionException

st_int32 = st.integers(min_value=-(2 ** 32), max_value=2 ** 32)
st_int32 = st.integers(min_value=-(2**32), max_value=2**32)


@pytest.mark.fuzzing
Expand Down Expand Up @@ -38,7 +38,7 @@ def foo(a: int128, b: int128) -> int128:
assert_tx_failed(lambda: contract.foo(left, right))


st_uint64 = st.integers(min_value=0, max_value=2 ** 64)
st_uint64 = st.integers(min_value=0, max_value=2**64)


@pytest.mark.fuzzing
Expand Down Expand Up @@ -95,7 +95,6 @@ def foo(a: uint256, b: uint256) -> uint256:
ops=st.lists(st.sampled_from("+-*/%"), min_size=11, max_size=11),
)
def test_binop_nested(get_contract, assert_tx_failed, values, ops):

variables = "abcdefghij"
input_value = ",".join(f"{i}: int128" for i in variables[: len(values)])
return_value = " ".join(f"{a} {b}" for a, b in zip(variables[: len(values)], ops))
Expand Down
2 changes: 0 additions & 2 deletions tests/ast/nodes/test_evaluate_boolop.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
@given(values=st.lists(st.booleans(), min_size=2, max_size=10))
@pytest.mark.parametrize("comparator", ["and", "or"])
def test_boolop_simple(get_contract, values, comparator):

input_value = ",".join(f"{i}: bool" for i in variables[: len(values)])
return_value = f" {comparator} ".join(variables[: len(values)])

Expand All @@ -39,7 +38,6 @@ def foo({input_value}) -> bool:
comparators=st.lists(st.sampled_from(["and", "or"]), min_size=11, max_size=11),
)
def test_boolop_nested(get_contract, values, comparators):

input_value = ",".join(f"{i}: bool" for i in variables[: len(values)])
return_value = " ".join(f"{a} {b}" for a, b in zip(variables[: len(values)], comparators))
return_value = return_value.rsplit(maxsplit=1)[0]
Expand Down
4 changes: 2 additions & 2 deletions tests/base_conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def _none_addr(datatype, data):
def tester():
# set absurdly high gas limit so that london basefee never adjusts
# (note: 2**63 - 1 is max that evm allows)
custom_genesis = PyEVMBackend._generate_genesis_params(overrides={"gas_limit": 10 ** 10})
custom_genesis = PyEVMBackend._generate_genesis_params(overrides={"gas_limit": 10**10})
custom_genesis["base_fee_per_gas"] = 0
backend = PyEVMBackend(genesis_parameters=custom_genesis)
return EthereumTester(backend=backend)
Expand Down Expand Up @@ -114,7 +114,7 @@ def _get_contract(w3, source_code, no_optimize, *args, **kwargs):
parse_vyper_source(source_code) # Test grammar.
abi = out["abi"]
bytecode = out["bytecode"]
value = kwargs.pop("value_in_eth", 0) * 10 ** 18 # Handle deploying with an eth value.
value = kwargs.pop("value_in_eth", 0) * 10**18 # Handle deploying with an eth value.
c = w3.eth.contract(abi=abi, bytecode=bytecode)
deploy_transaction = c.constructor(*args)
tx_info = {"from": w3.eth.accounts[0], "value": value, "gasPrice": 0}
Expand Down
6 changes: 3 additions & 3 deletions tests/builtins/folding/test_abs.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

@pytest.mark.fuzzing
@settings(max_examples=50, deadline=1000)
@given(a=st.integers(min_value=-(2 ** 255) + 1, max_value=2 ** 255 - 1))
@given(a=st.integers(min_value=-(2**255) + 1, max_value=2**255 - 1))
@example(a=0)
def test_abs(get_contract, a):
source = """
Expand All @@ -28,7 +28,7 @@ def foo(a: int256) -> int256:

@pytest.mark.fuzzing
@settings(max_examples=50, deadline=1000)
@given(a=st.integers(min_value=2 ** 255, max_value=2 ** 256 - 1))
@given(a=st.integers(min_value=2**255, max_value=2**256 - 1))
def test_abs_upper_bound_folding(get_contract, a):
source = f"""
@external
Expand All @@ -47,7 +47,7 @@ def foo(a: int256) -> int256:
"""
contract = get_contract(source)

assert_tx_failed(lambda: contract.foo(-(2 ** 255)))
assert_tx_failed(lambda: contract.foo(-(2**255)))


def test_abs_lower_bound_folded(get_contract, assert_tx_failed):
Expand Down
2 changes: 1 addition & 1 deletion tests/builtins/folding/test_addmod_mulmod.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from vyper import ast as vy_ast
from vyper.builtins import functions as vy_fn

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


@pytest.mark.fuzzing
Expand Down
5 changes: 1 addition & 4 deletions tests/builtins/folding/test_bitwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@
from vyper import ast as vy_ast
from vyper.builtins import functions as vy_fn

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


@pytest.mark.fuzzing
@settings(max_examples=50, deadline=1000)
@given(a=st_uint256, b=st_uint256)
@pytest.mark.parametrize("op", ["&", "|", "^"])
def test_bitwise_and_or(get_contract, a, b, op):

source = f"""
@external
def foo(a: uint256, b: uint256) -> uint256:
Expand All @@ -32,7 +31,6 @@ def foo(a: uint256, b: uint256) -> uint256:
@settings(max_examples=50, deadline=1000)
@given(value=st_uint256)
def test_bitwise_not(get_contract, value):

source = """
@external
def foo(a: uint256) -> uint256:
Expand All @@ -51,7 +49,6 @@ def foo(a: uint256) -> uint256:
@settings(max_examples=50, deadline=1000)
@given(value=st_uint256, steps=st.integers(min_value=-256, max_value=256))
def test_shift(get_contract, value, steps):

source = """
@external
def foo(a: uint256, b: int128) -> uint256:
Expand Down
2 changes: 1 addition & 1 deletion tests/builtins/folding/test_floor_ceil.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from vyper.builtins import functions as vy_fn

st_decimals = st.decimals(
min_value=-(2 ** 32), max_value=2 ** 32, allow_nan=False, allow_infinity=False, places=10
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/builtins/folding/test_fold_as_wei_value.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def foo(a: decimal) -> uint256:

@pytest.mark.fuzzing
@settings(max_examples=10, deadline=1000)
@given(value=st.integers(min_value=0, max_value=2 ** 128))
@given(value=st.integers(min_value=0, max_value=2**128))
@pytest.mark.parametrize("denom", denoms)
def test_integer(get_contract, value, denom):
source = f"""
Expand Down
1 change: 0 additions & 1 deletion tests/builtins/folding/test_keccak_sha.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
@settings(max_examples=50, deadline=1000)
@pytest.mark.parametrize("fn_name", ["keccak256", "sha256"])
def test_string(get_contract, value, fn_name):

source = f"""
@external
def foo(a: String[100]) -> bytes32:
Expand Down
4 changes: 2 additions & 2 deletions tests/builtins/folding/test_min_max.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
allow_infinity=False,
places=10,
)
st_int128 = st.integers(min_value=-(2 ** 127), max_value=2 ** 127 - 1)
st_uint256 = st.integers(min_value=0, max_value=2 ** 256 - 1)
st_int128 = st.integers(min_value=-(2**127), max_value=2**127 - 1)
st_uint256 = st.integers(min_value=0, max_value=2**256 - 1)


@pytest.mark.fuzzing
Expand Down
2 changes: 1 addition & 1 deletion tests/builtins/folding/test_powmod.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from vyper import ast as vy_ast
from vyper.builtins import functions as vy_fn

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


@pytest.mark.fuzzing
Expand Down
4 changes: 2 additions & 2 deletions tests/compiler/ir/test_compile_ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from vyper.ir.s_expressions import parse_s_exp

fail_list = [
[-(2 ** 255) - 3],
[2 ** 256 + 3],
[-(2**255) - 3],
[2**256 + 3],
["set", "_poz"],
[["set", "var_1", 0, 0]],
["with", "var_1", 0, ["set", 1, 1]],
Expand Down
Loading