Skip to content

Commit

Permalink
Default to User model in Status.parse more broadly for user attribute
Browse files Browse the repository at this point in the history
To handle parsers without model_factory attribute or model factories without user attribute
  • Loading branch information
Harmon758 committed Jan 28, 2021
1 parent 4590c7a commit 41e7afa
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tweepy/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,10 @@ def parse(cls, api, json):
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':
Expand Down

0 comments on commit 41e7afa

Please sign in to comment.