zed/crates/grammars
Torbjørn Lium 6a37cc1173
Add Python runnable for __name__ in ("__main__",) pattern (#58911)
The gutter run button for Python's main guard only appears for `if
__name__ == "__main__":` but not for the alternative membership test
pattern `if __name__ in ("__main__", "__builtin__", "builtins"):`.

This adds a second Tree-sitter query in `runnables.scm` that matches the
`in` variant. It emits the same `python-module-main-method` tag, so both
patterns get the same gutter icon and task behavior.

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 adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [x] Tests cover the new/changed behavior (No dedicated tests for the
Python runnables queries exist. The build passes cleanly)
- [x] Performance impact has been considered and is acceptable

Closes #58909

Release Notes:

- Fixed Python run button not appearing in the gutter for `if __name__
in ("__main__", ...)` style main guards.

Co-authored-by: Finn Evers <finn@zed.dev>
2026-08-19 22:16:44 +00:00
..
src Add Python runnable for __name__ in ("__main__",) pattern (#58911) 2026-08-19 22:16:44 +00:00
Cargo.toml language_core: Represent supported queries using an enum (#62707) 2026-08-19 16:26:14 +00:00
LICENSE-GPL