@@ -772,13 +772,14 @@ def _find_address_refs_in_bytecode(
772772 code_bytes : bytes ,
773773 known_addresses : set [Address ],
774774) -> dict [Address , int ]:
775- """Find which known addresses are referenced in bytecode via PUSH.
775+ """
776+ Find known addresses referenced in bytecode via PUSH.
776777
777- Return a mapping ``address -> minimum PUSH size observed``. A push size
778- smaller than 20 means the baseline bytecode compiled the address down
779- to fewer bytes (the original address had leading zero bytes); the
780- referenced contract must stay hardcoded so that the compiler keeps
781- emitting the same short PUSH opcode and the trace stays aligned.
778+ Return a mapping ``address -> minimum PUSH size observed``.
779+ A push size < 20 means the baseline bytecode compiled the
780+ address to fewer bytes (leading zero bytes); the referenced
781+ contract must stay hardcoded so the compiler keeps emitting
782+ the same short PUSH opcode and the trace stays aligned.
782783 """
783784 refs : dict [Address , int ] = {}
784785 # Pre-compute int values for fast comparison
@@ -819,8 +820,8 @@ def _topological_sort_contracts(
819820 """
820821 addr_set = set (contract_addrs )
821822 # forward[B] = {A} means A depends on B, so B must come first
822- forward : dict [Address , set [Address ]] = {a : set () for a in addr_set }
823- in_deg : dict [Address , int ] = { a : 0 for a in addr_set }
823+ forward : dict [Address , set [Address ]] = {a : set () for a in addr_set } # noqa: C420
824+ in_deg : dict [Address , int ] = dict . fromkeys ( addr_set , 0 )
824825 for a , dep_set in deps .items ():
825826 if a not in addr_set :
826827 continue
@@ -1015,7 +1016,10 @@ def _build_accounts(
10151016 changed = False
10161017 for addr in list (non_dynamic_addrs ):
10171018 for ref in deps .get (addr , set ()):
1018- if ref not in non_dynamic_addrs and ref in known_contract_addrs :
1019+ if (
1020+ ref not in non_dynamic_addrs
1021+ and ref in known_contract_addrs
1022+ ):
10191023 non_dynamic_addrs .add (ref )
10201024 changed = True
10211025
@@ -1057,13 +1061,13 @@ def _build_accounts(
10571061 # sequential addresses and cannot be dynamically assigned.
10581062 # If found, disable dynamic for ALL contracts.
10591063 # ------------------------------------------------------------------
1060- _ARITH_OPS = {"Op.ADD(" , "Op.SUB(" , "Op.MUL(" , "Op.DIV(" }
1064+ arith_ops = {"Op.ADD(" , "Op.SUB(" , "Op.MUL(" , "Op.DIV(" }
10611065 has_addr_arithmetic = False
10621066 for acct in raw_accounts :
10631067 if not acct .code_expr :
10641068 continue
10651069 for var_name in addr_var_names :
1066- for arith_op in _ARITH_OPS :
1070+ for arith_op in arith_ops :
10671071 if f"{ arith_op } { var_name } " in acct .code_expr :
10681072 has_addr_arithmetic = True
10691073 break
@@ -1078,7 +1082,7 @@ def _build_accounts(
10781082 # do this usually rely on specific pre-state contract addresses
10791083 # (dispatch-by-offset) and won't survive dynamic allocation.
10801084 # ------------------------------------------------------------------
1081- _COMPUTED_ADDR_PATTERNS = (
1085+ computed_addr_patterns = (
10821086 "address=Op.ADD(" ,
10831087 "address=Op.SUB(" ,
10841088 "address=Op.MUL(" ,
@@ -1092,7 +1096,7 @@ def _build_accounts(
10921096 for acct in raw_accounts :
10931097 if not acct .code_expr :
10941098 continue
1095- for pat in _COMPUTED_ADDR_PATTERNS :
1099+ for pat in computed_addr_patterns :
10961100 if pat in acct .code_expr :
10971101 has_computed_call_target = True
10981102 break
0 commit comments