Skip to content

Commit c94f798

Browse files
committed
feat(trace): simplify state handling logic
1 parent 12f4c3b commit c94f798

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

tests/infra/trace/traced_spec.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,18 +111,18 @@ def _spec_call_hook(
111111
args/kwargs: Arguments passed to the function.
112112
"""
113113
method_name = wrapped.__name__
114-
state: STATE | None = None
115114

116115
# A. Prepare arguments: bind to signature and serialize
117116
bound_args = self._bind_args(wrapped, args, kwargs)
117+
state: STATE | None = bound_args.arguments.get("state")
118118

119119
# Process arguments and auto-register any new SSZ objects as artifacts
120120
serial_params: SERIALIZED_KWARGS = {
121121
k: self._process_arg(v) for k, v in bound_args.arguments.items()
122122
}
123123

124124
# B. Identify State object and handle external state mutations
125-
self._capture_pre_state(state := bound_args.arguments.get("state"))
125+
self._capture_pre_state(state)
126126

127127
# C. Execute the real function with original args/kwargs
128128
result: RAW_ARGS = wrapped(*args, **kwargs)
@@ -132,8 +132,7 @@ def _spec_call_hook(
132132
self._record_spec_call_step(method_name, serial_params, serial_result)
133133

134134
# E. Update tracked state if mutated
135-
if state is not None:
136-
self._capture_post_state(state)
135+
self._capture_post_state(state)
137136

138137
return result
139138

0 commit comments

Comments
 (0)