[3.7] bpo-33217: deprecate non-Enum lookups in Enums (GH-6392)

deprecate non-Enum lookups in Enums

Lookups such as `1 in Color` and `2 in SomeFlag()` will raise TypeError
in 3.8+.
diff --git a/Lib/enum.py b/Lib/enum.py
index e5fe6f3..8c8409b 100644
--- a/Lib/enum.py
+++ b/Lib/enum.py
@@ -309,6 +309,12 @@
         return cls._create_(value, names, module=module, qualname=qualname, type=type, start=start)
 
     def __contains__(cls, member):
+        if not isinstance(member, Enum):
+            import warnings
+            warnings.warn(
+                    "using non-Enums in containment checks will raise "
+                    "TypeError in Python 3.8",
+                    DeprecationWarning, 2)
         return isinstance(member, cls) and member._name_ in cls._member_map_
 
     def __delattr__(cls, attr):
@@ -713,7 +719,12 @@
 
     def __contains__(self, other):
         if not isinstance(other, self.__class__):
-            return NotImplemented
+            import warnings
+            warnings.warn(
+                    "using non-Flags in containment checks will raise "
+                    "TypeError in Python 3.8",
+                    DeprecationWarning, 2)
+            return False
         return other._value_ & self._value_ == other._value_
 
     def __repr__(self):