Code review comment for lp:~kai-mast/friends/fix-retweets

Revision history for this message
Robert Bruce Park (robru) wrote :

So this mostly looks good, but there's a bad idiom you used here that you also did in your previous MP:

58 + if "retweeted_status" in tweet:
59 + shared_status = tweet.get('retweeted_status')

There's just no need for this kind of "look before you leap" logic in python. At worst, it's a race condition, and at best it's inefficient.

What you really want to do is something more like this:

message = tweet.get('retweeted_status', {}).get('text', '') or tweet.get('text', '')

If you do that, then you also reduce the number of calls to _resolve_tco() to 1, meaning you can inline it (meaning it doesn't have to be it's own method anymore).

Also you have "entities = tweet.get('entities', {})" in two different places, needlessly redundant.

review: Needs Fixing

« Back to merge proposal