@@ -194,7 +194,6 @@ def __init__(
194194 defaults_file : str | None = None ,
195195 login_path : str | None = None ,
196196 auto_vertical_output : bool = False ,
197- show_warnings : bool = False ,
198197 warn : bool | None = None ,
199198 myclirc : str = "~/.myclirc" ,
200199 ) -> None :
@@ -277,7 +276,7 @@ def __init__(
277276
278277 # read from cli argument or user config file
279278 self .auto_vertical_output = auto_vertical_output or c ["main" ].as_bool ("auto_vertical_output" )
280- self .show_warnings = show_warnings or c ["main" ].as_bool ("show_warnings" )
279+ self .show_warnings = c ["main" ].as_bool ("show_warnings" )
281280
282281 # Write user config if system config wasn't the last config loaded.
283282 if c .filename not in self .system_config_files and not os .path .exists (myclirc ):
@@ -608,6 +607,7 @@ def connect(
608607 use_keyring : bool | None = None ,
609608 reset_keyring : bool | None = None ,
610609 keepalive_ticks : int | None = None ,
610+ show_warnings : bool | None = None ,
611611 ) -> None :
612612 cnf = {
613613 "database" : None ,
@@ -637,6 +637,8 @@ def connect(
637637 ssl_config : dict [str , Any ] = ssl or {}
638638 user_connection_config = self .config_without_package_defaults .get ('connection' , {})
639639 self .keepalive_ticks = keepalive_ticks
640+ if show_warnings is not None :
641+ self .show_warnings = show_warnings
640642
641643 int_port = port and int (port )
642644 if not int_port :
@@ -2093,9 +2095,10 @@ class CliArgs:
20932095 is_flag = True ,
20942096 help = 'Automatically switch to vertical output mode if the result is wider than the terminal width.' ,
20952097 )
2096- show_warnings : bool = clickdc .option (
2098+ show_warnings : bool | None = clickdc .option (
20972099 '--show-warnings/--no-show-warnings' ,
20982100 is_flag = True ,
2101+ default = None ,
20992102 clickdc = None ,
21002103 help = 'Automatically show warnings after executing a SQL statement.' ,
21012104 )
@@ -2517,10 +2520,6 @@ def get_password_from_file(password_file: str | None) -> str | None:
25172520
25182521 combined_init_cmd = "; " .join (cmd .strip () for cmd in init_cmds if cmd )
25192522
2520- # --show-warnings / --no-show-warnings
2521- if cli_args .show_warnings :
2522- mycli .show_warnings = cli_args .show_warnings
2523-
25242523 if cli_args .use_keyring is not None and cli_args .use_keyring .lower () == 'reset' :
25252524 use_keyring = True
25262525 reset_keyring = True
@@ -2627,6 +2626,7 @@ def get_password_from_file(password_file: str | None) -> str | None:
26272626 use_keyring = use_keyring ,
26282627 reset_keyring = reset_keyring ,
26292628 keepalive_ticks = keepalive_ticks ,
2629+ show_warnings = cli_args .show_warnings ,
26302630 )
26312631
26322632 if combined_init_cmd :
0 commit comments