From 3d3a52d07fdd6495a7d1126d887efaff25f27221 Mon Sep 17 00:00:00 2001 From: Bruno Dufour Date: Mon, 26 Aug 2024 15:47:47 -0400 Subject: [PATCH] Addressed PR comments --- .../codegen/setup/native_app_setup_processor.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/snowflake/cli/_plugins/nativeapp/codegen/setup/native_app_setup_processor.py b/src/snowflake/cli/_plugins/nativeapp/codegen/setup/native_app_setup_processor.py index 928cd6eb88..fc80246622 100644 --- a/src/snowflake/cli/_plugins/nativeapp/codegen/setup/native_app_setup_processor.py +++ b/src/snowflake/cli/_plugins/nativeapp/codegen/setup/native_app_setup_processor.py @@ -50,6 +50,22 @@ def safe_set(d: dict, *keys: str, **kwargs) -> None: + """ + Sets a value in a nested dictionary structure, creating intermediate dictionaries as needed. + Sample usage: + + d = {} + safe_set(d, "a", "b", "c", value=42) + + d is now: + { + "a": { + "b": { + "c": 42 + } + } + } + """ curr = d for k in keys[:-1]: curr = curr.setdefault(k, {})