Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix DeprecationWarning when accessing collections.abc classes via collections #6268

Merged
merged 2 commits into from Feb 25, 2019
Merged

Fix DeprecationWarning when accessing collections.abc classes via collections #6268

merged 2 commits into from Feb 25, 2019

Conversation

chornsby
Copy link
Contributor

@chornsby chornsby commented Oct 20, 2018

Description

Since the Mapping and MutableMapping classes will no longer be available to import directly from the collections module in Python 3.8, we should create and use aliases for them in the compat module. I noticed this due to deprecation warnings appearing in tests in a project using rest framework that I ran on Python 3.7.

This builds on the work started in #6154 and removes the remaining references to the abstract base classes that are used in the project.

chornsby added 2 commits Oct 20, 2018
Since the Mapping class will no longer be available to import directly
from the collections module in Python 3.8, we should use the
compatibility helper introduced in #6154 in the fields module.
Since the MutableMapping class will no longer be available to import
directly from the collections module in Python 3.8, we should create an
alias for it in the compat module and use that instead.
@chornsby chornsby changed the title Py38 compat abc Fix DeprecationWarning when accessing collections.abc classes via collections Oct 20, 2018
@tirkarthi
Copy link
Contributor

tirkarthi commented Jan 13, 2019

There could be warnings caused in below files as I can see from grep

tests/test_renderers.py
5:from collections import MutableMapping, OrderedDict

tests/test_serializer.py
8:from collections import Mapping

@carltongibson carltongibson added this to the 3.9.2 Release milestone Feb 19, 2019
Copy link
Collaborator

@carltongibson carltongibson left a comment

Great. Thanks.

@carltongibson carltongibson merged commit 07c5c96 into encode:master Feb 25, 2019
1 check passed
@chornsby chornsby deleted the py38-compat-abc branch Feb 25, 2019
pchiquet pushed a commit to pchiquet/django-rest-framework that referenced this pull request Nov 17, 2020
…lections (encode#6268)

* Use compat version of collections.abc.Mapping

Since the Mapping class will no longer be available to import directly
from the collections module in Python 3.8, we should use the
compatibility helper introduced in encode#6154 in the fields module.

* Alias and use compat version of collections.abc.MutableMapping

Since the MutableMapping class will no longer be available to import
directly from the collections module in Python 3.8, we should create an
alias for it in the compat module and use that instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants