183183
184184try :
185185 if sys .platform == "win32" :
186- from prompt_toolkit .output .win32 import NoConsoleScreenBufferError # type: ignore[attr-defined]
186+ from prompt_toolkit .output .win32 import NoConsoleScreenBufferError
187187 else :
188188 # Trigger the except block for non-Windows platforms
189189 raise ImportError # noqa: TRY301
190190except ImportError :
191191
192- class NoConsoleScreenBufferError (Exception ): # type: ignore[no-redef]
192+ class NoConsoleScreenBufferError (Exception ): # type: ignore[no-redef, unused-ignore ]
193193 """Dummy exception to use when prompt_toolkit.output.win32.NoConsoleScreenBufferError is not available."""
194194
195195 def __init__ (self , msg : str = "" ) -> None :
@@ -617,7 +617,7 @@ def __init__(
617617
618618 # Store initial termios settings to restore after each command.
619619 # This is a faster way of accomplishing what "stty sane" does.
620- self ._initial_termios_settings = None
620+ self ._initial_termios_settings : list [ Any ] | None = None
621621 if not sys .platform .startswith ("win" ) and self .stdin .isatty ():
622622 try :
623623 import io
@@ -1042,7 +1042,7 @@ def _build_parser(
10421042
10431043 # Verify the factory returned the required type
10441044 if not isinstance (parser , Cmd2ArgumentParser ):
1045- builder_name = getattr (parser_source , "__name__" , str (parser_source )) # type: ignore[unreachable]
1045+ builder_name = getattr (parser_source , "__name__" , str (parser_source ))
10461046 raise TypeError (
10471047 f"'{ builder_name } ' must return a 'Cmd2ArgumentParser' (or subclass). Received: '{ type (parser ).__name__ } '."
10481048 )
@@ -1982,8 +1982,8 @@ def ppaged(
19821982
19831983 # If the pager was killed (e.g. SIGKILL), the terminal might be in a bad state.
19841984 # Attempt to restore terminal settings and foreground process group.
1985- if self ._initial_termios_settings is not None and self .stdin .isatty (): # type: ignore[unreachable]
1986- try : # type: ignore[unreachable]
1985+ if not sys . platform . startswith ( "win" ) and self ._initial_termios_settings is not None and self .stdin .isatty ():
1986+ try :
19871987 import signal
19881988 import termios
19891989
@@ -3109,8 +3109,8 @@ def onecmd_plus_hooks(
31093109
31103110 def _run_cmdfinalization_hooks (self , stop : bool , statement : Statement | None ) -> bool :
31113111 """Run the command finalization hooks."""
3112- if self ._initial_termios_settings is not None and self .stdin .isatty (): # type: ignore[unreachable]
3113- import io # type: ignore[unreachable]
3112+ if not sys . platform . startswith ( "win" ) and self ._initial_termios_settings is not None and self .stdin .isatty ():
3113+ import io
31143114 import termios
31153115
31163116 # Before the next command runs, fix any terminal problems like those
@@ -3875,7 +3875,7 @@ def _build_alias_parser() -> Cmd2ArgumentParser:
38753875 "An alias is a command that enables replacement of a word by another string." ,
38763876 )
38773877 alias_parser = argparse_utils .DEFAULT_ARGUMENT_PARSER (description = alias_description )
3878- alias_parser .epilog = TextGroup ( # type: ignore[assignment] # ty: ignore[invalid-assignment]
3878+ alias_parser .epilog = TextGroup ( # ty: ignore[invalid-assignment]
38793879 "See Also" ,
38803880 "macro" ,
38813881 )
@@ -3907,7 +3907,7 @@ def _build_alias_create_parser(cls) -> Cmd2ArgumentParser:
39073907 "for the actual command the alias resolves to."
39083908 ),
39093909 )
3910- alias_create_parser .epilog = TextGroup ("Notes" , alias_create_notes ) # type: ignore[assignment] # ty: ignore[invalid-assignment]
3910+ alias_create_parser .epilog = TextGroup ("Notes" , alias_create_notes ) # ty: ignore[invalid-assignment]
39113911
39123912 # Add arguments
39133913 alias_create_parser .add_argument ("name" , help = "name of this alias" )
@@ -4089,7 +4089,7 @@ def _build_macro_parser() -> Cmd2ArgumentParser:
40894089 "A macro is similar to an alias, but it can contain argument placeholders." ,
40904090 )
40914091 macro_parser = argparse_utils .DEFAULT_ARGUMENT_PARSER (description = macro_description )
4092- macro_parser .epilog = TextGroup ( # type: ignore[assignment] # ty: ignore[invalid-assignment]
4092+ macro_parser .epilog = TextGroup ( # ty: ignore[invalid-assignment]
40934093 "See Also" ,
40944094 "alias" ,
40954095 )
@@ -4152,7 +4152,7 @@ def _build_macro_create_parser(cls) -> Cmd2ArgumentParser:
41524152 "This default behavior changes if custom completion for macro arguments has been implemented."
41534153 ),
41544154 )
4155- macro_create_parser .epilog = TextGroup ("Notes" , macro_create_notes ) # type: ignore[assignment] # ty: ignore[invalid-assignment]
4155+ macro_create_parser .epilog = TextGroup ("Notes" , macro_create_notes ) # ty: ignore[invalid-assignment]
41564156
41574157 # Add arguments
41584158 macro_create_parser .add_argument ("name" , help = "name of this macro" )
@@ -4648,7 +4648,7 @@ def do_shortcuts(self, _: argparse.Namespace) -> None:
46484648 @staticmethod
46494649 def _build__eof_parser () -> Cmd2ArgumentParser :
46504650 _eof_parser = argparse_utils .DEFAULT_ARGUMENT_PARSER (description = "Called when Ctrl-D is pressed." )
4651- _eof_parser .epilog = TextGroup ( # type: ignore[assignment] # ty: ignore[invalid-assignment]
4651+ _eof_parser .epilog = TextGroup ( # ty: ignore[invalid-assignment]
46524652 "Note" ,
46534653 "This command is for internal use and is not intended to be called from the command line." ,
46544654 )
@@ -4982,7 +4982,7 @@ def _set_up_py_shell_env(self, interp: InteractiveConsole) -> _SavedCmd2Env:
49824982 cmd2_env .completer = readline .get_completer ()
49834983
49844984 # Set the completer to use the interpreter's locals
4985- readline .set_completer (rlcompleter .Completer (interp .locals ).complete ) # type: ignore[arg-type]
4985+ readline .set_completer (rlcompleter .Completer (interp .locals ).complete )
49864986
49874987 # Use the correct binding based on whether LibEdit or Readline is being used
49884988 if "libedit" in (readline .__doc__ or "" ):
@@ -5259,7 +5259,7 @@ def do_ipy(self, _: argparse.Namespace) -> bool | None: # pragma: no cover
52595259 )
52605260
52615261 # Start IPython
5262- start_ipython (config = config , argv = [], user_ns = local_vars ) # type: ignore[no-untyped-call]
5262+ start_ipython (config = config , argv = [], user_ns = local_vars )
52635263 self .poutput ("Now exiting IPython shell..." )
52645264
52655265 # The IPython application is a singleton and won't be recreated next time
@@ -5547,7 +5547,7 @@ def _persist_history(self) -> None:
55475547 def _build_edit_parser (cls ) -> Cmd2ArgumentParser :
55485548 edit_description = "Run a text editor and optionally open a file with it."
55495549 edit_parser = argparse_utils .DEFAULT_ARGUMENT_PARSER (description = edit_description )
5550- edit_parser .epilog = TextGroup ( # type: ignore[assignment] # ty: ignore[invalid-assignment]
5550+ edit_parser .epilog = TextGroup ( # ty: ignore[invalid-assignment]
55515551 "Note" ,
55525552 Text .assemble (
55535553 "To set a new editor, run: " ,
@@ -5669,7 +5669,7 @@ def _build__relative_run_script_parser(cls) -> Cmd2ArgumentParser:
56695669 _relative_run_script_parser = cls ._build_base_run_script_parser ()
56705670
56715671 # Append to existing description
5672- _relative_run_script_parser .description = Group ( # type: ignore[assignment] # ty: ignore[invalid-assignment]
5672+ _relative_run_script_parser .description = Group ( # ty: ignore[invalid-assignment]
56735673 cast (Group , _relative_run_script_parser .description ),
56745674 "\n " ,
56755675 (
@@ -5678,7 +5678,7 @@ def _build__relative_run_script_parser(cls) -> Cmd2ArgumentParser:
56785678 ),
56795679 )
56805680
5681- _relative_run_script_parser .epilog = TextGroup ( # type: ignore[assignment] # ty: ignore[invalid-assignment]
5681+ _relative_run_script_parser .epilog = TextGroup ( # ty: ignore[invalid-assignment]
56825682 "Note" ,
56835683 "This command is intended to be used from within a text script." ,
56845684 )
0 commit comments