2121from typing import Any , Callable , List , Tuple , TypeVar , Union
2222import yaml
2323
24-
2524_logger = logging .getLogger (__name__ )
2625
2726
@@ -96,7 +95,9 @@ def parser_wrapper(*args: Any, **kwargs: Any) -> Any:
9695 parsed_config : dict [str , Any ] = convert_login_customer_id_to_str (
9796 config_dict
9897 )
99- parsed_config : dict [str , Any ] = convert_linked_customer_id_to_str (parsed_config )
98+ parsed_config : dict [str , Any ] = convert_linked_customer_id_to_str (
99+ parsed_config
100+ )
100101
101102 config_keys : List [str ] = parsed_config .keys ()
102103
@@ -106,7 +107,9 @@ def parser_wrapper(*args: Any, **kwargs: Any) -> Any:
106107 # that needs to be returned by this method.
107108 if type (logging_config ) is not dict :
108109 try :
109- parsed_config ["logging" ]: dict [str , Any ] = json .loads (logging_config )
110+ parsed_config ["logging" ]: dict [str , Any ] = json .loads (
111+ logging_config
112+ )
110113 # The logger is configured here in case deprecation warnings
111114 # need to be logged further down in this method. The logger
112115 # is otherwise configured by the GoogleAdsClient class.
@@ -159,7 +162,9 @@ def parser_wrapper(*args: Any, **kwargs: Any) -> Any:
159162 # the string "False" is truthy and can easily be incorrectly
160163 # converted to the boolean True.
161164 value : Union [str , bool ] = parsed_config .get ("use_proto_plus" , False )
162- parsed_config ["use_proto_plus" ]: bool = disambiguate_string_bool (value )
165+ parsed_config ["use_proto_plus" ]: bool = disambiguate_string_bool (
166+ value
167+ )
163168
164169 if "use_application_default_credentials" in config_keys :
165170 # When loaded from YAML, YAML string or a dict, this value is
@@ -168,8 +173,12 @@ def parser_wrapper(*args: Any, **kwargs: Any) -> Any:
168173 # variable we need to manually change it to the bool False because
169174 # the string "False" is truthy and can easily be incorrectly
170175 # converted to the boolean True.
171- value : Union [str , bool ] = parsed_config .get ("use_application_default_credentials" , False )
172- parsed_config ["use_application_default_credentials" ]: bool = disambiguate_string_bool (value )
176+ value : Union [str , bool ] = parsed_config .get (
177+ "use_application_default_credentials" , False
178+ )
179+ parsed_config ["use_application_default_credentials" ]: bool = (
180+ disambiguate_string_bool (value )
181+ )
173182
174183 return parsed_config
175184
@@ -205,10 +214,16 @@ def validate_dict(config_data: dict[str, Any]) -> None:
205214 "found. The required fields are: {}" .format (str (_REQUIRED_KEYS ))
206215 )
207216
208- if "login_customer_id" in config_data :
217+ if (
218+ "login_customer_id" in config_data
219+ and config_data ["login_customer_id" ] is not None
220+ ):
209221 validate_login_customer_id (str (config_data ["login_customer_id" ]))
210222
211- if "linked_customer_id" in config_data :
223+ if (
224+ "linked_customer_id" in config_data
225+ and config_data ["linked_customer_id" ] is not None
226+ ):
212227 validate_linked_customer_id (str (config_data ["linked_customer_id" ]))
213228
214229
@@ -380,7 +395,7 @@ def get_oauth2_required_service_account_keys() -> tuple[str, ...]:
380395
381396
382397def convert_login_customer_id_to_str (
383- config_data : dict [str , Any ]
398+ config_data : dict [str , Any ],
384399) -> dict [str , Any ]:
385400 """Parses a config dict's login_customer_id attr value to a str.
386401
@@ -403,7 +418,7 @@ def convert_login_customer_id_to_str(
403418
404419
405420def convert_linked_customer_id_to_str (
406- config_data : dict [str , Any ]
421+ config_data : dict [str , Any ],
407422) -> dict [str , Any ]:
408423 """Parses a config dict's linked_customer_id attr value to a str.
409424
0 commit comments