← mined_oracle

rich_2226

failed WRONG_FIX UNSUBMITTED wrong_fix_unsubmitted(None) · None tool calls · 0 s · Textualize/rich

Task input

(not found in data/tasks.jsonl)

Tool calls (0)

#ToolArgumentsResult
No trace captured.

Patch

--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 - Ability to change terminal window title https://github.com/Textualize/rich/pull/2200
 - Added show_speed parameter to progress.track which will show the speed when the total is not known
+- Python blocks can now opt out from being rendered in tracebacks's frames, by setting a `_rich_traceback_omit = True` in their local scope https://github.com/Textualize/rich/issues/2207
 
 ### Fixed
 
--- a/rich/traceback.py
+++ b/rich/traceback.py
@@ -367,6 +367,8 @@ class Traceback:
                 if filename and not filename.startswith("<"):
                     if not os.path.isabs(filename):
                         filename = os.path.join(_IMPORT_CWD, filename)
+                if frame_summary.f_locals.get("_rich_traceback_omit", False):
+                    continue
                 frame = Frame(
                     filename=filename or "?",
                     lineno=line_no,
@@ -383,7 +385,7 @@ class Traceback:
                     else None,
                 )
                 append(frame)
-                if "_rich_traceback_guard" in frame_summary.f_locals:
+                if frame_summary.f_locals.get("_rich_traceback_guard", False):
                     del stack.frames[:]
 
             cause = getattr(exc_value, "__cause__", None)

Test output

show
..............F
=================================== FAILURES ===================================
___________________________ test_guess_lexer_yaml_j2 ___________________________

    def test_guess_lexer_yaml_j2():
        # https://github.com/Textualize/rich/issues/2018
        code = """\
    foobar:
        something: {{ raiser() }}
        else: {{ 5 + 5 }}
        """
>       assert Traceback._guess_lexer("test.yaml.j2", code) == "text"
E       AssertionError: assert 'YAML+Jinja' == 'text'
E         
E         - text
E         + YAML+Jinja

tests/test_traceback.py:280: AssertionError
=============================== warnings summary ===============================
tests/test_traceback.py:52
  /private/tmp/swe_work/mined_oracle/rich_2226/b/workspace/tests/test_traceback.py:52: SyntaxWarning: invalid escape sequence '\.'
    "^│ .+rich/tests/test_traceback\.py:",

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!
1 failed, 14 passed, 1 warning in 0.59s