Skip to content

Commit

Permalink
Merge "Import from collections.abc"
Browse files Browse the repository at this point in the history
  • Loading branch information
zzzeek authored and Gerrit Code Review committed Sep 28, 2018
2 parents 888d122 + 2d2fa49 commit 4085b10
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 11 deletions.
8 changes: 8 additions & 0 deletions doc/build/changelog/unreleased_12/4339.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.. change::
:tags: bug, misc, py3k
:tickets: 4339

Fixed additional warnings generated by Python 3.7 due to changes in the
organization of the Python ``collections`` and ``collections.abc`` packages.
Previous ``collections`` warnings were fixed in version 1.2.11. Pull request
courtesy xtreak.
5 changes: 2 additions & 3 deletions lib/sqlalchemy/dialects/postgresql/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from __future__ import absolute_import

import json
import collections

from .base import ischema_names, colspecs
from ... import types as sqltypes
Expand Down Expand Up @@ -61,7 +60,7 @@ def bind_processor(self, dialect):
super_proc = self.string_bind_processor(dialect)

def process(value):
assert isinstance(value, collections.Sequence)
assert isinstance(value, util.collections_abc.Sequence)
tokens = [util.text_type(elem)for elem in value]
value = "{%s}" % (", ".join(tokens))
if super_proc:
Expand All @@ -74,7 +73,7 @@ def literal_processor(self, dialect):
super_proc = self.string_literal_processor(dialect)

def process(value):
assert isinstance(value, collections.Sequence)
assert isinstance(value, util.collections_abc.Sequence)
tokens = [util.text_type(elem)for elem in value]
value = "{%s}" % (", ".join(tokens))
if super_proc:
Expand Down
3 changes: 1 addition & 2 deletions lib/sqlalchemy/engine/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,7 @@ def itervalues(self):
try:
# Register RowProxy with Sequence,
# so sequence protocol is implemented
from collections import Sequence
Sequence.register(RowProxy)
util.collections_abc.Sequence.register(RowProxy)
except ImportError:
pass

Expand Down
5 changes: 2 additions & 3 deletions lib/sqlalchemy/sql/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import itertools
from .visitors import ClauseVisitor
import re
import collections

PARSE_AUTOCOMMIT = util.symbol('PARSE_AUTOCOMMIT')
NO_ARG = util.symbol('NO_ARG')
Expand Down Expand Up @@ -46,7 +45,7 @@ def _generative(fn, *args, **kw):
return self


class _DialectArgView(collections.MutableMapping):
class _DialectArgView(util.collections_abc.MutableMapping):
"""A dictionary view of dialect-level arguments in the form
<dialectname>_<argument_name>.
Expand Down Expand Up @@ -99,7 +98,7 @@ def __iter__(self):
)


class _DialectArgDict(collections.MutableMapping):
class _DialectArgDict(util.collections_abc.MutableMapping):
"""A dictionary view of dialect-level arguments for a specific
dialect.
Expand Down
2 changes: 1 addition & 1 deletion lib/sqlalchemy/sql/sqltypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2098,7 +2098,7 @@ class Comparator(Indexable.Comparator, Concatenable.Comparator):
@util.dependencies('sqlalchemy.sql.default_comparator')
def _setup_getitem(self, default_comparator, index):
if not isinstance(index, util.string_types) and \
isinstance(index, collections.Sequence):
isinstance(index, compat.collections_abc.Sequence):
index = default_comparator._check_literal(
self.expr, operators.json_path_getitem_op,
index, bindparam_type=JSON.JSONPathType
Expand Down
4 changes: 2 additions & 2 deletions test/sql/test_resultset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1062,13 +1062,13 @@ def test_no_rowcount_on_selects_inserts(self):
eq_(len(mock_rowcount.__get__.mock_calls), 2)

def test_rowproxy_is_sequence(self):
import collections
from sqlalchemy.util import collections_abc
from sqlalchemy.engine import RowProxy

row = RowProxy(
object(), ['value'], [None],
{'key': (None, None, 0), 0: (None, None, 0)})
assert isinstance(row, collections.Sequence)
assert isinstance(row, collections_abc.Sequence)

@testing.provide_metadata
def test_rowproxy_getitem_indexes_compiled(self):
Expand Down

0 comments on commit 4085b10

Please sign in to comment.