Google-cloud-python: General: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working

Created on 8 Nov 2018  路  5Comments  路  Source: googleapis/google-cloud-python

I'm getting this deprecation warning when running pytests on my app that uses Google Storage.

Environment details

Arch Linux
Python 3.7.1
google-api-core==1.5.1
google-auth==1.5.1
google-cloud-core==0.28.1
google-cloud-storage==1.13.0
google-resumable-media==0.3.1
googleapis-common-protos==1.5.5
pytest==3.9.1

Steps to reproduce

  1. Create file test.py.
  2. Add line from google.protobuf.pyext import _message to it.
  3. Run pytest test.py (to install pytest first pip install pytest==3.9.1)
  4. Pytest will print the following: test.py:1: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working from google.protobuf.pyext import _message

In my tests this warning comes from: google/protobuf/internal/api_implementation.py:154

Couldn't reproduce in shell, but pytest somehow catches this while running tests.

bigquery core p2 firestore cleanup clouddebugger

Most helpful comment

@User3759685 I forgot to say thanks for reporting the issue!

All 5 comments

Please report the issue for the Python protobuf library in its repository.

We do have places here where we use those ABCs, which need to be fixed:

$ git grep -l "collections.ABCMeta" | wc -l
0
$ git grep -l "collections.Callable" | wc -l
0
$ git grep -l "collections.Container" | wc -l
0
$ git grep -l "collections.Hashable" | wc -l
0
$ git grep -l "collections.ItemsView" | wc -l
0
$ git grep -l "collections.Iterable" | wc -l
0
$ git grep -l "collections.Iterator" | wc -l
0
$ git grep -l "collections.KeysView" | wc -l
0
$ git grep -l "collections.Mapping"
api_core/google/api_core/protobuf_helpers.py
bigquery/google/cloud/bigquery/dbapi/_helpers.py
bigquery/google/cloud/bigquery/dbapi/cursor.py
firestore/google/cloud/firestore_v1beta1/_helpers.py
$ git grep -l "collections.MappingView" | wc -l
0
$ git grep -l "collections.MutableMapping"
api_core/google/api_core/protobuf_helpers.py
core/google/cloud/iam.py
$ git grep -l "collections.MutableSequence"
api_core/google/api_core/protobuf_helpers.py
$ git grep -l "collections.MutableSet" | wc -l
0
$ git grep -l "collections.Sequence"
bigquery/google/cloud/bigquery/client.py
$ git grep -l "collections.Set" | wc -l
0
$ git grep -l "collections.Sized" | wc -l
0
$ git grep -l "collections.ValuesView" | wc -l
0

Note that collections.abc is not present in Python 2.7, which means we will need to do some kind of conditional import, e.g.:

try:
    from collections.abc import Mapping
except ImportError:
    from collections import Mapping

@User3759685 I forgot to say thanks for reporting the issue!

@User3759685 There was an issue opened for protobuf. Unfortunately, the PR which closed it did not completely address the issue.

I submitted https://github.com/protocolbuffers/protobuf/issues/5335 for the remaining deprecated usage under protobuf.

DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
import pymssql
Traceback (most recent call last):
File "src\pymssql.pyx", line 636, in pymssql.connect
File "src_mssql.pyx", line 1957, in _mssql.connect
File "src_mssql.pyx", line 676, in _mssql.MSSQLConnection.__init__
File "src_mssql.pyx", line 1683, in _mssql.maybe_raise_MSSQLDatabaseException
_mssql.MSSQLDatabaseException: (20009, b'DB-Lib error message 20009, severity 9:\nUnable to connect: Adaptive Server is unavailable or does not exist (xxx:1433)\nNet-Lib error during Unknown
I'm getting this error on windows machine Please suggest how to resolve.

Was this page helpful?
0 / 5 - 0 ratings