Skip to content

Commit

Permalink
code-health: remove collections wrappers
Browse files Browse the repository at this point in the history
collections.abc was introduced in Python 3.3 [1].

1. https://docs.python.org/3/library/collections.abc.html

Part of #212
  • Loading branch information
DifferentialOrange committed Sep 21, 2022
1 parent 12f7dd9 commit d67bda3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
10 changes: 3 additions & 7 deletions tarantool/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@
'''

import sys
import collections
import msgpack
import hashlib

try:
collectionsAbc = collections.abc
except AttributeError:
collectionsAbc = collections
from collections.abc import Sequence, Mapping


from tarantool.error import DatabaseError
Expand Down Expand Up @@ -406,9 +402,9 @@ class RequestExecute(Request):

def __init__(self, conn, sql, args):
super(RequestExecute, self).__init__(conn)
if isinstance(args, collectionsAbc.Mapping):
if isinstance(args, Mapping):
args = [{":%s" % name: value} for name, value in args.items()]
elif not isinstance(args, collectionsAbc.Sequence):
elif not isinstance(args, Sequence):
raise TypeError("Parameter type '%s' is not supported. "
"Must be a mapping or sequence" % type(args))

Expand Down
7 changes: 1 addition & 6 deletions tarantool/response.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
# pylint: disable=C0301,W0105,W0401,W0614

try:
# Python 3.3+
from collections.abc import Sequence
except ImportError:
# Python 2
from collections import Sequence
from collections.abc import Sequence

import json
import msgpack
Expand Down

0 comments on commit d67bda3

Please sign in to comment.