Skip to content

Commit bbc448d

Browse files
committed
refactor: improve PathData logging and type hints
- Add debug logs for set_value and get_value methods - Fix type hint for create_value_fn using Callable from typing - Format function signature for better readability The debug logs follow the Helm plugin convention and provide better observability for value operations. Type hints now properly specify the function signature for create_value_fn.
1 parent c547cb6 commit bbc448d

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

helm_values_manager/models/path_data.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
metadata and values associated with a specific configuration path.
66
"""
77

8-
from typing import Any, Dict, Iterator, Optional
8+
from typing import Any, Callable, Dict, Iterator, Optional
99

1010
from helm_values_manager.models.value import Value
1111
from helm_values_manager.utils.logger import logger
@@ -61,6 +61,7 @@ def set_value(self, environment: str, value: Value) -> None:
6161
environment (str): The environment to set the value for
6262
value (Value): The Value object to set
6363
"""
64+
logger.debug("Setting value for path %s in environment %s", self.path, environment)
6465
self._values[environment] = value
6566

6667
def get_value(self, environment: str, resolve: bool = False) -> Optional[str]:
@@ -74,8 +75,10 @@ def get_value(self, environment: str, resolve: bool = False) -> Optional[str]:
7475
Returns:
7576
Optional[str]: The value if found, None otherwise
7677
"""
78+
logger.debug("Getting value for path %s in environment %s", self.path, environment)
7779
value = self._values.get(environment)
7880
if value is None:
81+
logger.debug("No value found for path %s in environment %s", self.path, environment)
7982
return None
8083

8184
return value.get(resolve=resolve)
@@ -103,13 +106,15 @@ def to_dict(self) -> Dict[str, Any]:
103106
}
104107

105108
@classmethod
106-
def from_dict(cls, data: Dict[str, Any], create_value_fn: callable) -> "PathData":
109+
def from_dict(
110+
cls, data: Dict[str, Any], create_value_fn: Callable[[str, str, Dict[str, Any]], Value]
111+
) -> "PathData":
107112
"""
108113
Create a PathData instance from a dictionary.
109114
110115
Args:
111116
data (Dict[str, Any]): Dictionary containing PathData data
112-
create_value_fn: Function to create Value instances
117+
create_value_fn: Function to create Value instances. Takes (path, env, value_data) and returns Value
113118
114119
Returns:
115120
PathData: New PathData instance

0 commit comments

Comments
 (0)