python: Add support for uv run as the shebang line (#45881)

`uv run` can be used to specify a shebang for a Python script.

See:
https://docs.astral.sh/uv/guides/scripts/#using-a-shebang-to-create-an-executable-file

Release Notes:

- Added support for `uv run` in the shebang line to be interpreted as a
Python script
This commit is contained in:
flou
2025-12-31 01:54:05 +01:00
committed by GitHub
parent 963cb2c200
commit 6b3412232f

View File

@@ -1,7 +1,7 @@
name = "Python"
grammar = "python"
path_suffixes = ["py", "pyi", "mpy"]
first_line_pattern = '^#!.*\bpython[0-9.]*\b'
first_line_pattern = '^#!.*((\bpython[0-9.]*\b)|(\buv run\b))'
line_comments = ["# "]
autoclose_before = ";:.,=}])>"
brackets = [