Skip to content

Commit

Permalink
Show renames of "by reference" watched values
Browse files Browse the repository at this point in the history
  • Loading branch information
mvanderkamp committed Jun 29, 2022
1 parent e79e268 commit 0980fa5
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions pudb/var_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -743,8 +743,23 @@ def make_var_view(global_watches, frame_var_info, frame_globals, frame_locals):
for watch_expr in chain(global_watches, frame_var_info.watches):
value = watch_expr.eval(frame_globals, frame_locals)
scope_str = watch_expr.scope[0]
method_str = "=" if watch_expr.method == "expression" else "*"
label = f"[{scope_str}{method_str}] {watch_expr.expression}"
expression = watch_expr.expression
if watch_expr.method == "reference":
found = False
# locals first as that's the context the user is more likely to be
# interested in re: seeing renames.
for mapping in (frame_locals, frame_globals):
for k, v in mapping.items():
if v is value:
expression = f"{expression} ({k})"
found = True
break
if found:
break
method_str = "*"
else:
method_str = "="
label = f"[{scope_str}{method_str}] {expression}"
WatchValueWalker(frame_var_info, watch_widget_list, watch_expr) \
.walk_value(None, label, value)

Expand Down

0 comments on commit 0980fa5

Please sign in to comment.