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

Use assert_type alongside cast #1

Merged
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
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ python_requires = >=3.10
install_requires =
pycryptodome>=3,<4
coincurve>=20,<21
typing_extensions>=4
typing_extensions>=4.2
py_ecc @ git+https://github.com/petertdavies/py_ecc.git@127184f4c57b1812da959586d0fe8f43bb1a2389
ethereum-types>=0.2.1,<0.3

Expand Down
3 changes: 2 additions & 1 deletion src/ethereum/arrow_glacier/trie.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from ethereum_types.bytes import Bytes
from ethereum_types.frozen import slotted_freezable
from ethereum_types.numeric import U256, Uint
from typing_extensions import assert_type

from ethereum.crypto.hash import keccak256
from ethereum.london import trie as previous_trie
Expand Down Expand Up @@ -485,6 +486,6 @@ def patricialize(
for k in range(16)
)
return BranchNode(
cast(BranchSubnodes, subnodes),
cast(BranchSubnodes, assert_type(subnodes, Tuple[rlp.Extended, ...])),
value,
)
3 changes: 2 additions & 1 deletion src/ethereum/berlin/trie.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
Tuple,
TypeVar,
Union,
assert_type,
cast,
)

Expand Down Expand Up @@ -485,6 +486,6 @@ def patricialize(
for k in range(16)
)
return BranchNode(
cast(BranchSubnodes, subnodes),
cast(BranchSubnodes, assert_type(subnodes, Tuple[rlp.Extended, ...])),
value,
)
3 changes: 2 additions & 1 deletion src/ethereum/byzantium/trie.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
Tuple,
TypeVar,
Union,
assert_type,
cast,
)

Expand Down Expand Up @@ -485,6 +486,6 @@ def patricialize(
for k in range(16)
)
return BranchNode(
cast(BranchSubnodes, subnodes),
cast(BranchSubnodes, assert_type(subnodes, Tuple[rlp.Extended, ...])),
value,
)
3 changes: 2 additions & 1 deletion src/ethereum/cancun/trie.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
Tuple,
TypeVar,
Union,
assert_type,
cast,
)

Expand Down Expand Up @@ -488,6 +489,6 @@ def patricialize(
for k in range(16)
)
return BranchNode(
cast(BranchSubnodes, subnodes),
cast(BranchSubnodes, assert_type(subnodes, Tuple[rlp.Extended, ...])),
value,
)
3 changes: 2 additions & 1 deletion src/ethereum/constantinople/trie.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
Tuple,
TypeVar,
Union,
assert_type,
cast,
)

Expand Down Expand Up @@ -485,6 +486,6 @@ def patricialize(
for k in range(16)
)
return BranchNode(
cast(BranchSubnodes, subnodes),
cast(BranchSubnodes, assert_type(subnodes, Tuple[rlp.Extended, ...])),
value,
)
3 changes: 2 additions & 1 deletion src/ethereum/dao_fork/trie.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
Tuple,
TypeVar,
Union,
assert_type,
cast,
)

Expand Down Expand Up @@ -485,6 +486,6 @@ def patricialize(
for k in range(16)
)
return BranchNode(
cast(BranchSubnodes, subnodes),
cast(BranchSubnodes, assert_type(subnodes, Tuple[rlp.Extended, ...])),
value,
)
3 changes: 2 additions & 1 deletion src/ethereum/frontier/trie.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
Tuple,
TypeVar,
Union,
assert_type,
cast,
)

Expand Down Expand Up @@ -486,6 +487,6 @@ def patricialize(
for k in range(16)
)
return BranchNode(
cast(BranchSubnodes, subnodes),
cast(BranchSubnodes, assert_type(subnodes, Tuple[rlp.Extended, ...])),
value,
)
3 changes: 2 additions & 1 deletion src/ethereum/gray_glacier/trie.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
Tuple,
TypeVar,
Union,
assert_type,
cast,
)

