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

flake8 upgrade to 3.8.3 #1759

Merged
merged 1 commit into from
Oct 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
import pytest
import time
import warnings
Expand Down
24 changes: 12 additions & 12 deletions ens/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class ENS:
reverse_domain = staticmethod(address_to_reverse_domain)

def __init__(
self, provider: 'BaseProvider'=cast('BaseProvider', default), addr: ChecksumAddress=None
self, provider: 'BaseProvider' = cast('BaseProvider', default), addr: ChecksumAddress = None
) -> None:
"""
:param provider: a single provider used to connect to Ethereum
Expand All @@ -91,7 +91,7 @@ def __init__(
self._resolverContract = self.web3.eth.contract(abi=abis.RESOLVER)

@classmethod
def fromWeb3(cls, web3: 'Web3', addr: ChecksumAddress=None) -> 'ENS':
def fromWeb3(cls, web3: 'Web3', addr: ChecksumAddress = None) -> 'ENS':
"""
Generate an ENS instance with web3

Expand Down Expand Up @@ -125,8 +125,8 @@ def name(self, address: ChecksumAddress) -> Optional[str]:
def setup_address(
self,
name: str,
address: Union[Address, ChecksumAddress, HexAddress]=cast(ChecksumAddress, default),
transact: "TxParams"={}
address: Union[Address, ChecksumAddress, HexAddress] = cast(ChecksumAddress, default),
transact: "TxParams" = {}
) -> HexBytes:
"""
Set up the name to point to the supplied address.
Expand Down Expand Up @@ -165,7 +165,7 @@ def setup_address(

@dict_copy
def setup_name(
self, name: str, address: ChecksumAddress=None, transact: "TxParams"={}
self, name: str, address: ChecksumAddress = None, transact: "TxParams" = {}
) -> HexBytes:
"""
Set up the address for reverse lookup, aka "caller ID".
Expand Down Expand Up @@ -208,7 +208,7 @@ def setup_name(
self.setup_address(name, address, transact=transact)
return self._setup_reverse(name, address, transact=transact)

def resolve(self, name: str, get: str='addr') -> Optional[Union[ChecksumAddress, str]]:
def resolve(self, name: str, get: str = 'addr') -> Optional[Union[ChecksumAddress, str]]:
normal_name = normalize_name(name)
resolver = self.resolver(normal_name)
if resolver:
Expand Down Expand Up @@ -249,8 +249,8 @@ def owner(self, name: str) -> ChecksumAddress:
def setup_owner(
self,
name: str,
new_owner: ChecksumAddress=cast(ChecksumAddress, default),
transact: "TxParams"={}
new_owner: ChecksumAddress = cast(ChecksumAddress, default),
transact: "TxParams" = {}
) -> ChecksumAddress:
"""
Set the owner of the supplied name to `new_owner`.
Expand Down Expand Up @@ -323,8 +323,8 @@ def _claim_ownership(
owner: ChecksumAddress,
unowned: Sequence[str],
owned: str,
old_owner: ChecksumAddress=None,
transact: "TxParams"={}
old_owner: ChecksumAddress = None,
transact: "TxParams" = {}
) -> None:
transact['from'] = old_owner or owner
for label in reversed(unowned):
Expand All @@ -337,7 +337,7 @@ def _claim_ownership(

@dict_copy
def _set_resolver(
self, name: str, resolver_addr: ChecksumAddress=None, transact: "TxParams"={}
self, name: str, resolver_addr: ChecksumAddress = None, transact: "TxParams" = {}
) -> 'Contract':
if is_none_or_zero_address(resolver_addr):
resolver_addr = self.address('resolver.eth')
Expand All @@ -351,7 +351,7 @@ def _set_resolver(

@dict_copy
def _setup_reverse(
self, name: str, address: ChecksumAddress, transact: "TxParams"={}
self, name: str, address: ChecksumAddress, transact: "TxParams" = {}
) -> HexBytes:
if name:
name = normalize_name(name)
Expand Down
2 changes: 1 addition & 1 deletion ens/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def ensure_hex(data: HexBytes) -> HexBytes:
return data


def init_web3(provider: 'BaseProvider'=cast('BaseProvider', default)) -> '_Web3':
def init_web3(provider: 'BaseProvider' = cast('BaseProvider', default)) -> '_Web3':
from web3 import Web3 as Web3Main

if provider is default:
Expand Down
4 changes: 2 additions & 2 deletions ethpm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ def get_ethpm_spec_dir() -> Path:
return ethpm_spec_dir


from .package import Package # noqa: F401
from .backends.registry import RegistryURI # noqa: F401
from .package import Package # noqa: E402, F401
from .backends.registry import RegistryURI # noqa: E402, F401
8 changes: 4 additions & 4 deletions ethpm/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ class Dependencies:

# ignoring Package type here and below to avoid a circular dependency
def __init__(
self, build_dependencies: Dict[str, "Package"] # type: ignore
self, build_dependencies: Dict[str, "Package"] # type: ignore # noqa: F821
) -> None:
self.build_dependencies = build_dependencies

def __getitem__(self, key: str) -> "Package": # type: ignore # noqa: F821
def __getitem__(self, key: str) -> "Package": # type: ignore # noqa: F821
return self.build_dependencies.get(key)

def __contains__(self, key: str) -> bool:
Expand All @@ -31,7 +31,7 @@ def _validate_name(self, name: str) -> None:
if name not in self.build_dependencies:
raise KeyError(f"Package name: {name} not found in build dependencies.")

def items(self) -> Tuple[Tuple[str, "Package"], ...]: # type: ignore
def items(self) -> Tuple[Tuple[str, "Package"], ...]: # type: ignore # noqa: F821
"""
Return an iterable containing package name and
corresponding `Package` instance that are available.
Expand All @@ -41,7 +41,7 @@ def items(self) -> Tuple[Tuple[str, "Package"], ...]: # type: ignore
}
return tuple(item_dict.items())

