# python: Fix Python exception highlighting \(\#58176\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/3c0f5a04a6d64e07d24cf456212fe8c5d849a477)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 3c0f5a04a6d64e07d24cf456212fe8c5d849a477

Requested commit: 3c0f5a04a6d64e07d24cf456212fe8c5d849a477

Commit: 3c0f5a04a6d64e07d24cf456212fe8c5d849a477

Tree: 7480171b8df9a6a84fbd5dcf4e347a7b71c09cb0

Author: Alex Lachance

Committer: GitHub

## Message

```
python: Fix Python exception highlighting (#58176)

In the current Python Tree-sitter `highlights.scm`, exception
(https://docs.python.org/3/library/exceptions.html) are highlighted
under `@type.class` which is inconsistent compared to other editors (VS
Code, Neovim, Helix).

This PR adds `#any-of?` with a list of python's exceptions and highlight
them under `@type.builtin`.

| Before | After |
|
:---------------------------------------------------------------------------------------------------------------------------------:
|
:--------------------------------------------------------------------------------------------------------------------------------:
|
| <img width="1237" height="1160" alt="image"
src="https://github.com/user-attachments/assets/05e1ae34-7637-413a-9785-ad696c2bf751"
/> | <img width="1237" height="1154" alt="image"
src="https://github.com/user-attachments/assets/105c61ca-b6a7-4c26-acc8-3e300f044510"
/> |


Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [ ] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- Added the ability to stylize builtin python exceptions and warnings
using the `type.class.builtin` syntax capture.
```

## Parents

- [4278e5296d89d744c1cc9629e2c20d38af396681](https://git.cafe/gitcafe/zed/commit/4278e5296d89d744c1cc9629e2c20d38af396681?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/3c0f5a04a6d64e07d24cf456212fe8c5d849a477?format=markdown)
