Default to User model in Status.parse more broadly for user attribute
authorHarmon <Harmon758@gmail.com>
Thu, 28 Jan 2021 19:54:30 +0000 (13:54 -0600)
committerHarmon <Harmon758@gmail.com>
Thu, 28 Jan 2021 19:54:30 +0000 (13:54 -0600)
To handle parsers without model_factory attribute or model factories without user attribute

tweepy/models.py

index 9a2447b4dc0c2ce6588c52ed173396aaf8b230fc..fc776d700b94c95f28a6a97983c4aa4054a60e4f 100644 (file)
@@ -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':