Avoid DeprecationWarning when importing OrderedDict#54
Avoid DeprecationWarning when importing OrderedDict#54SVilgelm merged 2 commits intopython-restx:masterfrom kbevers:fix-ordereddict-import
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.
|
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. |
SVilgelm
left a comment
There was a problem hiding this comment.
Looks good to me. Thank you
ziirish
left a comment
There was a problem hiding this comment.
I'm okay with this change.
Thanks for your contribution!
in
flask_restx/model.pyandflask_restx/swagger.pylogic is installed tocircumvent differences in Python2 and Python3 when importing from the
collections module. Some classes from collections has been moved to
collections.abcin Python3.OrderedDictis not one of them, hence anImportError is raised when trying to import
OrderedDictfromcollections.abc. This then leads to importing both
OrderedDictANDMutableMapping/Hashablefromcollections.abcwhich then raises aDeprecationWarningsinceMutableMapping/Hashablelives incollections.abcin Python3.This patch should fix those
DeprecationWarnings to be raised.Output from running
pytestin a project that uses flask_restx. Here theDeprecationWarnings are seen clearly. I've only fixed the ones pertaining to the Python standard library :