Expand Down Expand Up @@ -485,6 +486,6 @@ def patricialize(
for k in range(16)
)
return BranchNode(
cast(BranchSubnodes, subnodes),
cast(BranchSubnodes, assert_type(subnodes, Tuple[rlp.Extended, ...])),
value,
)
3 changes: 2 additions & 1 deletion src/ethereum/homestead/trie.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
Tuple,
TypeVar,
Union,
assert_type,
cast,
)

Expand Down Expand Up @@ -485,6 +486,6 @@ def patricialize(
for k in range(16)
)
return BranchNode(
cast(BranchSubnodes, subnodes),
cast(BranchSubnodes, assert_type(subnodes, Tuple[rlp.Extended, ...])),
value,
)
3 changes: 2 additions & 1 deletion src/ethereum/istanbul/trie.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
Tuple,
TypeVar,
Union,
assert_type,
cast,
)

Expand Down Expand Up @@ -485,6 +486,6 @@ def patricialize(
for k in range(16)
)
return BranchNode(
cast(BranchSubnodes, subnodes),
cast(BranchSubnodes, assert_type(subnodes, Tuple[rlp.Extended, ...])),
value,
)
3 changes: 2 additions & 1 deletion src/ethereum/london/trie.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
Tuple,
TypeVar,
Union,
assert_type,
cast,
)

Expand Down Expand Up @@ -485,6 +486,6 @@ def patricialize(
for k in range(16)
)
return BranchNode(
cast(BranchSubnodes, subnodes),
cast(BranchSubnodes, assert_type(subnodes, Tuple[rlp.Extended, ...])),
value,
)
3 changes: 2 additions & 1 deletion src/ethereum/muir_glacier/trie.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
Tuple,
TypeVar,
Union,
assert_type,
cast,
)

Expand Down Expand Up @@ -485,6 +486,6 @@ def patricialize(
for k in range(16)
)
return BranchNode(
cast(BranchSubnodes, subnodes),
cast(BranchSubnodes, assert_type(subnodes, Tuple[rlp.Extended, ...])),
value,
)
3 changes: 2 additions & 1 deletion src/ethereum/paris/trie.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
Tuple,
TypeVar,
Union,
assert_type,
cast,
)

Expand Down Expand Up @@ -485,6 +486,6 @@ def patricialize(
for k in range(16)
)
return BranchNode(
cast(BranchSubnodes, subnodes),
cast(BranchSubnodes, assert_type(subnodes, Tuple[rlp.Extended, ...])),
value,
)
3 changes: 2 additions & 1 deletion src/ethereum/shanghai/trie.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
Tuple,
TypeVar,
Union,
assert_type,
cast,
)

Expand Down Expand Up @@ -488,6 +489,6 @@ def patricialize(
for k in range(16)
)
return BranchNode(
cast(BranchSubnodes, subnodes),
cast(BranchSubnodes, assert_type(subnodes, Tuple[rlp.Extended, ...])),
value,
)
3 changes: 2 additions & 1 deletion src/ethereum/spurious_dragon/trie.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
Tuple,
TypeVar,
Union,
assert_type,
cast,
)

Expand Down Expand Up @@ -485,6 +486,6 @@ def patricialize(
for k in range(16)
)
return BranchNode(
cast(BranchSubnodes, subnodes),
cast(BranchSubnodes, assert_type(subnodes, Tuple[rlp.Extended, ...])),
value,
)
3 changes: 2 additions & 1 deletion src/ethereum/tangerine_whistle/trie.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
Tuple,
TypeVar,
Union,
assert_type,
cast,
)

Expand Down Expand Up @@ -485,6 +486,6 @@ def patricialize(
for k in range(16)
)
return BranchNode(
cast(BranchSubnodes, subnodes),
cast(BranchSubnodes, assert_type(subnodes, Tuple[rlp.Extended, ...])),
value,
)