-
Notifications
You must be signed in to change notification settings - Fork 338
Avoid DeprecationWarning when importing OrderedDict #54
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
Conversation
Seems like a partial implementation of noirbizarre/flask-restplus#768 |
You seem to be correct in that. Applying that patch here would be a better solution. |
wiat for applying the noirbizarre/flask-restplus#768
in flask_restx/model.py and flask_restx/swagger.py logic is installed to circumvent differences in Python2 and Python3 when importing from the collections module. Some classes from collections has been moved to collections.abc in Python3. OrderedDict is not one of them, hence an ImportError is raised when trying to import OrderedDict from collections.abc. This then leads to importing both OrderedDict AND MutableMapping/Hashable from collections.abc which then raises a deprecation warning since MutableMapping/Hashable lives in collections.abc in Python3. This patch should fix those DeprecationWarnings to be raised.
OrderedDict is a member of the collections module and not collections.abc. This goes for both Python2 and Python3.
7853511
to
6b253c0
Compare
I went and fixed the rest of the |
@ziirish Do we need this or we are going to remove py27 support at all? |
This is an improvement irregardless of Python2 support. You can't import |
@kbevers thanks for clarification, you are right. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Thank you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm okay with this change.
Thanks for your contribution!
in
flask_restx/model.py
andflask_restx/swagger.py
logic is installed tocircumvent differences in Python2 and Python3 when importing from the
collections module. Some classes from collections has been moved to
collections.abc
in Python3.OrderedDict
is not one of them, hence anImportError is raised when trying to import
OrderedDict
fromcollections.abc. This then leads to importing both
OrderedDict
ANDMutableMapping
/Hashable
fromcollections.abc
which then raises aDeprecationWarning
sinceMutableMapping
/Hashable
lives incollections.abc
in Python3.This patch should fix those
DeprecationWarning
s to be raised.Output from running
pytest
in a project that uses flask_restx. Here theDeprecationWarning
s are seen clearly. I've only fixed the ones pertaining to the Python standard library :