← mined_oracle

rich_2133

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
@@ -17,7 +17,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 
 ### Fixed
 
-- Add missing `end` keyword argument to `Text.from_markup`
+- Add missing `end` keyword argument to `Text.from_markup` https://github.com/Textualize/rich/pull/2095
+- Fallback to text lexer when no lexer guessed https://github.com/Textualize/rich/pull/2133
 - Fixed issue with decoding ANSI reset https://github.com/Textualize/rich/issues/2112
 
 ## [12.0.1] - 2022-03-22
--- a/poetry.lock
+++ b/poetry.lock
@@ -1002,7 +1002,7 @@ python-versions = ">=3.6"
 
 [[package]]
 name = "virtualenv"
-version = "20.13.4"
+version = "20.14.0"
 description = "Virtual Python Environment builder"
 category = "dev"
 optional = false
@@ -1786,8 +1786,8 @@ typing-extensions = [
     {file = "typing_extensions-4.1.1.tar.gz", hash = "sha256:1a9462dcc3347a79b1f1c0271fbe79e844580bb598bafa1ed208b94da3cdcd42"},
 ]
 virtualenv = [
-    {file = "virtualenv-20.13.4-py2.py3-none-any.whl", hash = "sha256:c3e01300fb8495bc00ed70741f5271fc95fed067eb7106297be73d30879af60c"},
-    {file = "virtualenv-20.13.4.tar.gz", hash = "sha256:ce8901d3bbf3b90393498187f2d56797a8a452fb2d0d7efc6fd837554d6f679c"},
+    {file = "virtualenv-20.14.0-py2.py3-none-any.whl", hash = "sha256:1e8588f35e8b42c6ec6841a13c5e88239de1e6e4e4cedfd3916b306dc826ec66"},
+    {file = "virtualenv-20.14.0.tar.gz", hash = "sha256:8e5b402037287126e81ccde9432b95a8be5b19d36584f64957060a3488c11ca8"},
 ]
 wcwidth = [
     {file = "wcwidth-0.2.5-py2.py3-none-any.whl", hash = "sha256:beb4802a9cebb9144e99086eff703a642a13d6a0052920003a230f3294bbe784"},
--- a/rich/traceback.py
+++ b/rich/traceback.py
@@ -12,6 +12,7 @@ from pygments.lexers import guess_lexer_for_filename
 from pygments.token import Comment, Keyword, Name, Number, Operator, String
 from pygments.token import Text as TextToken
 from pygments.token import Token
+from pygments.util import ClassNotFound
 
 from . import pretty
 from ._loop import loop_last
@@ -521,10 +522,10 @@ class Traceback:
             first_line = code[:new_line_index] if new_line_index != -1 else code
             if first_line.startswith("#!") and "python" in first_line.lower():
                 return "python"
-        lexer_name = (
-            cls.LEXERS.get(ext) or guess_lexer_for_filename(filename, code).name
-        )
-        return lexer_name
+        try:
+            return cls.LEXERS.get(ext) or guess_lexer_for_filename(filename, code).name
+        except ClassNotFound:
+            return "text"
 
     @group()
     def _render_stack(self, stack: Stack) -> RenderResult:

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:247: AssertionError
!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!
1 failed, 14 passed in 0.65s