Skip to content

Commit 2c434ec

Browse files
committed
fix: improve code quality
- Fix mutable default argument in PathData - Add proper Optional type annotation - Improve debug value handling in logger - Add explicit default for HELM_DEBUG - Simplify debug logic for better readability
1 parent 0667442 commit 2c434ec

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

helm_values_manager/models/path_data.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
class PathData:
1616
"""Manages metadata and values for a configuration path."""
1717

18-
def __init__(self, path: str, metadata: Dict[str, Any] = {}):
18+
def __init__(self, path: str, metadata: Optional[Dict[str, Any]] = None):
1919
"""
2020
Initialize PathData with a path and metadata.
2121
@@ -24,6 +24,8 @@ def __init__(self, path: str, metadata: Dict[str, Any] = {}):
2424
metadata: Dictionary containing metadata for the path
2525
"""
2626
self.path = path
27+
if metadata is None:
28+
metadata = {}
2729
self._metadata = ConfigMetadata(
2830
description=metadata.get("description", ConfigMetadata.DEFAULT_DESCRIPTION),
2931
required=metadata.get("required", ConfigMetadata.DEFAULT_REQUIRED),

helm_values_manager/utils/logger.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ def debug(msg: str, *args: Any) -> None:
3030
msg: Message with optional string format placeholders
3131
args: Values to substitute in the message
3232
"""
33-
debug_val = os.environ.get("HELM_DEBUG", "").lower()
34-
if debug_val and debug_val not in ("0", "false"):
35-
if args:
36-
msg = msg % args
37-
print("[debug] %s" % msg, file=sys.stderr)
33+
debug_val = os.environ.get("HELM_DEBUG", "false").lower()
34+
if debug_val in ("0", "false"):
35+
return
36+
if args:
37+
msg = msg % args
38+
print("[debug] %s" % msg, file=sys.stderr)
3839

3940
@staticmethod
4041
def error(msg: str, *args: Any) -> None:

0 commit comments

Comments
 (0)