Botocore: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated

Created on 12 Nov 2019  路  9Comments  路  Source: boto/botocore

Referencing collections.MutableMapping rather than collections.abc.MutableMapping triggers a deprecation warning.

>>> import botocore
>>> botocore.__version__
'1.13.15'
>>> import collections
>>> collections.MutableMapping
__main__:1: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working

The reference occurs here:
https://github.com/boto/botocore/blob/develop/botocore/awsrequest.py#L624

bug closing-soon

Most helpful comment

Sorry for the late reply. We are working on a fix for it. I will update here when it will be fixed.

All 9 comments

+1
Seeing it for a long time. Nobody cares?

It seems to be a different issue as I got the same Deprecation Warning from awsrequest.py:624 , not the vendored requests. botocore.__version__ = '1.13.16'

Changing

class HeadersDict(collections.MutableMapping):
...

to

try:
    from collections.abc import MutableMapping
except ModuleNotFoundError:
    from collections import MutableMapping

class HeadersDict(MutableMapping):
...

fixes this warning and is pythonic IMHO. Pytest will then throw the same DeprecationWarning from session.py:947 instead.

I can create a PR for it if you like : )

Update: Should replace ModuleNotFoundError with ImportError as the former was introduced in Python 3.6, and is subclass to ImportError.

@clifflu is correct. This is not in the vendored requests module. I had reviewed both #1615 and PR #1829 before filing this. The deprecation warning I posted is coming from the botocore lib itself, not the older version of requests in the vendored directory.

I'm also seeing this error:

.../site-packages/botocore/awsrequest.py:624: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
    class HeadersDict(collections.MutableMapping):

Sorry for the late reply. We are working on a fix for it. I will update here when it will be fixed.

this pr thats been around for a few weeks will fix it https://github.com/boto/botocore/pull/1865

@swetashre perhaps you want to merge #1865 as @kapilt mentioned? It's a pretty small/simple change.

Now i am not getting error with this code :

In [5]: import botocore                                                                                                

In [6]: botocore.__version__                                                                                           
Out[6]: '1.13.44'

In [7]: import collections                                                                                             

In [8]: collections.MutableMapping                                                                                     
Out[8]: collections.abc.MutableMapping

Please let me know if anyone is still getting the error. This issue is fixed with the merge of PR https://github.com/boto/botocore/pull/1922

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.

Was this page helpful?
0 / 5 - 0 ratings