From 89416d9856a2233b8f0c309720d9d746f2ac1e47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastien=20G=C3=A9rard?= Date: Fri, 5 Oct 2018 14:16:22 +0200 Subject: [PATCH] Fix deprecation warning about Hashable in py3.7 --- mongoengine/base/document.py | 2 +- mongoengine/python_support.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/mongoengine/base/document.py b/mongoengine/base/document.py index c82d670e..ccbfa3d6 100644 --- a/mongoengine/base/document.py +++ b/mongoengine/base/document.py @@ -1,6 +1,5 @@ import copy import numbers -from collections import Hashable from functools import partial from bson import ObjectId, json_util @@ -19,6 +18,7 @@ from mongoengine.base.fields import ComplexBaseField from mongoengine.common import _import_class from mongoengine.errors import (FieldDoesNotExist, InvalidDocumentError, LookUpError, OperationError, ValidationError) +from mongoengine.python_support import Hashable __all__ = ('BaseDocument', 'NON_FIELD_ERRORS') diff --git a/mongoengine/python_support.py b/mongoengine/python_support.py index e884b4ea..7e8e108f 100644 --- a/mongoengine/python_support.py +++ b/mongoengine/python_support.py @@ -19,3 +19,10 @@ if not six.PY3: pass else: StringIO = cStringIO.StringIO + + +if six.PY3: + from collections.abc import Hashable +else: + # raises DeprecationWarnings in Python >=3.7 + from collections import Hashable