From 21fd1c8b8014e0186e3b33310b268f8bd58a20b3 Mon Sep 17 00:00:00 2001 From: Zsolt Cserna Date: Sat, 17 May 2025 12:37:59 +0200 Subject: [PATCH] python: Fix highlighting of built-in types for `isinstance` and `issubclass` (#30807) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When built-in types such as `list` is specified in calls like `isinstance()`, the parameter is highlighted as a type. The issue is caused by a change which removed `list` and others in bf9e5b4f761b507310d744553e29ba6fdeb3c89a. This commit makes two special cases for `isinstance` and `issubclass` ensuring tree sitter to highlight the parameters correctly. Fixes #30331 Release Notes: - python: Fixed syntax highlighting for `isinstance()` and `issubclass()` calls Co-authored-by: László Vaskó <1771332+vlaci@users.noreply.github.com> --- crates/languages/src/python/highlights.scm | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/crates/languages/src/python/highlights.scm b/crates/languages/src/python/highlights.scm index ffc1c5633c..02f1a57a88 100644 --- a/crates/languages/src/python/highlights.scm +++ b/crates/languages/src/python/highlights.scm @@ -52,6 +52,20 @@ (function_definition name: (identifier) @function.definition) +((call + function: (identifier) @_isinstance + arguments: (argument_list + (_) + (identifier) @type)) + (#eq? @_isinstance "isinstance")) + +((call + function: (identifier) @_issubclass + arguments: (argument_list + (identifier) @type + (identifier) @type)) + (#eq? @_issubclass "issubclass")) + ; Function arguments (function_definition parameters: (parameters