Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import ABC from collections.abc for py 3.10 compatibility #5007

Merged
merged 6 commits into from
Mar 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ Changed

Contributed by @Kami and @shital.

* Import ABC from collections.abc for Python 3.10 compatibility. (#5007)
Contributed by @tirkarthi

3.4.0 - March 02, 2021
----------------------

Expand Down
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