summaryrefslogtreecommitdiff
path: root/cmd2/cmd2.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2019-07-03 11:33:32 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2019-07-03 11:33:32 -0400
commit6fdf6413b9ef0b96e44ce15976f4a93cefde8d02 (patch)
treea9110eaca020a4d0519ba5a7635465d09fe6566a /cmd2/cmd2.py
parent3d5d515aee889bc34b1be65d0ec4023fab613fcb (diff)
downloadcmd2-git-6fdf6413b9ef0b96e44ce15976f4a93cefde8d02.tar.gz
Removed import of Collection since we are no longer calling len() on the variables that needed it
Diffstat (limited to 'cmd2/cmd2.py')
-rw-r--r--cmd2/cmd2.py35
1 files changed, 6 insertions, 29 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py
index 351af91d..b63d656a 100644
--- a/cmd2/cmd2.py
+++ b/cmd2/cmd2.py
@@ -40,7 +40,7 @@ import sys
import threading
from collections import namedtuple
from contextlib import redirect_stdout
-from typing import Any, Callable, Dict, List, Mapping, Optional, Tuple, Type, Union
+from typing import Any, Callable, Dict, Iterable, List, Mapping, Optional, Tuple, Type, Union
from . import ansi
from . import constants
@@ -50,7 +50,7 @@ from .argparse_completer import AutoCompleter, ACArgumentParser, ACTION_ARG_CHOI
from .clipboard import can_clip, get_paste_buffer, write_to_paste_buffer
from .history import History, HistoryItem
from .parsing import StatementParser, Statement, Macro, MacroArg, shlex_split
-
+giut
# Set up readline
from .rl_utils import rl_type, RlType, rl_get_point, rl_set_prompt, vt100_support, rl_make_safe_prompt
@@ -80,29 +80,6 @@ else:
rl_basic_quote_characters = ctypes.c_char_p.in_dll(readline_lib, "rl_basic_quote_characters")
orig_rl_basic_quotes = ctypes.cast(rl_basic_quote_characters, ctypes.c_void_p).value
-# Collection is a container that is sizable and iterable
-# It was introduced in Python 3.6. We will try to import it, otherwise use our implementation
-try:
- from collections.abc import Collection, Iterable
-except ImportError:
- from collections.abc import Sized, Iterable, Container
-
- # noinspection PyAbstractClass
- class Collection(Sized, Iterable, Container):
-
- __slots__ = ()
-
- # noinspection PyPep8Naming
- @classmethod
- def __subclasshook__(cls, C):
- if cls is Collection:
- if any("__len__" in B.__dict__ for B in C.__mro__) and \
- any("__iter__" in B.__dict__ for B in C.__mro__) and \
- any("__contains__" in B.__dict__ for B in C.__mro__):
- return True
- return NotImplemented
-
-
# Detect whether IPython is installed to determine if the built-in "ipy" command should be included
ipython_available = True
try:
@@ -969,8 +946,8 @@ class Cmd(cmd.Cmd):
if flag in flag_dict:
match_against = flag_dict[flag]
- # Perform tab completion using a Collection
- if isinstance(match_against, Collection):
+ # Perform tab completion using an Iterable
+ if isinstance(match_against, Iterable):
completions_matches = self.basic_complete(text, line, begidx, endidx, match_against)
# Perform tab completion using a function
@@ -1013,8 +990,8 @@ class Cmd(cmd.Cmd):
else:
match_against = all_else
- # Perform tab completion using a Collection
- if isinstance(match_against, Collection):
+ # Perform tab completion using a Iterable
+ if isinstance(match_against, Iterable):
matches = self.basic_complete(text, line, begidx, endidx, match_against)
# Perform tab completion using a function