From 9f10a58e6a9fa8726fa033008f203ff577e1fc03 Mon Sep 17 00:00:00 2001 From: Harmon Date: Thu, 24 Feb 2022 13:46:08 -0600 Subject: [PATCH] Override Mapping.__contains__ in DataMapping This allows membership tests to check for existence within data, rather than existence of the attribute at all --- tweepy/mixins.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tweepy/mixins.py b/tweepy/mixins.py index ecd5b57..5884ff4 100644 --- a/tweepy/mixins.py +++ b/tweepy/mixins.py @@ -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] -- 2.25.1