refactor(python): change fallback_names to default_venv_names

This commit is contained in:
Antonin Ruan 2024-10-07 17:46:50 -10:00 committed by Jan De Dobbeleer
parent daea52598c
commit 026fa16145
4 changed files with 11 additions and 11 deletions

View file

@ -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",
})

View file

@ -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)

View file

@ -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",

View file

@ -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])