From 349c807f807e2262732a005878e3252441358f72 Mon Sep 17 00:00:00 2001 From: Harmon Date: Tue, 26 Jan 2021 09:42:47 -0600 Subject: [PATCH] Improve clarity of AsyncStream.on_data --- tweepy/asynchronous/streaming.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tweepy/asynchronous/streaming.py b/tweepy/asynchronous/streaming.py index 150c617..c5a1a37 100644 --- a/tweepy/asynchronous/streaming.py +++ b/tweepy/asynchronous/streaming.py @@ -295,11 +295,14 @@ class AsyncStream: return await self.on_disconnect_message(data["disconnect"]) if "limit" in data: return await self.on_limit(data["limit"]["track"]) - for message_type in ("scrub_geo","status_withheld", "user_withheld", - "warning"): - if message_type in data: - method = getattr(self, "on_" + message_type) - return await method(data[message_type]) + if "scrub_geo" in data: + return await self.on_scrub_geo(data["scrub_geo"]) + if "status_withheld" in data: + return await self.on_status_withheld(data["status_withheld"]) + if "user_withheld" in data: + return await self.on_user_withheld(data["user_withheld"]) + if "warning" in data: + return await self.on_warning(data["warning"]) log.warning("Received unknown message type: %s", raw_data) -- 2.25.1