Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
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
  • Loading branch information
DifferentialOrange committed Oct 6, 2022
commit ddd35767d73de3d1b43c91570372e7f73a53a5b5
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