From 026fa161450c1a877cec2333da8ec9c04700de92 Mon Sep 17 00:00:00 2001 From: Antonin Ruan Date: Mon, 7 Oct 2024 17:46:50 -1000 Subject: [PATCH] refactor(python): change fallback_names to default_venv_names --- src/segments/python.go | 4 ++-- src/segments/python_test.go | 8 ++++---- themes/schema.json | 6 +++--- website/docs/segments/languages/python.mdx | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/segments/python.go b/src/segments/python.go index 7409afc2..25b96dfd 100644 --- a/src/segments/python.go +++ b/src/segments/python.go @@ -22,7 +22,7 @@ const ( FetchVirtualEnv properties.Property = "fetch_virtual_env" UsePythonVersionFile properties.Property = "use_python_version_file" FolderNameFallback properties.Property = "folder_name_fallback" - FallbackNames properties.Property = "fallback_names" + DefaultVenvNames properties.Property = "default_venv_names" ) func (p *Python) Template() string { @@ -82,7 +82,7 @@ func (p *Python) loadContext() { } folderNameFallback := p.language.props.GetBool(FolderNameFallback, true) - defaultVenvNames := p.language.props.GetStringArray(FallbackNames, []string{ + defaultVenvNames := p.language.props.GetStringArray(DefaultVenvNames, []string{ ".venv", "venv", }) diff --git a/src/segments/python_test.go b/src/segments/python_test.go index 5c00a7e5..16066def 100644 --- a/src/segments/python_test.go +++ b/src/segments/python_test.go @@ -203,19 +203,19 @@ func TestPythonVirtualEnvIgnoreCustomVenvNames(t *testing.T) { cases := []struct { Expected string FolderNameFallback bool - FallbackNames []string + DefaultVenvNames []string VirtualEnvName string }{ { Expected: "folder", FolderNameFallback: true, - FallbackNames: []string{"env"}, + DefaultVenvNames: []string{"env"}, VirtualEnvName: "/path/to/folder/env", }, { Expected: "venv", FolderNameFallback: true, - FallbackNames: []string{"env"}, + DefaultVenvNames: []string{"env"}, VirtualEnvName: "/path/to/folder/venv", }, } @@ -235,7 +235,7 @@ func TestPythonVirtualEnvIgnoreCustomVenvNames(t *testing.T) { env.On("HasParentFilePath", ".python-version", false).Return(&runtime.FileInfo{}, errors.New("no match at root level")) props[FolderNameFallback] = tc.FolderNameFallback - props[FallbackNames] = tc.FallbackNames + props[DefaultVenvNames] = tc.DefaultVenvNames python := &Python{} python.Init(props, env) diff --git a/themes/schema.json b/themes/schema.json index 54564846..5d409438 100644 --- a/themes/schema.json +++ b/themes/schema.json @@ -2657,12 +2657,12 @@ "folder_name_fallback": { "type": "boolean", "title": "Folder Name Fallback", - "description": "Replace virtual environment names in fallback_names list with parent folder name", + "description": "Replace virtual environment names in default_venv_names list with parent folder name", "default": "true" }, - "fallback_names": { + "default_venv_names": { "type": "array", - "title": "Fallback Names", + "title": "Default Venv Names", "description": "Names to replace when folder_name_fallback is true", "default": [ ".venv", diff --git a/website/docs/segments/languages/python.mdx b/website/docs/segments/languages/python.mdx index e58ed168..ee6143cb 100644 --- a/website/docs/segments/languages/python.mdx +++ b/website/docs/segments/languages/python.mdx @@ -38,8 +38,8 @@ import Config from "@site/src/components/Config.js"; | `extensions` | `[]string` | `*.py, *.ipynb, pyproject.toml, venv.bak` | allows to override the default list of file extensions to validate | | `folders` | `[]string` | | allows to override the list of folder names to validate | | `cache_version` | `boolean` | `false` | cache the executable's version or not | -| `folder_name_fallback` | `boolean` | `true` | instead of `fallback_names` (case sensitive), use the parent folder name as the virtual environment's name or not | -| `fallback_names` | `[]string` | `.venv, venv` | allows to override the list of environment's name replaced when `folder_name_fallback` is `true` | +| `folder_name_fallback` | `boolean` | `true` | instead of `default_venv_names` (case sensitive), use the parent folder name as the virtual environment's name or not | +| `default_venv_names` | `[]string` | `.venv, venv` | allows to override the list of environment's name replaced when `folder_name_fallback` is `true` | ## Template ([info][templates])