Skip to content

Commit

Permalink
Import ABC from collections.abc
Browse files Browse the repository at this point in the history
  • Loading branch information
tirkarthi committed Mar 7, 2021
1 parent 144e51b commit e6249f0
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions st2client/st2client/utils/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
"""

from __future__ import absolute_import
import collections
from collections.abc import MutableSet

__all__ = ["OrderedSet"]


class OrderedSet(collections.MutableSet):
class OrderedSet(MutableSet):
def __init__(self, iterable=None):
self.end = end = []
end += [None, end, end] # sentinel node for doubly linked list
Expand Down
5 changes: 3 additions & 2 deletions st2common/st2common/util/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@

from __future__ import absolute_import

import collections
import mongoengine
import six

from collections.abc import Mapping


def mongodb_to_python_types(value):
# Convert MongoDB BaseDict and BaseList types to python dict and list types.
Expand All @@ -30,7 +31,7 @@ def mongodb_to_python_types(value):
# functions used to convert JSON/YAML objects/strings will errored. This is caused
# by the PR StackStorm/orquesta#191 which converts dict to collections.Mapping
# in YAQL related functions.
elif isinstance(value, collections.Mapping):
elif isinstance(value, Mapping):
value = dict(value)

# Recursively traverse the dict and list to convert values.
Expand Down
4 changes: 2 additions & 2 deletions st2common/st2common/util/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
import os
import re
import sys
import collections
import functools

import six
from collections.abc import Mapping

__all__ = [
"prefix_dict_keys",
Expand Down Expand Up @@ -137,7 +137,7 @@ def deep_update(d, u):
"""

for k, v in six.iteritems(u):
if isinstance(v, collections.Mapping):
if isinstance(v, Mapping):
r = deep_update(d.get(k, {}), v)
d[k] = r
else:
Expand Down
4 changes: 2 additions & 2 deletions st2common/st2common/util/pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

import os
import re
import collections

import six

from collections.abc import Iterable
from st2common.util import schema as util_schema
from st2common.constants.pack import MANIFEST_FILE_NAME
from st2common.constants.pack import PACK_REF_WHITELIST_REGEX
Expand Down Expand Up @@ -167,7 +167,7 @@ def validate_config_against_schema(
except jsonschema.ValidationError as e:
attribute = getattr(e, "path", [])

if isinstance(attribute, (tuple, list, collections.Iterable)):
if isinstance(attribute, (tuple, list, Iterable)):
attribute = [str(item) for item in attribute]
attribute = ".".join(attribute)
else:
Expand Down
4 changes: 2 additions & 2 deletions st2common/st2common/util/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
"""

from __future__ import absolute_import
import collections
from collections.abc import MutableSet

__all__ = ["OrderedSet"]


class OrderedSet(collections.MutableSet):
class OrderedSet(MutableSet):
def __init__(self, iterable=None):
self.end = end = []
end += [None, end, end] # sentinel node for doubly linked list
Expand Down

0 comments on commit e6249f0

Please sign in to comment.