Skip to content

Commit

Permalink
Check "if not None" for not set args instead of bool way is more precise
Browse files Browse the repository at this point in the history
  • Loading branch information
amochin committed Sep 25, 2024
1 parent f93f1cd commit 166befa
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/DatabaseLibrary/connection_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,9 @@ def _log_all_connection_params(*, connection_object=None, connection_string=None

def _arg_or_config(arg_value, param_name, mandatory=False):
val_from_config = config.pop(param_name)
if arg_value:
if arg_value is not None:
final_value = arg_value
if val_from_config:
if val_from_config is not None:
logger.info(
f"Parameter '{param_name}' set both as keyword argument and in config file, "
"but keyword arguments take precedence"
Expand All @@ -266,7 +266,7 @@ def _arg_or_config(arg_value, param_name, mandatory=False):
dbPassword = _arg_or_config(dbPassword, "dbPassword")
dbHost = _arg_or_config(dbHost, "dbHost")
dbPort = _arg_or_config(dbPort, "dbPort")
if dbPort:
if dbPort is not None:
dbPort = int(dbPort)
dbCharset = _arg_or_config(dbCharset, "dbCharset")
dbDriver = _arg_or_config(dbDriver, "dbDriver")
Expand Down

0 comments on commit 166befa

Please sign in to comment.