Skip to content

Commit bd9578e

Browse files
tirkarthiScitator
andauthored
Import ABC from collections.abc for Python 3.10 compatibility (#1409)
* Import ABC from collections.abc for Python 3.10 compatibility * github hack * github hack 2 Co-authored-by: Sergey Kolesnikov <[email protected]>
1 parent 2553ce8 commit bd9578e

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

catalyst/contrib/data/collate_fn.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import collections
1+
import collections.abc
22

33
from torch.utils.data.dataloader import default_collate
44

@@ -27,7 +27,7 @@ def __call__(self, batch):
2727
Returns:
2828
batch values filtered by `keys`
2929
"""
30-
if isinstance(batch[0], collections.Mapping):
30+
if isinstance(batch[0], collections.abc.Mapping):
3131
result = {}
3232
for key in batch[0]:
3333
items = [d[key] for d in batch]

catalyst/utils/misc.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import argparse
33
from base64 import urlsafe_b64encode
44
import collections
5+
import collections.abc
56
import copy
67
from datetime import datetime
78
from hashlib import sha256
@@ -203,7 +204,7 @@ def merge_dicts(*dicts: dict) -> dict:
203204
if (
204205
k in dict_
205206
and isinstance(dict_[k], dict)
206-
and isinstance(merge_dict[k], collections.Mapping)
207+
and isinstance(merge_dict[k], collections.abc.Mapping)
207208
):
208209
dict_[k] = merge_dicts(dict_[k], merge_dict[k])
209210
else:
@@ -230,7 +231,7 @@ def flatten_dict(
230231
items = []
231232
for key, value in dictionary.items():
232233
new_key = parent_key + separator + key if parent_key else key
233-
if isinstance(value, collections.MutableMapping):
234+
if isinstance(value, collections.abc.MutableMapping):
234235
items.extend(flatten_dict(value, new_key, separator=separator).items())
235236
else:
236237
items.append((new_key, value))

0 commit comments

Comments
 (0)