fix(python): align python_binary schema with argument support (#7415)

This commit is contained in:
Martim Lobao
2026-04-30 20:07:59 +01:00
committed by GitHub
parent 53270fb3f6
commit 3ec9b5c54c
3 changed files with 65 additions and 14 deletions
+26 -4
View File
@@ -4031,10 +4031,16 @@ By default, the module will be shown if any of the following conditions are met:
| `disabled` | `false` | Disables the `python` module. |
> [!TIP]
> The `python_binary` variable accepts either a string or a list of strings.
> Starship will try executing each binary until it gets a result. Note you can
> only change the binary that Starship executes to get the version of Python not
> the arguments that are used.
> The `python_binary` variable accepts either:
>
> - a string (e.g. `'python3'`),
> - a list of strings (e.g. `['python', 'python3']`)
> - a list of lists of strings, representing commands with optional arguments (e.g.
> `[['mise', 'exec', '--', 'python'], ['python3']]`)
>
> Starship will try executing each configured command until it gets a result.
> Note you can only change the binary that Starship executes to get the version
> of Python not the arguments that are used.
>
> The default values and order for `python_binary` was chosen to first identify
> the Python version in a virtualenv/conda environments (which currently still
@@ -4076,6 +4082,22 @@ python_binary = 'python3'
```toml
# ~/.config/starship.toml
[python]
# Use `mise` to get the version.
python_binary = [['mise', 'exec', '--', 'python']]
```
```toml
# ~/.config/starship.toml
[python]
# Potentially dangerous: `uv` can run any binary at `.venv/bin/python` without interaction
python_binary = [['uv', 'run', '--no-python-downloads', '--no-project', 'python']]
```
```toml
# ~/.config/starship.toml
[python]
# Don't trigger for files with the py extension
detect_extensions = []