From: Harmon Date: Thu, 28 Jan 2021 19:54:30 +0000 (-0600) Subject: Default to User model in Status.parse more broadly for user attribute X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=41e7afa3ad4110613e893e5ad459ef72007673a0;p=tweepy.git Default to User model in Status.parse more broadly for user attribute To handle parsers without model_factory attribute or model factories without user attribute --- diff --git a/tweepy/models.py b/tweepy/models.py index 9a2447b..fc776d7 100644 --- a/tweepy/models.py +++ b/tweepy/models.py @@ -92,8 +92,10 @@ class Status(Model, Hashable): setattr(status, '_json', json) for k, v in json.items(): if k == 'user': - user_model = getattr(api.parser.model_factory, 'user') if api else User - user = user_model.parse(api, v) + try: + user = api.parser.model_factory.user.parse(api, v) + except AttributeError: + user = User.parse(api, v) setattr(status, 'author', user) setattr(status, 'user', user) # DEPRECIATED elif k == 'created_at':