From: Harmon Date: Sun, 30 Oct 2022 02:28:24 +0000 (-0500) Subject: Warn when Tweet data is missing default edit_history_tweet_ids field X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=3dea0df2b8ee797264de67afc9f2d670e68aa634;p=tweepy.git Warn when Tweet data is missing default edit_history_tweet_ids field --- diff --git a/tweepy/tweet.py b/tweepy/tweet.py index 42a189d..0e896c4 100644 --- a/tweepy/tweet.py +++ b/tweepy/tweet.py @@ -2,6 +2,8 @@ # Copyright 2009-2022 Joshua Roesslein # See LICENSE for details. +import warnings + from tweepy.mixins import DataMapping, HashableID from tweepy.utils import parse_datetime @@ -124,9 +126,16 @@ class Tweet(HashableID, DataMapping): self.data = data self.id = int(data["id"]) self.text = data["text"] - self.edit_history_tweet_ids = list( - map(int, data["edit_history_tweet_ids"]) - ) + try: + self.edit_history_tweet_ids = list( + map(int, data["edit_history_tweet_ids"]) + ) + except KeyError: + warnings.warn( + "Tweet data missing default edit_history_tweet_ids field", + RuntimeWarning, + stacklevel=2 + ) self.attachments = data.get("attachments")