Skip to content

Commit 34ccd52

Browse files
committed
Finished removing ignores that were no longer used by mypy
1 parent 1ecda32 commit 34ccd52

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

cmd2/argparse_completer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ def _format_completions(self, arg_state: _ArgumentState, completions: list[str]
533533
if not self._cmd2_app.matches_sorted:
534534
# If all orig_value types are numbers, then sort by that value
535535
if all_nums:
536-
completion_items.sort(key=lambda c: c.orig_value) # type: ignore[no-any-return]
536+
completion_items.sort(key=lambda c: c.orig_value)
537537

538538
# Otherwise sort as strings
539539
else:
@@ -731,7 +731,7 @@ def _complete_arg(
731731
# This won't hit because runtime checking doesn't check function argument types and will always
732732
# resolve true above. Mypy, however, does see the difference and gives an error that can't be
733733
# ignored. Mypy issue #5485 discusses this problem
734-
completion_items = choices_func(*args) # type: ignore[arg-type]
734+
completion_items = choices_func(*args)
735735
# else case is already covered above
736736
else:
737737
completion_items = arg_choices

cmd2/argparse_custom.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,7 +1311,7 @@ def _format_args(self, action: argparse.Action, default_metavar: str) -> str:
13111311
if isinstance(action.nargs, int) and action.nargs > 1:
13121312
return '{}{{{}}}'.format('%s' % metavar_formatter(1), action.nargs) # noqa: UP031
13131313

1314-
return super()._format_args(action, default_metavar) # type: ignore[arg-type]
1314+
return super()._format_args(action, default_metavar)
13151315

13161316

13171317
class RawDescriptionCmd2HelpFormatter(
@@ -1433,7 +1433,7 @@ def __init__(
14331433
description=description, # type: ignore[arg-type]
14341434
epilog=epilog, # type: ignore[arg-type]
14351435
parents=parents if parents else [],
1436-
formatter_class=formatter_class, # type: ignore[arg-type]
1436+
formatter_class=formatter_class,
14371437
prefix_chars=prefix_chars,
14381438
fromfile_prefix_chars=fromfile_prefix_chars,
14391439
argument_default=argument_default,

cmd2/cmd2.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@
137137

138138
# NOTE: When using gnureadline with Python 3.13, start_ipython needs to be imported before any readline-related stuff
139139
with contextlib.suppress(ImportError):
140-
from IPython import start_ipython # type: ignore[import]
140+
from IPython import start_ipython
141141

142142
from .rl_utils import (
143143
RlType,
@@ -163,7 +163,7 @@
163163
if rl_type == RlType.NONE: # pragma: no cover
164164
Cmd2Console(sys.stderr).print(rl_warning, style=Cmd2Style.WARNING)
165165
else:
166-
from .rl_utils import ( # type: ignore[attr-defined]
166+
from .rl_utils import (
167167
readline,
168168
rl_force_redisplay,
169169
)
@@ -3094,11 +3094,11 @@ def _redirect_output(self, statement: Statement) -> utils.RedirectionSavedState:
30943094
kwargs['executable'] = shell
30953095

30963096
# 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
30983098
statement.pipe_to,
30993099
stdin=subproc_stdin,
31003100
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,
31023102
shell=True,
31033103
**kwargs,
31043104
)
@@ -3115,7 +3115,7 @@ def _redirect_output(self, statement: Statement) -> utils.RedirectionSavedState:
31153115
subproc_stdin.close()
31163116
new_stdout.close()
31173117
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
31193119
cmd_pipe_proc_reader = utils.ProcReader(proc, cast(TextIO, self.stdout), sys.stderr)
31203120

31213121
self.stdout = new_stdout
@@ -4435,7 +4435,7 @@ def complete_set_value(
44354435
arg_name,
44364436
metavar=arg_name,
44374437
help=settable.description,
4438-
choices=settable.choices, # type: ignore[arg-type]
4438+
choices=settable.choices,
44394439
choices_provider=settable.choices_provider,
44404440
completer=settable.completer,
44414441
)
@@ -4569,7 +4569,7 @@ def do_shell(self, args: argparse.Namespace) -> None:
45694569
proc = subprocess.Popen( # noqa: S602
45704570
expanded_command,
45714571
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,
45734573
shell=True,
45744574
**kwargs,
45754575
)
@@ -4889,18 +4889,18 @@ def do_ipy(self, _: argparse.Namespace) -> bool | None: # pragma: no cover
48894889

48904890
# Detect whether IPython is installed
48914891
try:
4892-
import traitlets.config.loader as traitlets_loader # type: ignore[import]
4892+
import traitlets.config.loader as traitlets_loader
48934893

48944894
# Allow users to install ipython from a cmd2 prompt when needed and still have ipy command work
48954895
try:
48964896
_dummy = start_ipython # noqa: F823
48974897
except NameError:
4898-
from IPython import start_ipython # type: ignore[import]
4898+
from IPython import start_ipython
48994899

4900-
from IPython.terminal.interactiveshell import ( # type: ignore[import]
4900+
from IPython.terminal.interactiveshell import (
49014901
TerminalInteractiveShell,
49024902
)
4903-
from IPython.terminal.ipapp import ( # type: ignore[import]
4903+
from IPython.terminal.ipapp import (
49044904
TerminalIPythonApp,
49054905
)
49064906
except ImportError:

0 commit comments

Comments
 (0)