From c4a2c77b4c5d0c67fd100d89eff4c79517cb72ca Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 7 Feb 2023 03:19:12 +0000 Subject: [PATCH 1/2] ci: weekly check. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 22.12.0 → 23.1.0](https://github.com/psf/black/compare/22.12.0...23.1.0) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 89784c504..a05cbfdfd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -29,7 +29,7 @@ repos: - id: check-merge-conflict name: Merge Conflicts - repo: https://github.com/psf/black - rev: 22.12.0 + rev: 23.1.0 hooks: - id: black name: Black Formatting From 9a1d282629a513fb38aa8cf544f92203d005eccb Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 7 Feb 2023 03:19:26 +0000 Subject: [PATCH 2/2] ci: correct from checks. --- interactions/api/cache.py | 1 - interactions/api/dispatch.py | 1 - interactions/api/error.py | 1 - interactions/api/gateway/client.py | 4 ---- interactions/api/http/interaction.py | 2 -- interactions/api/http/message.py | 2 -- interactions/api/http/thread.py | 1 - interactions/api/http/user.py | 1 - interactions/api/http/webhook.py | 2 -- interactions/api/models/channel.py | 4 ---- interactions/api/models/guild.py | 5 ----- interactions/api/models/misc.py | 2 -- interactions/client/bot.py | 3 --- interactions/client/context.py | 2 -- interactions/client/models/component.py | 1 - interactions/utils/get.py | 1 - 16 files changed, 33 deletions(-) diff --git a/interactions/api/cache.py b/interactions/api/cache.py index 03ca04265..3d0e92cf8 100644 --- a/interactions/api/cache.py +++ b/interactions/api/cache.py @@ -66,7 +66,6 @@ def merge(self, item: _T, id: Optional["Key"] = None) -> None: continue # we can only assume that discord did not provide it, falsely deleting is worse than not deleting if getattr(old_item, attrib) != getattr(item, attrib): - if isinstance(getattr(item, attrib), list) and not isinstance( getattr(old_item, attrib), list ): # could be None diff --git a/interactions/api/dispatch.py b/interactions/api/dispatch.py index bb06c37db..840311e46 100644 --- a/interactions/api/dispatch.py +++ b/interactions/api/dispatch.py @@ -37,7 +37,6 @@ def dispatch(self, name: str, /, *args, **kwargs) -> None: if converters := getattr(event, "_converters", None): _kwargs = kwargs.copy() for key, value in _kwargs.items(): - if key in converters.keys(): del kwargs[key] kwargs[converters[key]] = value diff --git a/interactions/api/error.py b/interactions/api/error.py index 77a7e8869..58957082b 100644 --- a/interactions/api/error.py +++ b/interactions/api/error.py @@ -317,7 +317,6 @@ def __init__(self, code: int = 0, message: str = None, severity: int = 0, **kwar self.log(self.message) if _fmt_error: - _flag: bool = ( self.message.lower() in self.lookup(self.code).lower() ) # creativity is hard diff --git a/interactions/api/gateway/client.py b/interactions/api/gateway/client.py index 9440bc6cc..8667284a2 100644 --- a/interactions/api/gateway/client.py +++ b/interactions/api/gateway/client.py @@ -241,7 +241,6 @@ async def _manage_heartbeat(self) -> None: """Manages the heartbeat loop.""" log.debug(f"Sending heartbeat every {self.__heartbeater.delay / 1000} seconds...") while not self.__heartbeat_event.is_set(): - log.debug("Sending heartbeat...") if not self.__heartbeater.event.is_set(): log.debug("HEARTBEAT_ACK missing, reconnecting...") @@ -967,7 +966,6 @@ async def __receive_packet(self, ignore_lock: bool = False) -> Optional[Dict[str buffer = bytearray() while True: - if not ignore_lock: # meaning if we're reconnecting or something because of tasks await self.__closed.wait() @@ -1007,7 +1005,6 @@ async def __receive_packet(self, ignore_lock: bool = False) -> Optional[Dict[str await self._reconnect(True) elif packet.type == WSMsgType.CLOSING: - if ignore_lock: raise LibraryException( message="Discord unexpectedly closing on receiving by force.", severity=50 @@ -1065,7 +1062,6 @@ async def _send_packet(self, data: Dict[str, Any]) -> None: await self._client.send_str(packet) else: async with self.reconnect_lock: # needs to lock while it reconnects. - if data["op"] != OpCodeType.HEARTBEAT.value: # This is because the ratelimiter limits already accounts for this. await self._ratelimiter.block() diff --git a/interactions/api/http/interaction.py b/interactions/api/http/interaction.py index 1c0945fcd..19f23f404 100644 --- a/interactions/api/http/interaction.py +++ b/interactions/api/http/interaction.py @@ -236,7 +236,6 @@ async def create_interaction_response( file_data = None if files: - file_data = MultipartWriter("form-data") part = file_data.append_json(data) part.set_content_disposition("form-data", name="payload_json") @@ -295,7 +294,6 @@ async def edit_interaction_response( # ^ again, I don't know if python will let me file_data = None if files: - file_data = MultipartWriter("form-data") part = file_data.append_json(data) part.set_content_disposition("form-data", name="payload_json") diff --git a/interactions/api/http/message.py b/interactions/api/http/message.py index a86e3ce11..c55c19794 100644 --- a/interactions/api/http/message.py +++ b/interactions/api/http/message.py @@ -84,7 +84,6 @@ async def create_message( data = None if files is not MISSING and len(files) > 0: - data = MultipartWriter("form-data") part = data.append_json(payload) part.set_content_disposition("form-data", name="payload_json") @@ -172,7 +171,6 @@ async def edit_message( """ data = None if files is not MISSING and len(files) > 0: - data = MultipartWriter("form-data") part = data.append_json(payload) part.set_content_disposition("form-data", name="payload_json") diff --git a/interactions/api/http/thread.py b/interactions/api/http/thread.py index 6ae7e8cc9..ed1332c94 100644 --- a/interactions/api/http/thread.py +++ b/interactions/api/http/thread.py @@ -231,7 +231,6 @@ async def create_thread_in_forum( data = None if files is not MISSING and files and len(files) > 0: # edge case `None` - data = MultipartWriter("form-data") part = data.append_json(payload) part.set_content_disposition("form-data", name="payload_json") diff --git a/interactions/api/http/user.py b/interactions/api/http/user.py index d9008044b..54dde6ed3 100644 --- a/interactions/api/http/user.py +++ b/interactions/api/http/user.py @@ -10,7 +10,6 @@ class UserRequest: - _req: _Request cache: Cache diff --git a/interactions/api/http/webhook.py b/interactions/api/http/webhook.py index 467c83f39..fdc607710 100644 --- a/interactions/api/http/webhook.py +++ b/interactions/api/http/webhook.py @@ -12,7 +12,6 @@ class WebhookRequest: - _req: _Request cache: Cache @@ -121,7 +120,6 @@ async def execute_webhook( data = None if files is not MISSING and len(files) > 0: - data = MultipartWriter("form-data") part = data.append_json(payload) part.set_content_disposition("form-data", name="payload_json") diff --git a/interactions/api/models/channel.py b/interactions/api/models/channel.py index 648643cf1..4183b3719 100644 --- a/interactions/api/models/channel.py +++ b/interactions/api/models/channel.py @@ -233,7 +233,6 @@ async def __anext__(self) -> "Message": obj = self.objects.pop(0) if self.check: - res = self.check(obj) _res = await res if isawaitable(res) else res while not _res: @@ -272,7 +271,6 @@ def __init__( obj: Union[int, str, "Snowflake", "Channel"], _client: "HTTPClient", ): - try: self.loop = get_running_loop() except RuntimeError as e: @@ -1325,7 +1323,6 @@ async def bulk_delete(): _allowed_time = datetime.now(tz=timezone.utc) - timedelta(days=14) _stop = False while amount > 100: - messages = [ Message(**res) for res in await self._client.get_channel_messages( @@ -1941,7 +1938,6 @@ async def create_forum_post( _content["attachments"].append(attach._json) else: - _data = await attach.download() __files.append(File(attach.filename, _data)) diff --git a/interactions/api/models/guild.py b/interactions/api/models/guild.py index 86f45d7db..fe44949b6 100644 --- a/interactions/api/models/guild.py +++ b/interactions/api/models/guild.py @@ -248,7 +248,6 @@ def __init__( start_at: Optional[Union[int, str, Snowflake, Member]] = MISSING, check: Optional[Callable[[Member], Union[bool, Awaitable[bool]]]] = None, ): - self.__stop: bool = False super().__init__(obj, _client, maximum=maximum, start_at=start_at, check=check) @@ -258,7 +257,6 @@ def __init__( self.objects: Optional[List[Member]] async def get_first_objects(self) -> None: - limit = min(self.maximum, 1000) if self.maximum == limit: @@ -280,7 +278,6 @@ async def get_first_objects(self) -> None: ] async def get_objects(self) -> None: - limit = min(500, self.maximum - self.object_count) members = await self._client.get_list_of_members( guild_id=self.object_id, after=self.after, limit=limit @@ -309,7 +306,6 @@ async def __anext__(self) -> Member: obj = self.objects.pop(0) if self.check: - res = self.check(obj) _res = await res if isawaitable(res) else res while not _res: @@ -2070,7 +2066,6 @@ async def get_all_bans(self) -> List[Dict[str, User]]: res: list = await self._client.get_guild_bans(int(self.id), limit=1000) while len(res) >= 1000: - for ban in res: ban["user"] = User(**ban["user"]) _all.extend(res) diff --git a/interactions/api/models/misc.py b/interactions/api/models/misc.py index c9e9e6d80..d707e7b11 100644 --- a/interactions/api/models/misc.py +++ b/interactions/api/models/misc.py @@ -348,7 +348,6 @@ class File: def __init__( self, filename: str, fp: Optional[IOBase] = MISSING, description: Optional[str] = MISSING ): - if not isinstance(filename, str): raise LibraryException( message=f"File's first parameter 'filename' must be a string, not {str(type(filename))}", @@ -378,7 +377,6 @@ class Image: """ def __init__(self, file: Union[str, FileIO], fp: Optional[IOBase] = MISSING): - self._URI = "data:image/" if fp is MISSING or isinstance(file, FileIO): diff --git a/interactions/client/bot.py b/interactions/client/bot.py index d4d66773e..b7b3a6478 100644 --- a/interactions/client/bot.py +++ b/interactions/client/bot.py @@ -369,7 +369,6 @@ def __check_options(command, data): return clean, _command elif command.get("options") and data.get("options"): - clean = __check_options(command, data) if not clean: @@ -538,7 +537,6 @@ async def _get_all_guilds(self) -> List[dict]: res = await self._http.get_self_guilds(limit=200) while len(res) >= 200: - _all.extend(res) _after = int(res[-1]["id"]) @@ -1513,7 +1511,6 @@ def remove( for ext_name, ext in getmembers( extension, lambda x: isinstance(x, type) and issubclass(x, Extension) ): - if ext_name != "Extension": _extension = self._extensions.get(ext_name) with contextlib.suppress(AttributeError): diff --git a/interactions/client/context.py b/interactions/client/context.py index 182fbf05c..0926ccaf5 100644 --- a/interactions/client/context.py +++ b/interactions/client/context.py @@ -281,7 +281,6 @@ async def send( and self.message and self.callback == InteractionCallbackType.DEFERRED_UPDATE_MESSAGE ): - if isinstance(self.message.components, list): _components = self.message.components else: @@ -552,7 +551,6 @@ def __attrs_post_init__(self) -> None: async def edit( self, content: Optional[str] = MISSING, **kwargs ) -> Message: # sourcery skip: low-code-quality - payload, files = await super().edit(content, **kwargs) msg = None diff --git a/interactions/client/models/component.py b/interactions/client/models/component.py index db4f677db..194f27919 100644 --- a/interactions/client/models/component.py +++ b/interactions/client/models/component.py @@ -277,7 +277,6 @@ def new(cls, *components: Union[Button, SelectMenu, TextInput]) -> List["ActionR def _build_components(components) -> List[dict]: # sourcery no-metrics def __check_action_row(): - if isinstance(components, list) and all( isinstance(action_row, (list, ActionRow)) for action_row in components ): diff --git a/interactions/utils/get.py b/interactions/utils/get.py index 6c49bdc95..6501a73d3 100644 --- a/interactions/utils/get.py +++ b/interactions/utils/get.py @@ -318,7 +318,6 @@ def _get_cache( def _resolve_kwargs(obj, **kwargs): # This function is needed to get correct kwarg names if __id := kwargs.pop("parent_id", None): - if version_info >= (3, 9): _list = [Message, List[Message], list[Message]] else: