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

Improve Configurability of Global Variable Printing & Clickable Stack Trace Navigation #31

Open
aiyinyuedejustin opened this issue Feb 18, 2025 · 1 comment

Comments

@aiyinyuedejustin
Copy link

Description

I recently started using traceback-with-variables and noticed some inconsistencies in behavior when using different methods to enable traceback enhancements. I would like to clarify whether these behaviors are intended and suggest an improvement for configuring global variable printing more conveniently.

Findings

1. Clickable Stack Trace Navigation

  • When I import tb.a at the top of my script and run it with:
python my_script.py

I can Cmd+Click (or Ctrl+Click) on file paths in the traceback output to quickly navigate to the corresponding code in my terminal.

  • However, if I only use:
traceback-with-variables my_script.py

without importing anything, the traceback is still enhanced, but the file paths are not clickable.

  • Question: Is this expected behavior? If so, could it be documented more explicitly?

2. Global Variable Printing Behavior

  • Running with:
traceback-with-variables my_script.py

prints global variables by default. But cannot click on it.

  • Running with:
import tb.a

at the top and executing:

python my_script.py

does NOT print global variables (which is sometimes undesirable). But can click on it.

  • The only way I found to enable global variable printing while still using python my_script.py so that I can click is to use:
from traceback_with_variables import global_print_exc
global_print_exc()

at the top of my script instead of import tb.a.

Suggestion

  • The current method of configuring global variable printing is too complex. Sometimes I need global variables, and sometimes I don't, but right now the only way to configure this is by changing the import statements in my code.

  • Proposal: Could we introduce a new alias, such as:

import tb.ag  # Equivalent to `import tb.a`, but enables global variable printing
  • This would make it much easier to switch between "with globals" and "without globals" modes, without modifying multiple lines of code, while can click on the traceback to nevigate.
@andy-landy
Copy link
Owner

Thanks for bringing this. I never heard of terminals with anything clickable ;) I'll check possible differences in output

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants