From 3299881b5e6766cc812181a107f50d3b65ae76b7 Mon Sep 17 00:00:00 2001 From: Harmon Date: Sun, 27 Feb 2022 14:35:20 -0600 Subject: [PATCH] Optimize Tweet.referenced_tweets initialization --- tweepy/tweet.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tweepy/tweet.py b/tweepy/tweet.py index 0437a72..7d877fd 100644 --- a/tweepy/tweet.py +++ b/tweepy/tweet.py @@ -52,11 +52,11 @@ class Tweet(HashableID, DataMapping): self.promoted_metrics = data.get("promoted_metrics") self.public_metrics = data.get("public_metrics") - self.referenced_tweets = None - if "referenced_tweets" in data: + self.referenced_tweets = data.get("referenced_tweets") + if self.referenced_tweets is not None: self.referenced_tweets = [ ReferencedTweet(referenced_tweet) - for referenced_tweet in data["referenced_tweets"] + for referenced_tweet in self.referenced_tweets ] self.reply_settings = data.get("reply_settings") -- 2.25.1