Remove retweeted original tweet from the list of tweets, fixes #310#311
Merged
Conversation
e36fd7a to
e665979
Compare
8e1103f to
eb21c19
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
get_typed_object
inutils.pyis a recursive deep-walker that collects **all** objects with a__typenamefield anywhere in the API response. When Twitter returns a retweet, the retweeted tweet is nested insideretweeted_status_result.resultand also carries__typename: "Tweet". It therefore ends up in the flattweetsdict built byto_old_rep, and_parse_items` then yields every entry in that dict without distinguishing top-level timeline items from nested lookup objects.The nested tweet is legitimately needed in
res["tweets"]as a lookup soTweet.parse()can populateretweetedTweet. The bug is that_parse_itemshas no way to know which entries are top-level vs. which were collected as nested references.Expected behaviour
user_tweetsshould yield the RT wrapper once. The original tweet should only be accessible viatweet.retweetedTweet, not as a separate item in the iteration.Note
The bug existed conceptually since
9238398(July 2023, the commit that introducedretweetedTweetsupport), but likely only became reliably reproducible after the May 2026 schema change: the old Twitter schema may not have included alegacykey on the nested retweeted object, which was the filter gate ([x for x in tmp["Tweet"] if "legacy" in x]). The schema migration explicitly preserves that filter condition, causing nested tweets to now consistently pass through.