Skip to content

Commit 9132109

Browse files
committed
[typing] use less restrictive type hints for some public methodes
1 parent 781f613 commit 9132109

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

cmd2/cmd2.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
Callable,
4949
Iterable,
5050
Mapping,
51+
Sequence,
5152
)
5253
from types import (
5354
FrameType,
@@ -320,10 +321,10 @@ def __init__(
320321
include_py: bool = False,
321322
include_ipy: bool = False,
322323
allow_cli_args: bool = True,
323-
transcript_files: list[str] | None = None,
324+
transcript_files: Sequence[str] | None = None,
324325
allow_redirection: bool = True,
325-
multiline_commands: list[str] | None = None,
326-
terminators: list[str] | None = None,
326+
multiline_commands: Iterable[str] | None = None,
327+
terminators: Iterable[str] | None = None,
327328
shortcuts: dict[str, str] | None = None,
328329
command_sets: Iterable[CommandSet] | None = None,
329330
auto_load_commands: bool = False,
@@ -568,7 +569,7 @@ def __init__(
568569
elif callargs:
569570
self._startup_commands.extend(callargs)
570571
elif transcript_files:
571-
self._transcript_files = transcript_files
572+
self._transcript_files = list(transcript_files)
572573

573574
# Set the pager(s) for use when displaying output using a pager
574575
if sys.platform.startswith('win'):
@@ -2870,7 +2871,7 @@ def _run_cmdfinalization_hooks(self, stop: bool, statement: Statement | None) ->
28702871

28712872
def runcmds_plus_hooks(
28722873
self,
2873-
cmds: list[HistoryItem] | list[str],
2874+
cmds: Iterable[HistoryItem] | Iterable[str],
28742875
*,
28752876
add_to_history: bool = True,
28762877
stop_on_keyboard_interrupt: bool = False,
@@ -4218,7 +4219,7 @@ def do_help(self, args: argparse.Namespace) -> None:
42184219
self.perror(err_msg, style=None)
42194220
self.last_result = False
42204221

4221-
def print_topics(self, header: str, cmds: list[str] | None, cmdlen: int, maxcol: int) -> None: # noqa: ARG002
4222+
def print_topics(self, header: str, cmds: Sequence[str] | None, cmdlen: int, maxcol: int) -> None: # noqa: ARG002
42224223
"""Print groups of commands and topics in columns and an optional header.
42234224
42244225
Override of cmd's print_topics() to use Rich.
@@ -4307,7 +4308,7 @@ def _print_documented_command_topics(self, header: str, cmds: list[str], verbose
43074308
self.poutput(category_grid)
43084309
self.poutput()
43094310

4310-
def render_columns(self, str_list: list[str] | None, display_width: int = 80) -> str:
4311+
def render_columns(self, str_list: Sequence[str] | None, display_width: int = 80) -> str:
43114312
"""Render a list of single-line strings as a compact set of columns.
43124313
43134314
This method correctly handles strings containing ANSI style sequences and
@@ -4366,7 +4367,7 @@ def render_columns(self, str_list: list[str] | None, display_width: int = 80) ->
43664367

43674368
return "\n".join(rows)
43684369

4369-
def columnize(self, str_list: list[str] | None, display_width: int = 80) -> None:
4370+
def columnize(self, str_list: Sequence[str] | None, display_width: int = 80) -> None:
43704371
"""Display a list of single-line strings as a compact set of columns.
43714372
43724373
Override of cmd's columnize() that uses the render_columns() method.

0 commit comments

Comments
 (0)