Skip to content

Commit 4d2920f

Browse files
code-health: remove collections wrappers
collections.abc was introduced in Python 3.3 [1]. 1. https://docs.python.org/3/library/collections.abc.html Part of #212
1 parent 3214c73 commit 4d2920f

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

Diff for: tarantool/request.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,10 @@
44
'''
55

66
import sys
7-
import collections
87
import msgpack
98
import hashlib
109

11-
try:
12-
collectionsAbc = collections.abc
13-
except AttributeError:
14-
collectionsAbc = collections
10+
from collections.abc import Sequence, Mapping
1511

1612

1713
from tarantool.error import DatabaseError
@@ -406,9 +402,9 @@ class RequestExecute(Request):
406402

407403
def __init__(self, conn, sql, args):
408404
super(RequestExecute, self).__init__(conn)
409-
if isinstance(args, collectionsAbc.Mapping):
405+
if isinstance(args, Mapping):
410406
args = [{":%s" % name: value} for name, value in args.items()]
411-
elif not isinstance(args, collectionsAbc.Sequence):
407+
elif not isinstance(args, Sequence):
412408
raise TypeError("Parameter type '%s' is not supported. "
413409
"Must be a mapping or sequence" % type(args))
414410

Diff for: tarantool/response.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
# pylint: disable=C0301,W0105,W0401,W0614
22

3-
try:
4-
# Python 3.3+
5-
from collections.abc import Sequence
6-
except ImportError:
7-
# Python 2
8-
from collections import Sequence
3+
from collections.abc import Sequence
94

105
import json
116
import msgpack

0 commit comments

Comments
 (0)