Skip to content

Commit 5040465

Browse files
committed
Fixing filter of internal attributes
1 parent 2e48890 commit 5040465

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

src/settings/_config_as_yaml.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ def filter_internal_attributes(data, internal_attributes, hide_internal_attr):
1717

1818
def clean_dict(data, sensitive_attributes, internal_attributes, hide_internal_attr):
1919
"""Clean a dictionary by masking sensitive attributes and filtering internal ones."""
20-
cleaned = {
20+
masked = {
2121
k: mask_sensitive_value(v, k, sensitive_attributes) for k, v in data.items()
2222
}
23-
return filter_internal_attributes(cleaned, internal_attributes, hide_internal_attr)
23+
return filter_internal_attributes(masked, internal_attributes, hide_internal_attr)
2424

2525

2626
def clean_list(obj, sensitive_attributes, internal_attributes, hide_internal_attr):
@@ -57,7 +57,8 @@ def clean_object(obj, sensitive_attributes, internal_attributes, hide_internal_a
5757
return clean_dict(
5858
vars(obj), sensitive_attributes, internal_attributes, hide_internal_attr
5959
)
60-
return mask_sensitive_value(obj, "", sensitive_attributes)
60+
61+
return obj
6162

6263

6364
def get_config_as_yaml(
@@ -92,13 +93,13 @@ def get_config_as_yaml(
9293

9394
# Process dict or class-like object config
9495
else:
95-
cleaned_obj = clean_object(
96-
obj,
97-
sensitive_attributes,
98-
internal_attributes,
99-
hide_internal_attr,
100-
)
101-
if cleaned_obj:
96+
if not key in internal_attributes and hide_internal_attr:
97+
cleaned_obj = clean_object(
98+
obj,
99+
sensitive_attributes,
100+
internal_attributes,
101+
hide_internal_attr,
102+
)
102103
config_output[key] = cleaned_obj
103104

104105
return yaml.dump(

src/settings/_constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def __init__(self):
1111
self.use_config_yaml = False # Overwritten later if config file exists
1212

1313
def config_as_yaml(self):
14-
return get_config_as_yaml(self.__dict__)
14+
return get_config_as_yaml(vars(self), internal_attributes={"in_docker"})
1515

1616

1717
class Paths:

0 commit comments

Comments
 (0)