Skip to content

Fix Python 3.7 DeprecationWarning (Python 3.8 compatibility) #6154

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 1 commit into from
Sep 11, 2018
Merged

Fix Python 3.7 DeprecationWarning (Python 3.8 compatibility) #6154

merged 1 commit into from
Sep 11, 2018

Conversation

jleclanche
Copy link
Contributor

@jleclanche jleclanche commented Sep 2, 2018

Description

Fixes warning:

rest_framework/serializers.py:18: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
  from collections import Mapping, OrderedDict

@codecov-io
Copy link

codecov-io commented Sep 2, 2018

Codecov Report

Merging #6154 into master will increase coverage by <.01%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master    #6154      +/-   ##
==========================================
+ Coverage   96.18%   96.18%   +<.01%     
==========================================
  Files         128      128              
  Lines       17624    17628       +4     
  Branches     1459     1459              
==========================================
+ Hits        16951    16955       +4     
  Misses        465      465              
  Partials      208      208

@carltongibson carltongibson added this to the 3.9 Release milestone Sep 2, 2018
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.

OK. Looks good. Thanks @jleclanche.

@rpkilby
Copy link
Member

rpkilby commented Sep 3, 2018

I would add a note that this is relevant to Python 2 compatibility. The warning was just added, but collections.abc has been around since Python 3.3

@jleclanche
Copy link
Contributor Author

Done

@jleclanche
Copy link
Contributor Author

Sorry, I misread what you meant. If it's been around since 3.3 then indeed this is only useful on 2.7.

@jleclanche
Copy link
Contributor Author

Updated comments

@rpkilby rpkilby merged commit 612a7b9 into encode:master Sep 11, 2018
carltongibson pushed a commit that referenced this pull request Feb 25, 2019
…lections (#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 #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.
pchiquet pushed a commit to pchiquet/django-rest-framework that referenced this pull request Nov 17, 2020
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants