Skip to content

Commit

Permalink
pylint
Browse files Browse the repository at this point in the history
  • Loading branch information
bencrabtree committed Aug 13, 2024
1 parent 80ab347 commit 095fb6c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/sagemaker/jumpstart/hub/parser_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ def snake_to_upper_camel(snake_case_string: str) -> str:


def walk_and_apply_json(
json_obj: Dict[Any, Any], apply, stop_keys: Optional[List[str]] = []
json_obj: Dict[Any, Any], apply, stop_keys: Optional[List[str]] = None
) -> Dict[Any, Any]:
"""Recursively walks a json object and applies a given function to the keys.
stop_keys (Optional[list[str]]): List of field keys that should stop the application function. Any
children of these keys will not have the application function applied to them.
stop_keys (Optional[list[str]]): List of field keys that should stop the application function.
Any children of these keys will not have the application function applied to them.
"""

def _walk_and_apply_json(json_obj, new):
if isinstance(json_obj, dict) and isinstance(new, dict):
for key, value in json_obj.items():
new_key = apply(key)
if new_key not in stop_keys:
if stop_keys and new_key not in stop_keys:
if isinstance(value, dict):
new[new_key] = {}
_walk_and_apply_json(value, new=new[new_key])
Expand Down

0 comments on commit 095fb6c

Please sign in to comment.