Skip to content

Commit ef5c2c2

Browse files
authored
Fix deprecation warnings for collections.abc imports (#525)
1 parent 6ae9fb1 commit ef5c2c2

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

boxsdk/object/api_json_object.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@
22

33
from __future__ import unicode_literals, absolute_import
44

5-
from collections import Mapping
5+
import sys
66
from abc import ABCMeta
77

88
from .base_api_json_object import BaseAPIJSONObject, BaseAPIJSONObjectMeta
99
from ..util.compat import with_metaclass
1010

11+
if sys.version_info >= (3, 3):
12+
from collections.abc import Mapping # pylint:disable=no-name-in-module,import-error
13+
else:
14+
from collections import Mapping # pylint:disable=no-name-in-module,import-error
15+
1116

1217
class APIJSONObjectMeta(BaseAPIJSONObjectMeta, ABCMeta):
1318
"""

boxsdk/pagination/box_object_collection.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,21 @@
22

33
from __future__ import unicode_literals
44

5+
import sys
56
from abc import ABCMeta, abstractmethod
6-
import collections
77

88
from six import add_metaclass
99

1010
from boxsdk.pagination.page import Page
1111

12+
if sys.version_info >= (3, 3):
13+
from collections.abc import Iterator # pylint:disable=no-name-in-module,import-error
14+
else:
15+
from collections import Iterator # pylint:disable=no-name-in-module,import-error
16+
1217

1318
@add_metaclass(ABCMeta)
14-
class BoxObjectCollection(collections.Iterator, object):
19+
class BoxObjectCollection(Iterator):
1520
"""
1621
An iterator that represents a collection of Box objects (BaseObject).
1722

boxsdk/pagination/page.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@
22

33
from __future__ import unicode_literals, absolute_import
44

5-
from collections import Sequence
65
import copy
6+
import sys
77

8+
if sys.version_info >= (3, 3):
9+
from collections.abc import Sequence # pylint:disable=no-name-in-module,import-error
10+
else:
11+
from collections import Sequence # pylint:disable=no-name-in-module,import-error
812

9-
class Page(Sequence, object):
13+
14+
class Page(Sequence):
1015
"""
1116
A sequence of BaseObjects that belong to a page returned from a paging api call.
1217

boxsdk/util/log.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from __future__ import unicode_literals
44

5-
from collections import Mapping
65
import logging
76
try:
87
from logging import NullHandler
@@ -14,6 +13,11 @@ def emit(self, record):
1413

1514
from six import string_types, iteritems
1615

16+
if sys.version_info >= (3, 3):
17+
from collections.abc import Mapping # pylint:disable=no-name-in-module,import-error
18+
else:
19+
from collections import Mapping # pylint:disable=no-name-in-module,import-error
20+
1721

1822
_no_logger = object()
1923

0 commit comments

Comments
 (0)