summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2020-01-22 19:55:53 -0500
committerGitHub <noreply@github.com>2020-01-22 19:55:53 -0500
commit5b19867cf1bd7fbe8a9fea424e67eb8b13c1795d (patch)
tree0993dcd796335422ba3d1de85f9790e02d425bdb
parente4bc87da34bb6fc645f54a4467dc7d0e32dfaa3b (diff)
parente803455cd80b3433f16b5a2d9c01f022c5183448 (diff)
downloadcmd2-git-5b19867cf1bd7fbe8a9fea424e67eb8b13c1795d.tar.gz
Merge pull request #852 from tirkarthi/fix-collections-warning
Import ABC from collections.abc instead of collections for Python 3.9 compatibility
-rw-r--r--cmd2/utils.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/cmd2/utils.py b/cmd2/utils.py
index 3e154bd2..42248884 100644
--- a/cmd2/utils.py
+++ b/cmd2/utils.py
@@ -9,6 +9,7 @@ import subprocess
import sys
import threading
import unicodedata
+import collections.abc as collections_abc
from enum import Enum
from typing import Any, Iterable, List, Optional, TextIO, Union
@@ -57,7 +58,7 @@ def strip_quotes(arg: str) -> str:
def namedtuple_with_defaults(typename: str, field_names: Union[str, List[str]],
- default_values: collections.Iterable = ()):
+ default_values: collections_abc.Iterable = ()):
"""
Convenience function for defining a namedtuple with default values
@@ -79,7 +80,7 @@ def namedtuple_with_defaults(typename: str, field_names: Union[str, List[str]],
T = collections.namedtuple(typename, field_names)
# noinspection PyProtectedMember,PyUnresolvedReferences
T.__new__.__defaults__ = (None,) * len(T._fields)
- if isinstance(default_values, collections.Mapping):
+ if isinstance(default_values, collections_abc.Mapping):
prototype = T(**default_values)
else:
prototype = T(*default_values)