From: Harmon Date: Thu, 24 Feb 2022 19:46:08 +0000 (-0600) Subject: Override Mapping.__contains__ in DataMapping X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=9f10a58e6a9fa8726fa033008f203ff577e1fc03;p=tweepy.git Override Mapping.__contains__ in DataMapping This allows membership tests to check for existence within data, rather than existence of the attribute at all --- 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]