Skip to content

Commit d1b7051

Browse files
committed
Refactor configuration handling by renaming ConfigFileKeysEnum to ConfigFileKeys and updating related references
1 parent b5796af commit d1b7051

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ By default, Toolit looks for a folder named `devtools` in the project root. You
4141

4242
```toml
4343
[toolit]
44-
devtools_folder = "tools" # Change "tools" to your desired folder name
44+
tools_folder = "tools"
4545
```
4646

4747
## Create the VS code tasks.json file

tests/configuration_loader_test.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import pytest
55
import pathlib
66
from toolit import config
7-
from toolit.constants import ConfigFileKeysEnum
7+
from toolit.constants import ConfigFileKeys
88

99

1010
def create_toml_file(path: pathlib.Path, data: dict) -> None:
@@ -84,14 +84,13 @@ def test_load_devtools_folder_returns_configured_path(monkeypatch: pytest.Monkey
8484
monkeypatch.setattr(
8585
config,
8686
"get_config_value",
87-
lambda key, default=None: folder if key == ConfigFileKeysEnum.TOOLS_FOLDER else default,
87+
lambda key, default=None: folder if key == ConfigFileKeys.TOOLS_FOLDER else default,
8888
)
8989
result: pathlib.Path = config.load_devtools_folder()
9090
assert str(result) == folder
9191

9292

93-
def test_load_devtools_folder_returns_default_path(monkeypatch: pytest.MonkeyPatch) -> None:
93+
def test_load_devtools_folder_returns_default_path() -> None:
9494
"""Test load_devtools_folder returns default folder path if not configured."""
95-
monkeypatch.setattr(config, "get_config_value", lambda key, default=None: None)
9695
result: pathlib.Path = config.load_devtools_folder()
97-
assert str(result) == ConfigFileKeysEnum.TOOLS_FOLDER_DEFAULT
96+
assert str(result) == ConfigFileKeys.TOOLS_FOLDER_DEFAULT

toolit/config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
import toml
1212
import pathlib
13-
from .constants import ConfigFileKeysEnum
13+
from .constants import ConfigFileKeys
1414
from functools import lru_cache
1515
from typing import Callable
1616

@@ -59,5 +59,5 @@ def get_config_value(key: str, default: str | None = None) -> str | None:
5959

6060
def load_devtools_folder() -> pathlib.Path:
6161
"""Load the tools folder path from configuration or use default."""
62-
folder = get_config_value(ConfigFileKeysEnum.TOOLS_FOLDER, ConfigFileKeysEnum.TOOLS_FOLDER_DEFAULT)
63-
return pathlib.Path(folder) if isinstance(folder, str) else pathlib.Path(ConfigFileKeysEnum.TOOLS_FOLDER_DEFAULT)
62+
folder = get_config_value(ConfigFileKeys.TOOLS_FOLDER, ConfigFileKeys.TOOLS_FOLDER_DEFAULT)
63+
return pathlib.Path(folder)

toolit/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
MARKER_TOOL = "__toolit_tool_type__"
66

77

8-
class ConfigFileKeysEnum:
8+
class ConfigFileKeys:
99
"""Namespace for the different configuration file keys for user configuration."""
1010

1111
TOOLS_FOLDER: str = "tools_folder"

0 commit comments

Comments
 (0)