Handle collections.abc deprecations
The use of ABC classes directly from collections has been deprecated in 3.x versions of Python. The direction is to use the classes defined in collections.abc. Python 2.7 does not have this, but Python 3.8 will be dropping the backwards compatibility to use the old location. Six also does not have support for this yet, so in the mean time to make sure we don't run into issues as folks try to move to 3.8, and to get rid of deprecation warnings in logs, this handles importing from the preferred location and falls back if it not available. Change-Id: I535640779da645e43ba6586308b07bf25dba7d89 Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
This commit is contained in:
parent
c6631d3825
commit
6c951ed373
@ -17,6 +17,14 @@
|
||||
|
||||
import argparse
|
||||
import collections
|
||||
|
||||
# TODO(smcginnis) update this once six has support for collections.abc
|
||||
# (https://github.com/benjaminp/six/pull/241) or clean up once we drop py2.7.
|
||||
try:
|
||||
from collections.abc import Mapping
|
||||
except ImportError:
|
||||
from collections import Mapping
|
||||
|
||||
import copy
|
||||
import errno
|
||||
import functools
|
||||
@ -1910,7 +1918,7 @@ class _CachedArgumentParser(argparse.ArgumentParser):
|
||||
super(_CachedArgumentParser, self).print_usage(file)
|
||||
|
||||
|
||||
class ConfigOpts(collections.Mapping):
|
||||
class ConfigOpts(Mapping):
|
||||
|
||||
"""Config options which may be set on the command line or in config files.
|
||||
|
||||
@ -3099,7 +3107,7 @@ class ConfigOpts(collections.Mapping):
|
||||
value, loc = self._do_get(name, opt_group, None)
|
||||
return loc
|
||||
|
||||
class GroupAttr(collections.Mapping):
|
||||
class GroupAttr(Mapping):
|
||||
|
||||
"""Helper class.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user