diff --git a/.github/config-schema.json b/.github/config-schema.json index 2c01b2d3..b9ec08e2 100644 --- a/.github/config-schema.json +++ b/.github/config-schema.json @@ -1419,7 +1419,8 @@ "VIRTUAL_ENV" ], "detect_extensions": [ - "py" + "py", + "ipynb" ], "detect_files": [ "requirements.txt", @@ -1428,7 +1429,8 @@ "Pipfile", "tox.ini", "setup.py", - "__init__.py" + "__init__.py", + "pixi.toml" ], "detect_folders": [], "disabled": false, @@ -5298,7 +5300,8 @@ }, "detect_extensions": { "default": [ - "py" + "py", + "ipynb" ], "type": "array", "items": { @@ -5313,7 +5316,8 @@ "Pipfile", "tox.ini", "setup.py", - "__init__.py" + "__init__.py", + "pixi.toml" ], "type": "array", "items": { @@ -6548,4 +6552,4 @@ ] } } -} +} \ No newline at end of file diff --git a/docs/config/README.md b/docs/config/README.md index b64d0ec0..b5ab46b5 100644 --- a/docs/config/README.md +++ b/docs/config/README.md @@ -3688,25 +3688,26 @@ By default, the module will be shown if any of the following conditions are met: - The current directory contains a `requirements.txt` file - The current directory contains a `setup.py` file - The current directory contains a `tox.ini` file +- The current directory contains a `pixi.toml` file - The current directory contains a file with the `.py` extension. +- The current directory contains a file with the `.ipynb` extension. - A virtual environment is currently activated ### Options -| Option | Default | Description | -| -------------------- | ------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------- | -| `format` | `'via [${symbol}${pyenv_prefix}(${version} )(\($virtualenv\) )]($style)'` | The format for the module. | -| `version_format` | `'v${raw}'` | The version format. Available vars are `raw`, `major`, `minor`, & `patch` | -| `symbol` | `'🐍 '` | A format string representing the symbol of Python | -| `style` | `'yellow bold'` | The style for the module. | -| `pyenv_version_name` | `false` | Use pyenv to get Python version | -| `pyenv_prefix` | `'pyenv'` | Prefix before pyenv version display, only used if pyenv is used | -| `python_binary` | `['python', 'python3', 'python2']` | Configures the python binaries that Starship should executes when getting the version. | -| `detect_extensions` | `['py']` | Which extensions should trigger this module | -| `detect_files` | `['.python-version', 'Pipfile', '__init__.py', 'pyproject.toml', 'requirements.txt', 'setup.py', 'tox.ini']` | Which filenames should trigger this module | -| `detect_folders` | `[]` | Which folders should trigger this module | -| `detect_env_vars` | `["VIRTUAL_ENV"]` | Which environmental variables should trigger this module | -| `disabled` | `false` | Disables the `python` module. | +| Option | Default | Description | +| -------------------- | ------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | +| `format` | `'via [${symbol}${pyenv_prefix}(${version} )(\($virtualenv\) )]($style)'` | The format for the module. | +| `version_format` | `'v${raw}'` | The version format. Available vars are `raw`, `major`, `minor`, & `patch` | +| `symbol` | `'🐍 '` | A format string representing the symbol of Python | +| `style` | `'yellow bold'` | The style for the module. | +| `pyenv_version_name` | `false` | Use pyenv to get Python version | +| `pyenv_prefix` | `'pyenv'` | Prefix before pyenv version display, only used if pyenv is used | +| `python_binary` | `['python', 'python3', 'python2']` | Configures the python binaries that Starship should executes when getting the version. | +| `detect_extensions` | `['py', 'ipynb']` | Which extensions should trigger this module | +| `detect_files` | `['.python-version', 'Pipfile', '__init__.py', 'pyproject.toml', 'requirements.txt', 'setup.py', 'tox.ini', 'pixi.toml']` | Which filenames should trigger this module | +| `detect_folders` | `[]` | Which folders should trigger this module | +| `disabled` | `false` | Disables the `python` module. | ::: tip diff --git a/src/configs/python.rs b/src/configs/python.rs index 3654fa82..05043b35 100644 --- a/src/configs/python.rs +++ b/src/configs/python.rs @@ -35,7 +35,7 @@ impl<'a> Default for PythonConfig<'a> { style: "yellow bold", symbol: "🐍 ", disabled: false, - detect_extensions: vec!["py"], + detect_extensions: vec!["py", "ipynb"], detect_files: vec![ "requirements.txt", ".python-version", @@ -44,6 +44,7 @@ impl<'a> Default for PythonConfig<'a> { "tox.ini", "setup.py", "__init__.py", + "pixi.toml", ], detect_folders: vec![], detect_env_vars: vec!["VIRTUAL_ENV"], diff --git a/src/modules/python.rs b/src/modules/python.rs index d531362b..5b4701e3 100644 --- a/src/modules/python.rs +++ b/src/modules/python.rs @@ -279,6 +279,30 @@ Python 3.7.9 (7e6e2bb30ac5fbdbd443619cae28c51d5c162a02, Nov 24 2020, 10:03:59) dir.close() } + #[test] + fn folder_with_pixi_file() -> io::Result<()> { + let dir = tempfile::tempdir()?; + File::create(dir.path().join("pixi.toml"))?.sync_all()?; + + check_python2_renders(&dir, None); + check_python3_renders(&dir, None); + check_pyenv_renders(&dir, None); + check_multiple_binaries_renders(&dir, None); + dir.close() + } + + #[test] + fn folder_with_ipynb_file() -> io::Result<()> { + let dir = tempfile::tempdir()?; + File::create(dir.path().join("notebook.ipynb"))?.sync_all()?; + + check_python2_renders(&dir, None); + check_python3_renders(&dir, None); + check_pyenv_renders(&dir, None); + check_multiple_binaries_renders(&dir, None); + dir.close() + } + #[test] fn disabled_scan_for_pyfiles_and_folder_with_ignored_py_file() -> io::Result<()> { let dir = tempfile::tempdir()?;