From 3fd79f8a87577ea715db2ec95f59819a3bf1ac76 Mon Sep 17 00:00:00 2001 From: Alex Lachance Date: Sun, 31 May 2026 10:05:40 -0400 Subject: [PATCH 1/2] Added exception highlighting --- crates/grammars/src/python/highlights.scm | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/crates/grammars/src/python/highlights.scm b/crates/grammars/src/python/highlights.scm index 87283aaa799a15..9753689faffe87 100644 --- a/crates/grammars/src/python/highlights.scm +++ b/crates/grammars/src/python/highlights.scm @@ -344,3 +344,23 @@ "bool" "bytearray" "bytes" "complex" "dict" "float" "frozenset" "int" "list" "memoryview" "object" "range" "set" "slice" "str" "tuple") ] + +((identifier) @type.builtin + (#any-of? @type.builtin + ; Exceptions + "BaseException" "Exception" "ArithmeticError" "BufferError" "LookupError" "AssertionError" + "AttributeError" "EOFError" "FloatingPointError" "GeneratorExit" "ImportError" + "ModuleNotFoundError" "IndexError" "KeyError" "KeyboardInterrupt" "MemoryError" "NameError" + "NotImplementedError" "OSError" "OverflowError" "RecursionError" "ReferenceError" "RuntimeError" + "StopIteration" "StopAsyncIteration" "SyntaxError" "IndentationError" "TabError" "SystemError" + "SystemExit" "TypeError" "UnboundLocalError" "UnicodeError" "UnicodeEncodeError" + "UnicodeDecodeError" "UnicodeTranslateError" "ValueError" "ZeroDivisionError" "EnvironmentError" + "IOError" "WindowsError" "BlockingIOError" "ChildProcessError" "ConnectionError" + "BrokenPipeError" "ConnectionAbortedError" "ConnectionRefusedError" "ConnectionResetError" + "FileExistsError" "FileNotFoundError" "InterruptedError" "IsADirectoryError" + "NotADirectoryError" "PermissionError" "ProcessLookupError" "TimeoutError" "ExceptionGroup" + "BaseExceptionGroup" + ; Warnings + "Warning" "UserWarning" "DeprecationWarning" "PendingDeprecationWarning" + "SyntaxWarning" "RuntimeWarning" "FutureWarning" "ImportWarning" "UnicodeWarning" + "EncodingWarning" "BytesWarning" "ResourceWarning")) From 46f9c8b8fcf47a5cf8bc614b9a68fd97fc468fc8 Mon Sep 17 00:00:00 2001 From: Alex Lachance Date: Wed, 3 Jun 2026 18:14:07 -0400 Subject: [PATCH 2/2] Updated to @type.class.builtin and fixed list wrapping --- crates/grammars/src/python/highlights.scm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/grammars/src/python/highlights.scm b/crates/grammars/src/python/highlights.scm index 9753689faffe87..04e5787a19f17d 100644 --- a/crates/grammars/src/python/highlights.scm +++ b/crates/grammars/src/python/highlights.scm @@ -345,8 +345,8 @@ "object" "range" "set" "slice" "str" "tuple") ] -((identifier) @type.builtin - (#any-of? @type.builtin +((identifier) @type.class.builtin + (#any-of? @type.class.builtin ; Exceptions "BaseException" "Exception" "ArithmeticError" "BufferError" "LookupError" "AssertionError" "AttributeError" "EOFError" "FloatingPointError" "GeneratorExit" "ImportError" @@ -361,6 +361,6 @@ "NotADirectoryError" "PermissionError" "ProcessLookupError" "TimeoutError" "ExceptionGroup" "BaseExceptionGroup" ; Warnings - "Warning" "UserWarning" "DeprecationWarning" "PendingDeprecationWarning" - "SyntaxWarning" "RuntimeWarning" "FutureWarning" "ImportWarning" "UnicodeWarning" - "EncodingWarning" "BytesWarning" "ResourceWarning")) + "Warning" "UserWarning" "DeprecationWarning" "PendingDeprecationWarning" "SyntaxWarning" + "RuntimeWarning" "FutureWarning" "ImportWarning" "UnicodeWarning" "EncodingWarning" + "BytesWarning" "ResourceWarning"))