Skip to content

Commit

Permalink
update black version, apply new linting
Browse files Browse the repository at this point in the history
  • Loading branch information
iamdefinitelyahuman committed Feb 11, 2020
1 parent 7092a84 commit c0d4cb9
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 17 deletions.
2 changes: 1 addition & 1 deletion brownie/convert/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def to_int(value: Any, type_str: str = "int256") -> Wei:
def to_decimal(value: Any) -> Fixed:
"""Convert a value to a fixed point decimal"""
d: Fixed = Fixed(value)
if d < -2 ** 127 or d >= 2 ** 127:
if d < -(2 ** 127) or d >= 2 ** 127:
raise OverflowError(f"{value} is outside allowable range for decimal")
if d.quantize(Decimal("1.0000000000")) != d:
raise ValueError("Maximum of 10 decimal points allowed")
Expand Down
2 changes: 1 addition & 1 deletion brownie/convert/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def get_int_bounds(type_str: str) -> Tuple[int, int]:
raise ValueError(f"Invalid type: {type_str}")
if type_str.startswith("u"):
return 0, 2 ** size - 1
return -2 ** (size - 1), 2 ** (size - 1) - 1
return -(2 ** (size - 1)), 2 ** (size - 1) - 1


def get_type_strings(abi_params: List, substitutions: Optional[Dict] = None) -> List:
Expand Down
4 changes: 1 addition & 3 deletions brownie/network/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,9 +582,7 @@ def info(self) -> None:
if self.events:
result += "\n Events In This Transaction\n --------------------------"
for event in self.events: # type: ignore
result += (
f"\n {color('bright yellow')}{event.name}{color}" # type: ignore
)
result += f"\n {color('bright yellow')}{event.name}{color}" # type: ignore
for key, value in event.items(): # type: ignore
result += f"\n {key}: {color('bright blue')}{value}{color}"
print(result)
Expand Down
2 changes: 1 addition & 1 deletion brownie/test/stateful.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def state_machine(
brownie.rpc.snapshot()

try:
sf.run_state_machine_as_test(lambda: machine(), hp_settings(**settings or {}))
sf.run_state_machine_as_test(lambda: machine(), settings=hp_settings(**settings or {}))
finally:
if hasattr(machine, "teardown_final"):
# teardown_final is also a class method
Expand Down
2 changes: 1 addition & 1 deletion brownie/test/strategies.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def _array_strategy(
if abi_type.item_type.is_array:
kwargs.update(min_length=min_length, max_length=max_length, unique=unique)
base_strategy = strategy(abi_type.item_type.to_type_str(), **kwargs)
strat = st.lists(base_strategy, min_len, max_len, unique=unique)
strat = st.lists(base_strategy, min_size=min_len, max_size=max_len, unique=unique)
# swap 'size' for 'length' in the repr
repr_ = "length".join(strat.__repr__().rsplit("size", maxsplit=2))
strat._LazyStrategy__representation = repr_ # type: ignore
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
black==19.3b0
black==19.10b0
bumpversion==0.5.3
coverage==4.5.4
coveralls==1.9.2
Expand Down
4 changes: 2 additions & 2 deletions tests/convert/test_to_decimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ def test_incorrect_type():


def test_bounds():
to_decimal(-2 ** 127)
to_decimal(-(2 ** 127))
with pytest.raises(OverflowError):
to_decimal(-2 ** 127 - 1)
to_decimal(-(2 ** 127) - 1)
to_decimal(2 ** 127 - 1)
with pytest.raises(OverflowError):
to_decimal(2 ** 127)
Expand Down
4 changes: 2 additions & 2 deletions tests/convert/test_to_int.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ def test_overflow_uint():
def test_underflow():
for i in range(8, 264, 8):
type_ = "int" + str(i)
assert to_int((-2 ** i // 2), type_) == (-2 ** i // 2)
assert to_int((-(2 ** i) // 2), type_) == (-(2 ** i) // 2)
with pytest.raises(OverflowError):
to_int(-2 ** i // 2 - 1, type_)
to_int(-(2 ** i) // 2 - 1, type_)


def test_type():
Expand Down
4 changes: 2 additions & 2 deletions tests/test/strategies/test_decimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def test_strategy():
def test_invalid_min_max():
# min too low
with pytest.raises(ValueError):
strategy("decimal", min_value=-2 ** 128)
strategy("decimal", min_value=-(2 ** 128))
# max too high
with pytest.raises(ValueError):
strategy("decimal", max_value=2 ** 128)
Expand All @@ -30,7 +30,7 @@ def test_invalid_min_max():
def test_given(value):
assert type(value) is Decimal
assert value.quantize(Decimal("1.0000000000")) == value
assert -2 ** 127 <= value <= 2 ** 127 - 1
assert -(2 ** 127) <= value <= 2 ** 127 - 1


@given(value=strategy("decimal", min_value=1, max_value="1.5"))
Expand Down
4 changes: 2 additions & 2 deletions tests/test/strategies/test_integers.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_invalid_min_max():
with pytest.raises(ValueError):
strategy("uint", min_value=-1)
with pytest.raises(ValueError):
strategy("int", min_value=-2 ** 255 - 1)
strategy("int", min_value=-(2 ** 255) - 1)

# max too high
with pytest.raises(ValueError):
Expand Down Expand Up @@ -60,7 +60,7 @@ def test_uint8_given(value):

@given(value=strategy("int"))
def test_int_given(value):
assert -2 ** 255 <= value <= 2 ** 255 - 1
assert -(2 ** 255) <= value <= 2 ** 255 - 1


@given(value=strategy("int8"))
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ commands =

[testenv:lint]
deps =
black==19.3b0
black==19.10b0
flake8==3.7.9
isort==4.3.21
mypy==0.720
Expand Down

0 comments on commit c0d4cb9

Please sign in to comment.