Skip to content

Commit 884758d

Browse files
committed
Cleaned up remaining import of Dict and List from Typing
1 parent 74b21c8 commit 884758d

File tree

15 files changed

+38
-72
lines changed

15 files changed

+38
-72
lines changed

cmd2/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
# Check if user has defined a module that sets a custom value for argparse_custom.DEFAULT_ARGUMENT_PARSER.
1313
# Do this before loading cmd2.Cmd class so its commands use the custom parser.
1414
import argparse
15-
from typing import List
1615

1716
from .ansi import (
1817
Bg,
@@ -56,7 +55,7 @@
5655
from .py_bridge import CommandResult
5756
from .utils import CompletionMode, CustomCompletionSettings, Settable, categorize
5857

59-
__all__: List[str] = [
58+
__all__: list[str] = [
6059
'COMMAND_NAME',
6160
'DEFAULT_SHORTCUTS',
6261
# ANSI Exports

cmd2/ansi.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -986,10 +986,10 @@ def style(
986986
:raises TypeError: if bg isn't None or a subclass of BgColor
987987
:return: the stylized string
988988
"""
989-
# List of strings that add style
989+
# list of strings that add style
990990
additions: list[AnsiSequence] = []
991991

992-
# List of strings that remove style
992+
# list of strings that remove style
993993
removals: list[AnsiSequence] = []
994994

995995
# Process the style settings

cmd2/exceptions.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
"""Custom exceptions for cmd2"""
22

3-
from typing import (
4-
Any,
5-
)
3+
from typing import Any
64

75
############################################################################################################
86
# The following exceptions are part of the public API

cmd2/plugin.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
from dataclasses import (
44
dataclass,
55
)
6-
from typing import (
7-
Optional,
8-
)
6+
from typing import Optional
97

108
from .parsing import (
119
Statement,

cmd2/rl_utils.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
from enum import (
77
Enum,
88
)
9-
from typing import (
10-
Union,
11-
)
9+
from typing import Union
1210

1311
#########################################################################################################################
1412
# NOTE ON LIBEDIT:

examples/modular_commands/commandset_complex.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
"""
44

55
import argparse
6-
from typing import (
7-
List,
8-
)
96

107
import cmd2
118

@@ -23,7 +20,7 @@ def do_banana(self, statement: cmd2.Statement):
2320
cranberry_parser.add_argument('arg1', choices=['lemonade', 'juice', 'sauce'])
2421

2522
@cmd2.with_argparser(cranberry_parser, with_unknown_args=True)
26-
def do_cranberry(self, ns: argparse.Namespace, unknown: List[str]):
23+
def do_cranberry(self, ns: argparse.Namespace, unknown: list[str]):
2724
self._cmd.poutput('Cranberry {}!!'.format(ns.arg1))
2825
if unknown and len(unknown):
2926
self._cmd.poutput('Unknown: ' + ', '.join(['{}'] * len(unknown)).format(*unknown))
@@ -34,12 +31,12 @@ def help_cranberry(self):
3431

3532
@cmd2.with_argument_list
3633
@cmd2.with_category('Also Alone')
37-
def do_durian(self, args: List[str]):
34+
def do_durian(self, args: list[str]):
3835
"""Durian Command"""
3936
self._cmd.poutput('{} Arguments: '.format(len(args)))
4037
self._cmd.poutput(', '.join(['{}'] * len(args)).format(*args))
4138

42-
def complete_durian(self, text: str, line: str, begidx: int, endidx: int) -> List[str]:
39+
def complete_durian(self, text: str, line: str, begidx: int, endidx: int) -> list[str]:
4340
return self._cmd.basic_complete(text, line, begidx, endidx, ['stinks', 'smells', 'disgusting'])
4441

4542
elderberry_parser = cmd2.Cmd2ArgumentParser()

examples/modular_commands_main.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66

77
import argparse
88
from collections.abc import Iterable
9-
from typing import (
10-
Optional,
11-
)
9+
from typing import Optional
1210

1311
from modular_commands.commandset_basic import ( # noqa: F401
1412
BasicCompletionCommandSet,

examples/scripts/save_help_text.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,12 @@
66
import argparse
77
import os
88
import sys
9-
from typing import (
10-
List,
11-
TextIO,
12-
)
9+
from typing import TextIO
1310

1411
ASTERISKS = "********************************************************"
1512

1613

17-
def get_sub_commands(parser: argparse.ArgumentParser) -> List[str]:
14+
def get_sub_commands(parser: argparse.ArgumentParser) -> list[str]:
1815
"""Get a list of subcommands for an ArgumentParser"""
1916
sub_cmds = []
2017

examples/table_creation.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33

44
import functools
55
import sys
6-
from typing import (
7-
Any,
8-
)
6+
from typing import Any
97

108
from cmd2 import (
119
EightBitBg,

plugins/template/cmd2_myplugin/myplugin.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33

44
import functools
55
from collections.abc import Callable
6-
from typing import (
7-
TYPE_CHECKING,
8-
)
6+
from typing import TYPE_CHECKING
97

108
import cmd2
119

0 commit comments

Comments
 (0)