Skip to content

Commit 7e31ad0

Browse files
committed
Update isort and add changes from migration guide
- Move isort config into a single config file, ``.isort.cfg``, rather than having it spread between ``tox.ini`` and ``pyproject.toml`` - Update ``isort``, add recommended changes for migrating to isort >5
1 parent 256a028 commit 7e31ad0

File tree

84 files changed

+304
-129
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+304
-129
lines changed

.isort.cfg

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[settings]
2+
profile=black
3+
force_grid_wrap=1
4+
multi_line_output=3
5+
honor_noqa=true
6+
float_to_top=true
7+
combine_as_imports=true
8+
force_sort_within_sections=true
9+
include_trailing_comma=true
10+
extra_standard_library=pytest
11+
known_first_party=web3,ens,ethpm
12+
known_third_party=lru,eth_tester
13+
line_length=88
14+
use_parentheses=true
15+
# skip `__init__.py` files because sometimes order of initialization is important
16+
skip=__init__.py,web3/main.py,web3/utils/windows.py,ethpm/ethpm-spec/,ethpm/_utils/protobuf/ipfs_file_pb2.py,

ens/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from .ens import (
1010
ENS,
1111
)
12-
1312
from .exceptions import (
1413
AddressMismatch,
1514
BidTooLow,

ens/async_ens.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
HexBytes,
3030
)
3131

32-
from ens import abis
32+
from ens import (
33+
abis,
34+
)
3335
from ens.base_ens import (
3436
BaseENS,
3537
)

ens/auto.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
from ens import ENS
1+
from ens import (
2+
ENS,
3+
)
24

35
ns = ENS()

ens/ens.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
HexBytes,
3030
)
3131

32-
from ens import abis
32+
from ens import (
33+
abis,
34+
)
3335
from ens.base_ens import (
3436
BaseENS,
3537
)

ens/utils.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@
5454

5555

5656
if TYPE_CHECKING:
57-
from web3 import Web3 as _Web3 # noqa: F401
57+
from web3 import ( # noqa: F401
58+
Web3 as _Web3,
59+
)
5860
from web3.providers import ( # noqa: F401
5961
AsyncBaseProvider,
6062
BaseProvider,
@@ -67,7 +69,9 @@
6769

6870

6971
def Web3() -> Type["_Web3"]:
70-
from web3 import Web3 as Web3Main
72+
from web3 import (
73+
Web3 as Web3Main,
74+
)
7175

7276
return Web3Main
7377

@@ -76,8 +80,12 @@ def init_web3(
7680
provider: "BaseProvider" = cast("BaseProvider", default),
7781
middlewares: Optional[Sequence[Tuple["Middleware", str]]] = None,
7882
) -> "_Web3":
79-
from web3 import Web3 as Web3Main
80-
from web3.eth import Eth as EthMain
83+
from web3 import (
84+
Web3 as Web3Main,
85+
)
86+
from web3.eth import (
87+
Eth as EthMain,
88+
)
8189

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

8997

9098
def customize_web3(w3: "_Web3") -> "_Web3":
91-
from web3.middleware import make_stalecheck_middleware
99+
from web3.middleware import (
100+
make_stalecheck_middleware,
101+
)
92102

93103
if w3.middleware_onion.get("name_to_address"):
94104
w3.middleware_onion.remove("name_to_address")
@@ -280,8 +290,12 @@ def init_async_web3(
280290
provider: "AsyncBaseProvider" = cast("AsyncBaseProvider", default),
281291
middlewares: Optional[Sequence[Tuple["Middleware", str]]] = (),
282292
) -> "_Web3":
283-
from web3 import Web3 as Web3Main
284-
from web3.eth import AsyncEth as AsyncEthMain
293+
from web3 import (
294+
Web3 as Web3Main,
295+
)
296+
from web3.eth import (
297+
AsyncEth as AsyncEthMain,
298+
)
285299

286300
middlewares = list(middlewares)
287301
for i, (middleware, name) in enumerate(middlewares):
@@ -309,7 +323,9 @@ def init_async_web3(
309323
async def _async_ens_stalecheck_middleware(
310324
make_request: Callable[["RPCEndpoint", Any], Any], w3: "_Web3"
311325
) -> "Middleware":
312-
from web3.middleware import async_make_stalecheck_middleware
326+
from web3.middleware import (
327+
async_make_stalecheck_middleware,
328+
)
313329

314330
middleware = await async_make_stalecheck_middleware(ACCEPTABLE_STALE_HOURS * 3600)
315331
return await middleware(make_request, w3)

ethpm/_utils/backend.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
)
2929

3030
try:
31-
from ipfshttpclient.exceptions import ConnectionError as IpfsConnectionError
31+
from ipfshttpclient.exceptions import (
32+
ConnectionError as IpfsConnectionError,
33+
)
3234
except ImportError:
3335
pass
3436

ethpm/backends/registry.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
is_address,
1717
)
1818

19-
from ens import ENS
19+
from ens import (
20+
ENS,
21+
)
2022
from ethpm._utils.registry import (
2123
fetch_standard_registry_abi,
2224
)
@@ -46,7 +48,10 @@ class RegistryURIBackend(BaseURIBackend):
4648
"""
4749

4850
def __init__(self) -> None:
49-
from web3 import Web3, WebsocketProvider
51+
from web3 import (
52+
Web3,
53+
WebsocketProvider,
54+
)
5055

5156
w3 = Web3(WebsocketProvider())
5257

@@ -90,7 +95,10 @@ def parse_registry_uri(uri: str) -> RegistryURI:
9095
Validate and return (authority, chain_id, pkg_name, version)
9196
from a valid registry URI.
9297
"""
93-
from web3 import Web3, WebsocketProvider
98+
from web3 import (
99+
Web3,
100+
WebsocketProvider,
101+
)
94102

95103
w3 = Web3(WebsocketProvider())
96104

ethpm/validation/misc.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
from ethpm.exceptions import (
66
EthPMValidationError,
77
)
8-
from web3 import Web3
8+
from web3 import (
9+
Web3,
10+
)
911

1012

1113
def validate_w3_instance(w3: "Web3") -> None:

ethpm/validation/uri.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ def validate_single_matching_uri(all_blockchain_uris: List[str], w3: "Web3") ->
126126
Return a single block URI after validating that it is the *only* URI in
127127
all_blockchain_uris that matches the w3 instance.
128128
"""
129-
from ethpm.uri import check_if_chain_matches_chain_uri
129+
from ethpm.uri import (
130+
check_if_chain_matches_chain_uri,
131+
)
130132

131133
matching_uris = [
132134
uri for uri in all_blockchain_uris if check_if_chain_matches_chain_uri(w3, uri)

0 commit comments

Comments
 (0)