1717except ImportError :
1818 from sqlite3 import OperationalError , sqlite_version
1919from time import time
20- from typing import Any , Iterable , Optional , Dict
20+ from typing import Any , Iterable
2121
2222import click
2323import sqlparse
@@ -66,12 +66,12 @@ class LiteCli(object):
6666
6767 def __init__ (
6868 self ,
69- sqlexecute : Optional [ SQLExecute ] = None ,
70- prompt : Optional [ str ] = None ,
71- logfile : Optional [ Any ] = None ,
69+ sqlexecute : SQLExecute | None = None ,
70+ prompt : str | None = None ,
71+ logfile : Any | None = None ,
7272 auto_vertical_output : bool = False ,
73- warn : Optional [ bool ] = None ,
74- liteclirc : Optional [ str ] = None ,
73+ warn : bool | None = None ,
74+ liteclirc : str | None = None ,
7575 ) -> None :
7676 self .sqlexecute = sqlexecute
7777 self .logfile = logfile
@@ -190,7 +190,7 @@ def change_table_format(self, arg: str, **_: Any):
190190 msg += "\n \t {}" .format (table_type )
191191 yield (None , None , None , msg )
192192
193- def change_db (self , arg : Optional [ str ] , ** _ : Any ):
193+ def change_db (self , arg : str | None , ** _ : Any ):
194194 if arg is None :
195195 self .sqlexecute .connect ()
196196 else :
@@ -204,7 +204,7 @@ def change_db(self, arg: Optional[str], **_: Any):
204204 'You are now connected to database "%s"' % (self .sqlexecute .dbname ),
205205 )
206206
207- def execute_from_file (self , arg : Optional [ str ] , ** _ : Any ):
207+ def execute_from_file (self , arg : str | None , ** _ : Any ):
208208 if not arg :
209209 message = "Missing required argument, filename."
210210 return [(None , None , None , message )]
@@ -220,7 +220,7 @@ def execute_from_file(self, arg: Optional[str], **_: Any):
220220
221221 return self .sqlexecute .run (query )
222222
223- def change_prompt_format (self , arg : Optional [ str ] , ** _ : Any ):
223+ def change_prompt_format (self , arg : str | None , ** _ : Any ):
224224 """
225225 Change the prompt format.
226226 """
@@ -279,7 +279,7 @@ def initialize_logging(self) -> None:
279279 root_logger .debug ("Initializing litecli logging." )
280280 root_logger .debug ("Log file %r." , log_file )
281281
282- def read_my_cnf_files (self , keys : Iterable [str ]) -> Dict [str , Optional [ str ] ]:
282+ def read_my_cnf_files (self , keys : Iterable [str ]) -> dict [str , str | None ]:
283283 """
284284 Reads a list of config files and merges them. The last one will win.
285285 :param files: list of files to read
@@ -661,7 +661,7 @@ def echo(self, s: str, **kwargs: Any) -> None:
661661 self .log_output (s )
662662 click .secho (s , ** kwargs )
663663
664- def get_output_margin (self , status : Optional [ str ] = None ) -> int :
664+ def get_output_margin (self , status : str | None = None ) -> int :
665665 """Get the output margin (number of rows for the prompt, footer and
666666 timing message."""
667667 margin = self .get_reserved_space () + self .get_prompt (self .prompt_format ).count ("\n " ) + 2
@@ -670,7 +670,7 @@ def get_output_margin(self, status: Optional[str] = None) -> int:
670670
671671 return margin
672672
673- def output (self , output : Iterable [str ], status : Optional [ str ] = None ) -> None :
673+ def output (self , output : Iterable [str ], status : str | None = None ) -> None :
674674 """Output text to stdout or a pager command.
675675
676676 The status text is not outputted to pager or files.
0 commit comments