def values(self) -> List["Package"]: # type: ignore
def values(self) -> List["Package"]: # type: ignore # noqa: F821
"""
Return an iterable of the available `Package` instances.
"""
Expand Down
1 change: 1 addition & 0 deletions newsfragments/1759.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Upgrade Flake8 to v3.8.3
1 change: 0 additions & 1 deletion newsfragments/validate_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# Towncrier silently ignores files that do not match the expected ending.
# We use this script to ensure we catch these as errors in CI.

import os
import pathlib
import sys

Expand Down
10 changes: 5 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"py-geth>=2.4.0,<3",
],
'linter': [
"flake8==3.4.1",
"flake8==3.8.3",
"isort>=4.2.15,<4.3.5",
"mypy==0.730",
],
Expand Down Expand Up @@ -51,10 +51,10 @@
}

extras_require['dev'] = (
extras_require['tester'] +
extras_require['linter'] +
extras_require['docs'] +
extras_require['dev']
extras_require['tester']
+ extras_require['linter']
+ extras_require['docs']
+ extras_require['dev']
)

setup(
Expand Down
23 changes: 11 additions & 12 deletions tests/core/contracts/test_contract_deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,26 +55,25 @@ def test_contract_deployment_with_constructor_with_arguments(web3,


@pytest.mark.parametrize('constructor_arg', (
b'1234\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', # noqa: E501
'0x0000000000000000000000000000000000000000000000000000000000000000'
)
b'1234\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', # noqa: E501
'0x0000000000000000000000000000000000000000000000000000000000000000')
)
def test_contract_deployment_with_constructor_with_arguments_strict(w3_strict_abi,
WithConstructorArgumentsContractStrict, # noqa: E501
WITH_CONSTRUCTOR_ARGUMENTS_RUNTIME, # noqa: E501
constructor_arg):
deploy_txn = WithConstructorArgumentsContractStrict.constructor(
1234, constructor_arg
).transact()
deploy_txn = WithConstructorArgumentsContractStrict.constructor(
1234, constructor_arg
).transact()

txn_receipt = w3_strict_abi.eth.waitForTransactionReceipt(deploy_txn)
assert txn_receipt is not None
txn_receipt = w3_strict_abi.eth.waitForTransactionReceipt(deploy_txn)
assert txn_receipt is not None

assert txn_receipt['contractAddress']
contract_address = txn_receipt['contractAddress']
assert txn_receipt['contractAddress']
contract_address = txn_receipt['contractAddress']

blockchain_code = w3_strict_abi.eth.getCode(contract_address)
assert blockchain_code == decode_hex(WITH_CONSTRUCTOR_ARGUMENTS_RUNTIME)
blockchain_code = w3_strict_abi.eth.getCode(contract_address)
assert blockchain_code == decode_hex(WITH_CONSTRUCTOR_ARGUMENTS_RUNTIME)


def test_contract_deployment_with_constructor_with_arguments_strict_error(w3_strict_abi,
Expand Down
2 changes: 1 addition & 1 deletion tests/core/contracts/test_extracting_event_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ def test_receipt_processing_with_invalid_flag(

event_instance = indexed_event_contract.events.LogSingleWithIndex()

with pytest.raises(AttributeError, match=f"Error flag must be one of: "):
with pytest.raises(AttributeError, match="Error flag must be one of: "):
event_instance.processReceipt(dup_txn_receipt, errors='not-a-flag')


Expand Down
4 changes: 2 additions & 2 deletions tests/core/eth-module/test_accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ def test_eth_account_sign(acct,
signature):
message = encode_defunct(text=message_text)
signed_message = Web3.keccak(
b"\x19Ethereum Signed Message:\n" +
bytes(f"{len(message.body)}", encoding='utf-8') + message.body
b"\x19Ethereum Signed Message:\n"
+ bytes(f"{len(message.body)}", encoding='utf-8') + message.body
)
assert signed_message == expected_hash

Expand Down
2 changes: 1 addition & 1 deletion tests/core/filtering/test_contract_on_event_filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def test_on_sync_filter_with_event_name_and_single_argument(

seen_logs = event_filter.get_new_entries()
assert len(seen_logs) == 2
assert {l['transactionHash'] for l in seen_logs} == set(txn_hashes[1:])
assert {log['transactionHash'] for log in seen_logs} == set(txn_hashes[1:])


@pytest.mark.parametrize('call_as_instance', (True, False))
Expand Down
20 changes: 10 additions & 10 deletions tests/core/gas-strategies/test_time_based_gas_price_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
def _get_block_by_something(method, params):
block_identifier = params[0]
if (
block_identifier == 'latest' or
block_identifier == '0x5'
block_identifier == 'latest'
or block_identifier == '0x5'
):
return {
'hash': '0x0000000000000000000000000000000000000000000000000000000000000005',
Expand All @@ -38,8 +38,8 @@ def _get_block_by_something(method, params):
'timestamp': 120,
}
elif (
block_identifier == '0x0000000000000000000000000000000000000000000000000000000000000004' or
block_identifier == '0x4'
block_identifier == '0x0000000000000000000000000000000000000000000000000000000000000004'
or block_identifier == '0x4'
):
return {
'hash': '0x0000000000000000000000000000000000000000000000000000000000000004',
Expand All @@ -54,8 +54,8 @@ def _get_block_by_something(method, params):
'timestamp': 90,
}
elif (
block_identifier == '0x0000000000000000000000000000000000000000000000000000000000000003' or
block_identifier == '0x3'
block_identifier == '0x0000000000000000000000000000000000000000000000000000000000000003'
or block_identifier == '0x3'
):
return {
'hash': '0x0000000000000000000000000000000000000000000000000000000000000003',
Expand All @@ -68,8 +68,8 @@ def _get_block_by_something(method, params):
'timestamp': 60,
}
elif (
block_identifier == '0x0000000000000000000000000000000000000000000000000000000000000002' or
block_identifier == '0x2'
block_identifier == '0x0000000000000000000000000000000000000000000000000000000000000002'
or block_identifier == '0x2'
):
return {
'hash': '0x0000000000000000000000000000000000000000000000000000000000000002',
Expand All @@ -81,8 +81,8 @@ def _get_block_by_something(method, params):
'timestamp': 30,
}
elif (
block_identifier == '0x0000000000000000000000000000000000000000000000000000000000000001' or
block_identifier == '0x1'
block_identifier == '0x0000000000000000000000000000000000000000000000000000000000000001'
or block_identifier == '0x1'
):
return {
'hash': '0x0000000000000000000000000000000000000000000000000000000000000001',
Expand Down
4 changes: 2 additions & 2 deletions tests/core/shh-module/test_shh_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def test_shh_remove_filter_deprecated(web3, skip_if_testrpc):
try:
web3.shh.getMessages(shh_filter.filter_id)
assert False
except:
except Exception:
assert True


Expand Down Expand Up @@ -257,5 +257,5 @@ def test_shh_remove_filter(web3, skip_if_testrpc):
try:
web3.shh.get_messages(shh_filter.filter_id)
assert False
except:
except Exception:
assert True
12 changes: 6 additions & 6 deletions tests/ethpm/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
create_latest_block_uri,
)
from web3 import Web3
from web3.tools import ( # noqa: E741
linker as l,
from web3.tools import (
linker,
)

V3_PACKAGE_NAMES = [
Expand Down Expand Up @@ -172,10 +172,10 @@ def manifest_with_empty_deployments(tmpdir, safe_math_manifest):
def escrow_package(deployer, w3, ethpm_spec_dir):
escrow_manifest = ethpm_spec_dir / "examples" / "escrow" / "v3.json"
escrow_deployer = deployer(escrow_manifest)
escrow_strategy = l.linker(
l.deploy("SafeSendLib"),
l.link("Escrow", "SafeSendLib"),
l.deploy("Escrow", w3.eth.accounts[0]),
escrow_strategy = linker.linker(
linker.deploy("SafeSendLib"),
linker.link("Escrow", "SafeSendLib"),
linker.deploy("Escrow", w3.eth.accounts[0]),
)
escrow_deployer.register_strategy("Escrow", escrow_strategy)
return escrow_deployer.deploy("Escrow")
Expand Down
4 changes: 2 additions & 2 deletions tests/ethpm/test_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ def test_linkable_contract_class_handles_missing_link_refs(get_manifest, w3):
{"length": 20, "name": "SafeMathLib", "offsets": [25]},
],
{"SafeSendLib": SAFE_SEND_CANON, "SafeMathLib": SAFE_MATH_CANON},
b"\00" + SAFE_SEND_CANON + bytearray(4) + SAFE_MATH_CANON +
bytearray(5) + SAFE_SEND_CANON + bytearray(10),
b"\00" + SAFE_SEND_CANON + bytearray(4) + SAFE_MATH_CANON
+ bytearray(5) + SAFE_SEND_CANON + bytearray(10),
),
),
)
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use_parentheses=True
[flake8]
max-line-length= 100
exclude= venv*,.tox,docs,build
ignore=
ignore=W503
[testenv]
whitelist_externals=/usr/bin/make
install_command=python -m pip install --no-use-pep517 {opts} {packages}
Expand Down
4 changes: 2 additions & 2 deletions web3/_utils/abi.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ def filter_by_name(name: str, contract_abi: ABI) -> List[Union[ABIFunction, ABIE
for abi
in contract_abi
if (
abi['type'] not in ('fallback', 'constructor', 'receive') and
abi['name'] == name
abi['type'] not in ('fallback', 'constructor', 'receive')
and abi['name'] == name
)
]

Expand Down
5 changes: 3 additions & 2 deletions web3/_utils/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@


def admin_start_params_munger(
module: Module, host: str='localhost', port: int=8546, cors: str='', apis: str='eth,net,web3'
module: Module, host: str = 'localhost', port: int = 8546, cors: str = '',
apis: str = 'eth,net,web3'
) -> Tuple[str, int, str, str]:
return (host, port, cors, apis)

Expand Down Expand Up @@ -57,7 +58,7 @@ def admin_start_params_munger(

class ServerConnection(Protocol):
def __call__(
self, host: str="localhost", port: int=8546, cors: str="", apis: str="eth,net,web3"
self, host: str = "localhost", port: int = 8546, cors: str = "", apis: str = "eth,net,web3"
) -> bool:
pass

Expand Down
2 changes: 1 addition & 1 deletion web3/_utils/method_formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def bytes_to_ascii(value: bytes) -> str:

@curry
def to_hexbytes(
num_bytes: int, val: Union[str, int, bytes], variable_length: bool=False
num_bytes: int, val: Union[str, int, bytes], variable_length: bool = False
) -> HexBytes:
if isinstance(val, (str, int, bytes)):
result = HexBytes(val)
Expand Down
Loading