Skip to content

Conversation

@Kigstn
Copy link

@Kigstn Kigstn commented Dec 4, 2025

Type of changes

  • Bug fix
  • New feature
  • Documentation / docstrings
  • Tests
  • Other

AI?

  • AI was used to generate this PR

AI generated PRs may be accepted, but only if @willmcgugan has responded on an issue or discussion.

Checklist

  • I've run the latest black with default args on new code.
  • I've updated CHANGELOG.md and CONTRIBUTORS.md where appropriate (see note about typos above).
  • I've added tests for new code.
  • I accept that @willmcgugan may be pedantic in the code review.

Description

Hi! I ran into an issue where rich tracebacks were spamming my logs with deeply nested items & found no way to reduce this.
This PR is a simple re-implementation of the accepted PR #3415 where the author did not respond to fix merge conflicts :)

Please see the above mentioned PR for information & background.
I simply moved over the changes

@DenShlk
Copy link

DenShlk commented Dec 12, 2025

almost made an exactly the same PR, haha

  1. Can I suggest to also pass those options to RichHandler for logs?
  2. I spotted some typos with 'overlow' instead of 'overflow'.
  3. we can add a test to check that we pass those params everywhere, but i guess it's alright without it
def test_locals_max_depth():
    console = Console(width=80, file=io.StringIO(), color_system=None)
    try:
        data = {"a": {"b": {"c": 1}}}
        1 / 0
    except Exception:
        exc_type, exc_value, tb = sys.exc_info()
        traceback = Traceback.from_exception(
            exc_type,
            exc_value,
            tb,
            show_locals=True,
            locals_max_depth=1,
        )
        console.print(traceback)
    exception_text = console.file.getvalue()
    assert "data = {'a': {...}}" in exception_text

I can help to add those changes, but I'm not sure what's the best way to do it, I guess i need to create a new PR based on this one?

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

Successfully merging this pull request may close these issues.

2 participants