From 8a0477d086f22ec27e0becdfa0466ae408f5b94f Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 8 Sep 2023 23:47:21 +0000 Subject: [PATCH 1/2] refactor: refactor unnecessary `else` / `elif` when `if` block has a `raise` statement `raise` causes control flow to be disrupted, as it will exit the block. It is recommended to check other conditions using another `if` statement, and get rid of `else` statements as they are unnecessary. --- lynxie/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lynxie/utils.py b/lynxie/utils.py index 8451a4c..c9c7c2a 100644 --- a/lynxie/utils.py +++ b/lynxie/utils.py @@ -63,7 +63,7 @@ def get_env_or_error(env: str) -> str: if from_file is None and from_env is None: raise KeyError(f"Environment variable {env} not found") - elif from_file is None: + if from_file is None: return from_env else: return from_file From ed8a415e43b1888000f82e4f1ffd1bf3328cc8d4 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Fri, 8 Sep 2023 23:47:30 +0000 Subject: [PATCH 2/2] style: Format code with black --- lynxie/utils.py | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/lynxie/utils.py b/lynxie/utils.py index c9c7c2a..d2e581b 100644 --- a/lynxie/utils.py +++ b/lynxie/utils.py @@ -8,40 +8,42 @@ from discord.gateway import _log async def mobile_status(self): payload = { - 'op': self.IDENTIFY, - 'd': { - 'token': self.token, - 'properties': { - '$os': sys.platform, - '$browser': 'Discord Android', - '$device': 'Discord Android', - '$referrer': '', - '$referring_domain': '' + "op": self.IDENTIFY, + "d": { + "token": self.token, + "properties": { + "$os": sys.platform, + "$browser": "Discord Android", + "$device": "Discord Android", + "$referrer": "", + "$referring_domain": "", }, - 'compress': True, - 'large_threshold': 250, - 'v': 3 - } + "compress": True, + "large_threshold": 250, + "v": 3, + }, } if self.shard_id is not None and self.shard_count is not None: - payload['d']['shard'] = [self.shard_id, self.shard_count] + payload["d"]["shard"] = [self.shard_id, self.shard_count] state = self._connection if state._activity is not None or state._status is not None: - payload['d']['presence'] = { - 'status': state._status, - 'game': state._activity, - 'since': 0, - 'afk': False + payload["d"]["presence"] = { + "status": state._status, + "game": state._activity, + "since": 0, + "afk": False, } if state._intents is not None: - payload['d']['intents'] = state._intents.value + payload["d"]["intents"] = state._intents.value - await self.call_hooks('before_identify', self.shard_id, initial=self._initial_identify) + await self.call_hooks( + "before_identify", self.shard_id, initial=self._initial_identify + ) await self.send_as_json(payload) - _log.info('Shard ID %s has sent the IDENTIFY payload.', self.shard_id) + _log.info("Shard ID %s has sent the IDENTIFY payload.", self.shard_id) def error_message(error: str) -> discord.Embed: