Skip to content

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

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

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

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.

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

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great. Thanks.

@carltongibson carltongibson merged commit 07c5c96 into encode:master Feb 25, 2019
@chornsby chornsby deleted the py38-compat-abc branch February 25, 2019 11:48
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.
sigvef pushed a commit to sigvef/django-rest-framework that referenced this pull request Dec 3, 2022
…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.

4 participants