Skip to content
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
40 changes: 32 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,6 @@ windows_steps: &windows_steps


jobs:
lint:
<<: *common
docker:
- image: cimg/python:3.9
environment:
TOXENV: lint

docs:
<<: *docs_steps
docker:
Expand Down Expand Up @@ -327,6 +320,13 @@ jobs:
#
# Python 3.8
#
py38-lint:
<<: *common
docker:
- image: cimg/python:3.8
environment:
TOXENV: py38-lint

py38-core:
<<: *common
docker:
Expand Down Expand Up @@ -424,6 +424,13 @@ jobs:
#
# Python 3.9
#
py39-lint:
<<: *common
docker:
- image: cimg/python:3.9
environment:
TOXENV: py39-lint

py39-core:
<<: *common
docker:
Expand Down Expand Up @@ -521,6 +528,13 @@ jobs:
#
# Python 3.10
#
py310-lint:
<<: *common
docker:
- image: cimg/python:3.10
environment:
TOXENV: py310-lint

py310-core:
<<: *common
docker:
Expand Down Expand Up @@ -618,6 +632,13 @@ jobs:
#
# Python 3.11
#
py311-lint:
<<: *common
docker:
- image: cimg/python:3.11
environment:
TOXENV: py311-lint

py311-core:
<<: *common
docker:
Expand Down Expand Up @@ -730,7 +751,6 @@ workflows:
- py39-core
- py310-core
- py311-core
- lint
- docs
- benchmark
- py37-ens
Expand All @@ -745,6 +765,7 @@ workflows:
- py37-integration-ethtester-pyevm
- py37-wheel-cli
- py37-wheel-cli-windows
- py38-lint
- py38-ens
- py38-ethpm
- py38-integration-goethereum-ipc
Expand All @@ -756,6 +777,7 @@ workflows:
- py38-integration-goethereum-ws_flaky
- py38-integration-ethtester-pyevm
- py38-wheel-cli
- py39-lint
- py39-ens
- py39-ethpm
- py39-integration-goethereum-ipc
Expand All @@ -767,6 +789,7 @@ workflows:
- py39-integration-goethereum-ws_flaky
- py39-integration-ethtester-pyevm
- py39-wheel-cli
- py310-lint
- py310-ens
- py310-ethpm
- py310-integration-goethereum-ipc
Expand All @@ -778,6 +801,7 @@ workflows:
- py310-integration-goethereum-ws_flaky
- py310-integration-ethtester-pyevm
- py310-wheel-cli
- py311-lint
- py311-ens
- py311-ethpm
- py311-integration-goethereum-ipc
Expand Down
16 changes: 16 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[settings]
profile=black
force_grid_wrap=1
multi_line_output=3
honor_noqa=true
float_to_top=true
combine_as_imports=true
force_sort_within_sections=true
include_trailing_comma=true
extra_standard_library=pytest
known_first_party=web3,ens,ethpm
known_third_party=lru,eth_tester
line_length=88
use_parentheses=true
# skip `__init__.py` files because sometimes order of initialization is important
skip=__init__.py,web3/main.py,web3/utils/windows.py,ethpm/ethpm-spec/,ethpm/_utils/protobuf/ipfs_file_pb2.py,
1 change: 0 additions & 1 deletion ens/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from .ens import (
ENS,
)

from .exceptions import (
AddressMismatch,
BidTooLow,
Expand Down
4 changes: 3 additions & 1 deletion ens/async_ens.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
HexBytes,
)

from ens import abis
from ens import (
abis,
)
from ens.base_ens import (
BaseENS,
)
Expand Down
4 changes: 3 additions & 1 deletion ens/auto.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from ens import ENS
from ens import (
ENS,
)

ns = ENS()
4 changes: 3 additions & 1 deletion ens/ens.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
HexBytes,
)

from ens import abis
from ens import (
abis,
)
from ens.base_ens import (
BaseENS,
)
Expand Down
32 changes: 24 additions & 8 deletions ens/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@


if TYPE_CHECKING:
from web3 import Web3 as _Web3 # noqa: F401
from web3 import ( # noqa: F401
Web3 as _Web3,
)
from web3.providers import ( # noqa: F401
AsyncBaseProvider,
BaseProvider,
Expand All @@ -67,7 +69,9 @@


def Web3() -> Type["_Web3"]:
from web3 import Web3 as Web3Main
from web3 import (
Web3 as Web3Main,
)

return Web3Main

Expand All @@ -76,8 +80,12 @@ def init_web3(
provider: "BaseProvider" = cast("BaseProvider", default),
middlewares: Optional[Sequence[Tuple["Middleware", str]]] = None,
) -> "_Web3":
from web3 import Web3 as Web3Main
from web3.eth import Eth as EthMain
from web3 import (
Web3 as Web3Main,
)
from web3.eth import (
Eth as EthMain,
)

if provider is default:
w3 = Web3Main(ens=None, modules={"eth": (EthMain)})
Expand All @@ -88,7 +96,9 @@ def init_web3(


def customize_web3(w3: "_Web3") -> "_Web3":
from web3.middleware import make_stalecheck_middleware
from web3.middleware import (
make_stalecheck_middleware,
)

if w3.middleware_onion.get("name_to_address"):
w3.middleware_onion.remove("name_to_address")
Expand Down Expand Up @@ -280,8 +290,12 @@ def init_async_web3(
provider: "AsyncBaseProvider" = cast("AsyncBaseProvider", default),
middlewares: Optional[Sequence[Tuple["Middleware", str]]] = (),
) -> "_Web3":
from web3 import Web3 as Web3Main
from web3.eth import AsyncEth as AsyncEthMain
from web3 import (
Web3 as Web3Main,
)
from web3.eth import (
AsyncEth as AsyncEthMain,
)

middlewares = list(middlewares)
for i, (middleware, name) in enumerate(middlewares):
Expand Down Expand Up @@ -309,7 +323,9 @@ def init_async_web3(
async def _async_ens_stalecheck_middleware(
make_request: Callable[["RPCEndpoint", Any], Any], w3: "_Web3"
) -> "Middleware":
from web3.middleware import async_make_stalecheck_middleware
from web3.middleware import (
async_make_stalecheck_middleware,
)

middleware = await async_make_stalecheck_middleware(ACCEPTABLE_STALE_HOURS * 3600)
return await middleware(make_request, w3)
4 changes: 3 additions & 1 deletion ethpm/_utils/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
)

try:
from ipfshttpclient.exceptions import ConnectionError as IpfsConnectionError
from ipfshttpclient.exceptions import (
ConnectionError as IpfsConnectionError,
)
except ImportError:
pass

Expand Down
14 changes: 11 additions & 3 deletions ethpm/backends/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
is_address,
)

from ens import ENS
from ens import (
ENS,
)
from ethpm._utils.registry import (
fetch_standard_registry_abi,
)
Expand Down Expand Up @@ -46,7 +48,10 @@ class RegistryURIBackend(BaseURIBackend):
"""

def __init__(self) -> None:
from web3 import Web3, WebsocketProvider
from web3 import (
Web3,
WebsocketProvider,
)

w3 = Web3(WebsocketProvider())

Expand Down Expand Up @@ -90,7 +95,10 @@ def parse_registry_uri(uri: str) -> RegistryURI:
Validate and return (authority, chain_id, pkg_name, version)
from a valid registry URI.
"""
from web3 import Web3, WebsocketProvider
from web3 import (
Web3,
WebsocketProvider,
)

w3 = Web3(WebsocketProvider())

Expand Down
1 change: 1 addition & 0 deletions ethpm/tools/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ def check_sources(manifest: Manifest, warnings: Dict[str, str]) -> Dict[str, str
# Contract Types
#


# todo: validate a contract type matches source
@curry
def check_contract_types(
Expand Down
4 changes: 3 additions & 1 deletion ethpm/validation/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
from ethpm.exceptions import (
EthPMValidationError,
)
from web3 import Web3
from web3 import (
Web3,
)


def validate_w3_instance(w3: "Web3") -> None:
Expand Down
4 changes: 3 additions & 1 deletion ethpm/validation/uri.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ def validate_single_matching_uri(all_blockchain_uris: List[str], w3: "Web3") ->
Return a single block URI after validating that it is the *only* URI in
all_blockchain_uris that matches the w3 instance.
"""
from ethpm.uri import check_if_chain_matches_chain_uri
from ethpm.uri import (
check_if_chain_matches_chain_uri,
)

matching_uris = [
uri for uri in all_blockchain_uris if check_if_chain_matches_chain_uri(w3, uri)
Expand Down
1 change: 1 addition & 0 deletions newsfragments/2802.internal.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updates to ``isort`` and ``black`` required some formatting changes and isort config refactoring.
3 changes: 0 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,3 @@ showcontent = false
directory = "breaking"
name = "Breaking changes"
showcontent = true

[tool.isort]
profile="black"
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"linter": [
"black>=22.1.0",
"flake8==3.8.3",
"isort>=4.2.15,<4.3.5",
"isort>=5.11.0",
"mypy==0.910",
"types-setuptools>=57.4.4",
"types-requests>=2.26.1",
Expand Down
4 changes: 3 additions & 1 deletion tests/core/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import pytest_asyncio

from web3 import Web3
from web3 import (
Web3,
)
from web3.eth import (
AsyncEth,
)
Expand Down
1 change: 0 additions & 1 deletion tests/core/contracts/test_contract_deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ async def test_async_contract_deployment_with_constructor_arguments(
async_constructor_with_args_contract_factory,
constructor_arg,
):

deploy_txn = await async_constructor_with_args_contract_factory.constructor(
1234, constructor_arg
).transact()
Expand Down
8 changes: 6 additions & 2 deletions tests/core/contracts/test_contract_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ def test_initial_greeting(foo_contract):

def test_can_update_greeting(w3, foo_contract):
# send transaction that updates the greeting
tx_hash = foo_contract.functions.setBar("testing contracts is easy",).transact(
tx_hash = foo_contract.functions.setBar(
"testing contracts is easy",
).transact(
{
"from": w3.eth.accounts[1],
}
Expand All @@ -97,7 +99,9 @@ def test_can_update_greeting(w3, foo_contract):

def test_updating_greeting_emits_event(w3, foo_contract):
# send transaction that updates the greeting
tx_hash = foo_contract.functions.setBar("testing contracts is easy",).transact(
tx_hash = foo_contract.functions.setBar(
"testing contracts is easy",
).transact(
{
"from": w3.eth.accounts[1],
}
Expand Down
2 changes: 0 additions & 2 deletions tests/core/contracts/test_contract_transact_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,6 @@ async def test_async_transacting_with_contract_with_byte_array_argument_non_stri
async def test_async_transacting_with_contract_respects_explicit_gas(
async_w3, string_contract_data, async_call, async_transact
):

StringContract = async_w3.eth.contract(**string_contract_data)

deploy_txn = await StringContract.constructor("Caqalai").transact()
Expand Down Expand Up @@ -541,7 +540,6 @@ async def test_async_transacting_with_contract_respects_explicit_gas(
async def test_async_auto_gas_computation_when_transacting(
async_w3, string_contract_data, async_call, async_transact
):

StringContract = async_w3.eth.contract(**string_contract_data)

deploy_txn = await StringContract.constructor("Caqalai").transact()
Expand Down
Loading