Override Mapping.__contains__ in DataMapping
authorHarmon <Harmon758@gmail.com>
Thu, 24 Feb 2022 19:46:08 +0000 (13:46 -0600)
committerHarmon <Harmon758@gmail.com>
Thu, 24 Feb 2022 19:46:08 +0000 (13:46 -0600)
This allows membership tests to check for existence within data, rather than existence of the attribute at all

tweepy/mixins.py

index ecd5b5713a9e06c51ba5f778e09639d35c8a6a5f..5884ff47e267211b9aa38881cb7bda764b3c5d9a 100644 (file)
@@ -25,6 +25,9 @@ class HashableID(EqualityComparableID):
 class DataMapping(Mapping):
     __slots__ = ()
 
+    def __contains__(self, item):
+        return item in self.data
+
     def __getattr__(self, name):
         try:
             return self.data[name]