137
137
138
138
# NOTE: When using gnureadline with Python 3.13, start_ipython needs to be imported before any readline-related stuff
139
139
with contextlib .suppress (ImportError ):
140
- from IPython import start_ipython # type: ignore[import]
140
+ from IPython import start_ipython
141
141
142
142
from .rl_utils import (
143
143
RlType ,
163
163
if rl_type == RlType .NONE : # pragma: no cover
164
164
Cmd2Console (sys .stderr ).print (rl_warning , style = Cmd2Style .WARNING )
165
165
else :
166
- from .rl_utils import ( # type: ignore[attr-defined]
166
+ from .rl_utils import (
167
167
readline ,
168
168
rl_force_redisplay ,
169
169
)
@@ -1068,7 +1068,7 @@ def _unregister_subcommands(self, cmdset: Union[CommandSet, 'Cmd']) -> None:
1068
1068
1069
1069
for action in command_parser ._actions :
1070
1070
if isinstance (action , argparse ._SubParsersAction ):
1071
- action .remove_parser (subcommand_name ) # type: ignore[arg-type, attr-defined]
1071
+ action .remove_parser (subcommand_name ) # type: ignore[attr-defined]
1072
1072
break
1073
1073
1074
1074
@property
@@ -3094,11 +3094,11 @@ def _redirect_output(self, statement: Statement) -> utils.RedirectionSavedState:
3094
3094
kwargs ['executable' ] = shell
3095
3095
3096
3096
# For any stream that is a StdSim, we will use a pipe so we can capture its output
3097
- proc = subprocess .Popen ( # type: ignore[call-overload] # noqa: S602
3097
+ proc = subprocess .Popen ( # noqa: S602
3098
3098
statement .pipe_to ,
3099
3099
stdin = subproc_stdin ,
3100
3100
stdout = subprocess .PIPE if isinstance (self .stdout , utils .StdSim ) else self .stdout , # type: ignore[unreachable]
3101
- stderr = subprocess .PIPE if isinstance (sys .stderr , utils .StdSim ) else sys .stderr , # type: ignore[unreachable]
3101
+ stderr = subprocess .PIPE if isinstance (sys .stderr , utils .StdSim ) else sys .stderr ,
3102
3102
shell = True ,
3103
3103
** kwargs ,
3104
3104
)
@@ -3115,7 +3115,7 @@ def _redirect_output(self, statement: Statement) -> utils.RedirectionSavedState:
3115
3115
subproc_stdin .close ()
3116
3116
new_stdout .close ()
3117
3117
raise RedirectionError (f'Pipe process exited with code { proc .returncode } before command could run' )
3118
- redir_saved_state .redirecting = True # type: ignore[unreachable]
3118
+ redir_saved_state .redirecting = True
3119
3119
cmd_pipe_proc_reader = utils .ProcReader (proc , cast (TextIO , self .stdout ), sys .stderr )
3120
3120
3121
3121
self .stdout = new_stdout
@@ -3351,7 +3351,7 @@ def complete_none(text: str, state: int) -> str | None: # pragma: no cover # n
3351
3351
parser .add_argument (
3352
3352
'arg' ,
3353
3353
suppress_tab_hint = True ,
3354
- choices = choices , # type: ignore[arg-type]
3354
+ choices = choices ,
3355
3355
choices_provider = choices_provider ,
3356
3356
completer = completer ,
3357
3357
)
@@ -4435,7 +4435,7 @@ def complete_set_value(
4435
4435
arg_name ,
4436
4436
metavar = arg_name ,
4437
4437
help = settable .description ,
4438
- choices = settable .choices , # type: ignore[arg-type]
4438
+ choices = settable .choices ,
4439
4439
choices_provider = settable .choices_provider ,
4440
4440
completer = settable .completer ,
4441
4441
)
@@ -4566,15 +4566,15 @@ def do_shell(self, args: argparse.Namespace) -> None:
4566
4566
# still receive the SIGINT since it is in the same process group as us.
4567
4567
with self .sigint_protection :
4568
4568
# For any stream that is a StdSim, we will use a pipe so we can capture its output
4569
- proc = subprocess .Popen ( # type: ignore[call-overload] # noqa: S602
4569
+ proc = subprocess .Popen ( # noqa: S602
4570
4570
expanded_command ,
4571
4571
stdout = subprocess .PIPE if isinstance (self .stdout , utils .StdSim ) else self .stdout , # type: ignore[unreachable]
4572
- stderr = subprocess .PIPE if isinstance (sys .stderr , utils .StdSim ) else sys .stderr , # type: ignore[unreachable]
4572
+ stderr = subprocess .PIPE if isinstance (sys .stderr , utils .StdSim ) else sys .stderr ,
4573
4573
shell = True ,
4574
4574
** kwargs ,
4575
4575
)
4576
4576
4577
- proc_reader = utils .ProcReader (proc , cast (TextIO , self .stdout ), sys .stderr ) # type: ignore[arg-type]
4577
+ proc_reader = utils .ProcReader (proc , cast (TextIO , self .stdout ), sys .stderr )
4578
4578
proc_reader .wait ()
4579
4579
4580
4580
# Save the return code of the application for use in a pyscript
@@ -4656,9 +4656,9 @@ def _set_up_py_shell_env(self, interp: InteractiveConsole) -> _SavedCmd2Env:
4656
4656
# Save off the current completer and set a new one in the Python console
4657
4657
# Make sure it tab completes from its locals() dictionary
4658
4658
cmd2_env .readline_settings .completer = readline .get_completer ()
4659
- interp .runcode ("from rlcompleter import Completer" ) # type: ignore[arg-type]
4660
- interp .runcode ("import readline" ) # type: ignore[arg-type]
4661
- interp .runcode ("readline.set_completer(Completer(locals()).complete)" ) # type: ignore[arg-type]
4659
+ interp .runcode (compile ( "from rlcompleter import Completer" , "<stdin>" , "exec" ))
4660
+ interp .runcode (compile ( "import readline" , "<stdin>" , "exec" ))
4661
+ interp .runcode (compile ( "readline.set_completer(Completer(locals()).complete)" , "<stdin>" , "exec" ))
4662
4662
4663
4663
# Set up sys module for the Python console
4664
4664
self ._reset_py_display ()
@@ -4889,18 +4889,18 @@ def do_ipy(self, _: argparse.Namespace) -> bool | None: # pragma: no cover
4889
4889
4890
4890
# Detect whether IPython is installed
4891
4891
try :
4892
- import traitlets .config .loader as traitlets_loader # type: ignore[import]
4892
+ import traitlets .config .loader as traitlets_loader
4893
4893
4894
4894
# Allow users to install ipython from a cmd2 prompt when needed and still have ipy command work
4895
4895
try :
4896
4896
_dummy = start_ipython # noqa: F823
4897
4897
except NameError :
4898
- from IPython import start_ipython # type: ignore[import]
4898
+ from IPython import start_ipython
4899
4899
4900
- from IPython .terminal .interactiveshell import ( # type: ignore[import]
4900
+ from IPython .terminal .interactiveshell import (
4901
4901
TerminalInteractiveShell ,
4902
4902
)
4903
- from IPython .terminal .ipapp import ( # type: ignore[import]
4903
+ from IPython .terminal .ipapp import (
4904
4904
TerminalIPythonApp ,
4905
4905
)
4906
4906
except ImportError :
0 commit comments