From 5295880d795c99843d2a05241d8ce48c9cf6f687 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 7 Oct 2024 17:31:37 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- Backend/alembic/versions/2b04ec01b78e_.py | 1 + Backend/alembic/versions/37f73a9d15d5_.py | 1 + Backend/alembic/versions/73765744a1f6_.py | 1 + Backend/alembic/versions/ef97c8cef951_.py | 1 + Backend/alembic/versions/fe382d5e9771_.py | 1 + Backend/bungio/manifest.py | 28 +++++++------ Backend/core/destiny/profile.py | 14 +++---- Backend/crud/destiny/activities.py | 12 +++--- Backend/crud/destiny/discordUsers.py | 6 ++- Backend/database/models.py | 1 + ElevatorBot/commandHelpers/optionTemplates.py | 16 +++++--- .../commands/c_admin/setup/overview.py | 40 ++++++++++++------- ElevatorBot/core/destiny/dayOneRace.py | 4 +- ElevatorBot/core/destiny/lfg/lfgSystem.py | 28 +++++++------ ElevatorBot/core/misc/ticTacToe.py | 8 ++-- ElevatorBot/networking/http.py | 30 +++++++------- ElevatorBot/static/emojis.py | 2 +- Shared/networkingSchemas/destiny/roles.py | 6 +-- 18 files changed, 117 insertions(+), 83 deletions(-) diff --git a/Backend/alembic/versions/2b04ec01b78e_.py b/Backend/alembic/versions/2b04ec01b78e_.py index 64d0b992..0614cde4 100644 --- a/Backend/alembic/versions/2b04ec01b78e_.py +++ b/Backend/alembic/versions/2b04ec01b78e_.py @@ -5,6 +5,7 @@ Create Date: 2022-06-01 16:16:48.372839+00:00 """ + from alembic import op import sqlalchemy as sa from sqlalchemy.dialects import postgresql diff --git a/Backend/alembic/versions/37f73a9d15d5_.py b/Backend/alembic/versions/37f73a9d15d5_.py index f1fe0148..a50a0167 100644 --- a/Backend/alembic/versions/37f73a9d15d5_.py +++ b/Backend/alembic/versions/37f73a9d15d5_.py @@ -5,6 +5,7 @@ Create Date: 2022-04-02 10:42:18.076326+00:00 """ + import sqlalchemy as sa from alembic import op diff --git a/Backend/alembic/versions/73765744a1f6_.py b/Backend/alembic/versions/73765744a1f6_.py index ccf9ecca..fc689bdf 100644 --- a/Backend/alembic/versions/73765744a1f6_.py +++ b/Backend/alembic/versions/73765744a1f6_.py @@ -5,6 +5,7 @@ Create Date: 2022-04-02 11:19:02.574169+00:00 """ + import sqlalchemy as sa from alembic import op diff --git a/Backend/alembic/versions/ef97c8cef951_.py b/Backend/alembic/versions/ef97c8cef951_.py index 993e3a0c..15fd3f45 100644 --- a/Backend/alembic/versions/ef97c8cef951_.py +++ b/Backend/alembic/versions/ef97c8cef951_.py @@ -5,6 +5,7 @@ Create Date: 2022-06-01 14:51:34.843488+00:00 """ + import sqlalchemy as sa from alembic import op diff --git a/Backend/alembic/versions/fe382d5e9771_.py b/Backend/alembic/versions/fe382d5e9771_.py index 4b764d6f..3c5383cc 100644 --- a/Backend/alembic/versions/fe382d5e9771_.py +++ b/Backend/alembic/versions/fe382d5e9771_.py @@ -5,6 +5,7 @@ Create Date: 2022-08-02 08:30:27.944319+00:00 """ + import sqlalchemy as sa from alembic import op from sqlalchemy.dialects import postgresql diff --git a/Backend/bungio/manifest.py b/Backend/bungio/manifest.py index e7eb433a..43cce7e8 100644 --- a/Backend/bungio/manifest.py +++ b/Backend/bungio/manifest.py @@ -265,9 +265,9 @@ async def get_all_activities(self) -> dict[int, DestinyActivityModel]: activity_ids=[activity.hash for activity in activities], mode=mode.value, modes=[m.value for m in modes], - image_url=f"https://www.bungie.net/{activities[0].pgcr_image}" - if activities[0].pgcr_image - else None, + image_url=( + f"https://www.bungie.net/{activities[0].pgcr_image}" if activities[0].pgcr_image else None + ), ) for reference_id in model.activity_ids: result[reference_id] = model @@ -319,9 +319,9 @@ async def get_seals(self) -> dict[DestinyPresentationNodeDefinition, list[Destin async with get_seals_lock: if not self._manifest_seals: - presentation_nodes: list[ - DestinyPresentationNodeDefinition - ] = await get_bungio_client().manifest.fetch_all(manifest_class=DestinyPresentationNodeDefinition) + presentation_nodes: list[DestinyPresentationNodeDefinition] = ( + await get_bungio_client().manifest.fetch_all(manifest_class=DestinyPresentationNodeDefinition) + ) seals = [] for node in presentation_nodes: @@ -428,9 +428,11 @@ async def get_grandmaster_nfs(self) -> list[DestinyActivityModel]: activity_ids=reference_ids, mode=mode.value, modes=[m.value for m in modes], - image_url=f"https://www.bungie.net/{activities[0].pgcr_image}" - if activities[0].pgcr_image - else None, + image_url=( + f"https://www.bungie.net/{activities[0].pgcr_image}" + if activities[0].pgcr_image + else None + ), ) ) @@ -516,9 +518,11 @@ async def get_challenging_solo_activities(self) -> dict[str, list[DestinyActivit activity_ids=[activity.hash], mode=mode.value, modes=[m.value for m in modes], - image_url=f"https://www.bungie.net/{activity.pgcr_image}" - if activity.pgcr_image - else None, + image_url=( + f"https://www.bungie.net/{activity.pgcr_image}" + if activity.pgcr_image + else None + ), ) else: data.activity_ids.append(activity.hash) diff --git a/Backend/core/destiny/profile.py b/Backend/core/destiny/profile.py index fee19a68..bf5821da 100644 --- a/Backend/core/destiny/profile.py +++ b/Backend/core/destiny/profile.py @@ -827,9 +827,7 @@ async def get_time_played( character_class=character_class, ) - async def get_character_items( - self, character_id: int - ) -> dict[ + async def get_character_items(self, character_id: int) -> dict[ Literal["helmet", "gauntlets", "chest", "leg", "class"], dict[Literal["equipped", "inventory"], list[DestinyItemComponent]], ]: @@ -904,9 +902,7 @@ async def get_character_items( return items - async def __get_inventory_bucket( - self, *buckets: DestinyInventoryBucketEnum - ) -> dict[ + async def __get_inventory_bucket(self, *buckets: DestinyInventoryBucketEnum) -> dict[ DestinyInventoryBucketEnum, dict[int, dict[Literal["item", "power_level", "quantity"], DestinyItemComponent | int]], ]: @@ -988,9 +984,9 @@ def add_info( result_dict[char_id][bucket].update({item.item_instance_id: {"item": item}}) if include_item_level: try: - result_dict[char_id][bucket][item.item_instance_id][ - "power_level" - ] = result.item_components.instances.data[item.item_instance_id].primary_stat.value + result_dict[char_id][bucket][item.item_instance_id]["power_level"] = ( + result.item_components.instances.data[item.item_instance_id].primary_stat.value + ) except KeyError: pass break diff --git a/Backend/crud/destiny/activities.py b/Backend/crud/destiny/activities.py index b725fd52..7fe8707c 100644 --- a/Backend/crud/destiny/activities.py +++ b/Backend/crud/destiny/activities.py @@ -142,14 +142,14 @@ def _convert_to_model( player_count=int(player_pgcr.values["playerCount"].basic.value), team_score=int(player_pgcr.values["teamScore"].basic.value), precision_kills=int(extended_data.values["precisionKills"].basic.value) if extended_data else 0, - weapon_kills_grenade=int(extended_data.values["weaponKillsGrenade"].basic.value) - if extended_data - else 0, + weapon_kills_grenade=( + int(extended_data.values["weaponKillsGrenade"].basic.value) if extended_data else 0 + ), weapon_kills_melee=int(extended_data.values["weaponKillsMelee"].basic.value) if extended_data else 0, weapon_kills_super=int(extended_data.values["weaponKillsSuper"].basic.value) if extended_data else 0, - weapon_kills_ability=int(extended_data.values["weaponKillsAbility"].basic.value) - if extended_data - else 0, + weapon_kills_ability=( + int(extended_data.values["weaponKillsAbility"].basic.value) if extended_data else 0 + ), ) if extended_data: diff --git a/Backend/crud/destiny/discordUsers.py b/Backend/crud/destiny/discordUsers.py index e4e86493..9b3277a0 100644 --- a/Backend/crud/destiny/discordUsers.py +++ b/Backend/crud/destiny/discordUsers.py @@ -85,7 +85,11 @@ async def insert_profile( # split the state (discord_id, guild_id, channel_id) = state.split(":") - discord_id, guild_id, channel_id, = ( + ( + discord_id, + guild_id, + channel_id, + ) = ( int(discord_id), int(guild_id), int(channel_id), diff --git a/Backend/database/models.py b/Backend/database/models.py index d59a423e..b206c8ba 100644 --- a/Backend/database/models.py +++ b/Backend/database/models.py @@ -223,6 +223,7 @@ class ElevatorServers(Base): ################################################################ # Roles + # for activities class RolesActivity(Base): __tablename__ = "rolesActivity" diff --git a/ElevatorBot/commandHelpers/optionTemplates.py b/ElevatorBot/commandHelpers/optionTemplates.py index 18024106..4eca8fe8 100644 --- a/ElevatorBot/commandHelpers/optionTemplates.py +++ b/ElevatorBot/commandHelpers/optionTemplates.py @@ -173,9 +173,11 @@ def wrapper(func): choices=[ SlashCommandChoice( name=expansion.name, - value=f"{expansion.name}|{int(expansion.start.timestamp())}|{int(expansion_dates[(expansion_dates.index(expansion) + 1)].start.timestamp())}" - if expansion_dates.index(expansion) + 1 < len(expansion_dates) - else f"{expansion.name}|{int(expansion.start.timestamp())}|9999999999", + value=( + f"{expansion.name}|{int(expansion.start.timestamp())}|{int(expansion_dates[(expansion_dates.index(expansion) + 1)].start.timestamp())}" + if expansion_dates.index(expansion) + 1 < len(expansion_dates) + else f"{expansion.name}|{int(expansion.start.timestamp())}|9999999999" + ), ) for expansion in expansion_dates ], @@ -205,9 +207,11 @@ def wrapper(func): choices=[ SlashCommandChoice( name=season.name, - value=f"{season.name}|{int(season.start.timestamp())}|{int(season_and_expansion_dates[(season_and_expansion_dates.index(season) + 1)].start.timestamp())}" - if season_and_expansion_dates.index(season) + 1 < len(season_and_expansion_dates) - else f"{season.name}|{int(season.start.timestamp())}|9999999999", + value=( + f"{season.name}|{int(season.start.timestamp())}|{int(season_and_expansion_dates[(season_and_expansion_dates.index(season) + 1)].start.timestamp())}" + if season_and_expansion_dates.index(season) + 1 < len(season_and_expansion_dates) + else f"{season.name}|{int(season.start.timestamp())}|9999999999" + ), ) for season in season_and_expansion_dates ], diff --git a/ElevatorBot/commands/c_admin/setup/overview.py b/ElevatorBot/commands/c_admin/setup/overview.py index cb1c8432..8f2fc723 100644 --- a/ElevatorBot/commands/c_admin/setup/overview.py +++ b/ElevatorBot/commands/c_admin/setup/overview.py @@ -45,9 +45,11 @@ async def overview(self, ctx: ElevatorInteractionContext): obj = handy_dict["clan_join_request"] if "clan_join_request" in handy_dict else None embed.add_field( name="Clan Join Button", - value=f"[Click To View The Linked Message](https://canary.discord.com/channels/{obj.guild_id}/{obj.channel_id}/{obj.message_id})" - if obj - else "Not Set-Up", + value=( + f"[Click To View The Linked Message](https://canary.discord.com/channels/{obj.guild_id}/{obj.channel_id}/{obj.message_id})" + if obj + else "Not Set-Up" + ), inline=True, ) @@ -75,9 +77,11 @@ async def overview(self, ctx: ElevatorInteractionContext): obj = handy_dict["increment_button"] if "increment_button" in handy_dict else None embed.add_field( name="Increment Button", - value=f"[Click To View The Linked Message](https://canary.discord.com/channels/{obj.guild_id}/{obj.channel_id}/{obj.message_id})" - if obj - else "Not Set-Up", + value=( + f"[Click To View The Linked Message](https://canary.discord.com/channels/{obj.guild_id}/{obj.channel_id}/{obj.message_id})" + if obj + else "Not Set-Up" + ), inline=True, ) @@ -91,9 +95,11 @@ async def overview(self, ctx: ElevatorInteractionContext): obj = handy_dict["registration"] if "registration" in handy_dict else None embed.add_field( name="Registration Button", - value=f"[Click To View The Linked Message](https://canary.discord.com/channels/{obj.guild_id}/{obj.channel_id}/{obj.message_id})" - if obj - else "Not Set-Up", + value=( + f"[Click To View The Linked Message](https://canary.discord.com/channels/{obj.guild_id}/{obj.channel_id}/{obj.message_id})" + if obj + else "Not Set-Up" + ), inline=True, ) @@ -117,18 +123,22 @@ async def overview(self, ctx: ElevatorInteractionContext): obj = handy_dict["other_game_roles"] if "other_game_roles" in handy_dict else None embed.add_field( name="Miscellaneous Roles Message", - value=f"[Click To View The Linked Message](https://canary.discord.com/channels/{obj.guild_id}/{obj.channel_id}/{obj.message_id})" - if obj - else "Not Set-Up", + value=( + f"[Click To View The Linked Message](https://canary.discord.com/channels/{obj.guild_id}/{obj.channel_id}/{obj.message_id})" + if obj + else "Not Set-Up" + ), inline=False, ) obj = handy_dict["status"] if "status" in handy_dict else None embed.add_field( name="ElevatorBot Status Message", - value=f"[Click To View The Linked Message](https://canary.discord.com/channels/{obj.guild_id}/{obj.channel_id}/{obj.message_id})" - if obj - else "Not Set-Up", + value=( + f"[Click To View The Linked Message](https://canary.discord.com/channels/{obj.guild_id}/{obj.channel_id}/{obj.message_id})" + if obj + else "Not Set-Up" + ), inline=True, ) diff --git a/ElevatorBot/core/destiny/dayOneRace.py b/ElevatorBot/core/destiny/dayOneRace.py index 3012cf6f..2aac3c82 100644 --- a/ElevatorBot/core/destiny/dayOneRace.py +++ b/ElevatorBot/core/destiny/dayOneRace.py @@ -55,7 +55,9 @@ class DayOneRace: cutoff_time: datetime.datetime = datetime.datetime(2021, 5, 23, 17, 0, tzinfo=datetime.timezone.utc) # cosmetic data for the raid - image_url: str = "https://static.wikia.nocookie.net/destinypedia/images/6/62/Vault.jpg/revision/latest/scale-to-width-down/1000?cb=20150330170833" + image_url: str = ( + "https://static.wikia.nocookie.net/destinypedia/images/6/62/Vault.jpg/revision/latest/scale-to-width-down/1000?cb=20150330170833" + ) raid_name: str = "Vault of Glass" location_name: str = "Ishtar Sink, Venus" diff --git a/ElevatorBot/core/destiny/lfg/lfgSystem.py b/ElevatorBot/core/destiny/lfg/lfgSystem.py index d3ba24af..063ec95d 100644 --- a/ElevatorBot/core/destiny/lfg/lfgSystem.py +++ b/ElevatorBot/core/destiny/lfg/lfgSystem.py @@ -166,9 +166,9 @@ async def from_lfg_output_model( joined_ids=model.joined_members, backup_ids=model.backup_members, voice_channel=await client.fetch_channel(model.voice_channel_id) if model.voice_channel_id else None, - voice_category_channel=await client.fetch_channel(model.voice_category_channel_id) - if model.voice_category_channel_id - else None, + voice_category_channel=( + await client.fetch_channel(model.voice_category_channel_id) if model.voice_category_channel_id else None + ), started=model.started, ) @@ -280,9 +280,11 @@ async def create( description=description, start_time=start_time, max_joined_members=max_joined_members, - voice_category_channel=await ctx.bot.fetch_channel(result.voice_category_channel_id) - if result.voice_category_channel_id - else None, + voice_category_channel=( + await ctx.bot.fetch_channel(result.voice_category_channel_id) + if result.voice_category_channel_id + else None + ), joined_ids=[ctx.author.id], started=result.started, ) @@ -664,12 +666,14 @@ async def __sort_lfg_messages(self): creation_time=event.creation_time, joined_ids=event.joined_members, backup_ids=event.backup_members, - voice_channel=await self.client.fetch_channel(event.voice_channel_id) - if event.voice_channel_id - else None, - voice_category_channel=await self.client.fetch_channel(event.voice_category_channel_id) - if event.voice_category_channel_id - else None, + voice_channel=( + await self.client.fetch_channel(event.voice_channel_id) if event.voice_channel_id else None + ), + voice_category_channel=( + await self.client.fetch_channel(event.voice_category_channel_id) + if event.voice_category_channel_id + else None + ), started=event.started, ) ) diff --git a/ElevatorBot/core/misc/ticTacToe.py b/ElevatorBot/core/misc/ticTacToe.py index 402267b0..515f52dc 100644 --- a/ElevatorBot/core/misc/ticTacToe.py +++ b/ElevatorBot/core/misc/ticTacToe.py @@ -333,9 +333,11 @@ async def send_message( if not self.message: embed = embed_message( f"{self.ctx.author.display_name}'s TicTacToe Game", - footer=f"""You are green{f" - Easy Mode: On" if self.easy_mode else ""}""" - if not self.versus - else "First user to press a button plays green, second plays red", + footer=( + f"""You are green{f" - Easy Mode: On" if self.easy_mode else ""}""" + if not self.versus + else "First user to press a button plays green, second plays red" + ), ) self.message = await self.ctx.send(components=self.buttons, embeds=embed) else: diff --git a/ElevatorBot/networking/http.py b/ElevatorBot/networking/http.py index 34e1452e..107ae37e 100644 --- a/ElevatorBot/networking/http.py +++ b/ElevatorBot/networking/http.py @@ -27,20 +27,22 @@ address=f"""redis://{os.environ.get("REDIS_HOST")}:{os.environ.get("REDIS_PORT")}""", allowed_methods=["GET", "POST"] if not get_setting("ENABLE_DEBUG_MODE") else [], expire_after=0, # only save selected stuff - urls_expire_after={ - "**/destiny/account": timedelta(minutes=30), - "**/destiny/activities/**/last": 0, # never save last activity - "**/destiny/activities/**/get/all": 0, # never activity ids - "**/destiny/activities/**/get/grandmaster": 0, # never grandmaster ids - "**/destiny/activities": timedelta(minutes=30), - "**/destiny/items/lore/get/all": 0, # never save lore ids - "**/destiny/roles/*/*/get/all": timedelta(minutes=30), # user roles - "**/destiny/roles/*/*/get/missing": timedelta(minutes=30), # user roles - "**/destiny/weapons/**/top": timedelta(minutes=60), # user top weapons - "**/destiny/weapons/**/weapon": timedelta(minutes=60), # user weapon - } - if not get_setting("ENABLE_DEBUG_MODE") - else {}, + urls_expire_after=( + { + "**/destiny/account": timedelta(minutes=30), + "**/destiny/activities/**/last": 0, # never save last activity + "**/destiny/activities/**/get/all": 0, # never activity ids + "**/destiny/activities/**/get/grandmaster": 0, # never grandmaster ids + "**/destiny/activities": timedelta(minutes=30), + "**/destiny/items/lore/get/all": 0, # never save lore ids + "**/destiny/roles/*/*/get/all": timedelta(minutes=30), # user roles + "**/destiny/roles/*/*/get/missing": timedelta(minutes=30), # user roles + "**/destiny/weapons/**/top": timedelta(minutes=60), # user top weapons + "**/destiny/weapons/**/weapon": timedelta(minutes=60), # user weapon + } + if not get_setting("ENABLE_DEBUG_MODE") + else {} + ), ) _no_default = object() diff --git a/ElevatorBot/static/emojis.py b/ElevatorBot/static/emojis.py index 71b0b288..ff29322e 100644 --- a/ElevatorBot/static/emojis.py +++ b/ElevatorBot/static/emojis.py @@ -14,7 +14,7 @@ def __init__(self): # !!! # Either the moji id must be correct, or the emoji name on discord must be the same as in the class here # !!! - + # DESCEND [BL] self.kinetic: CustomEmoji | int = 906180170875031562 diff --git a/Shared/networkingSchemas/destiny/roles.py b/Shared/networkingSchemas/destiny/roles.py index 6be31bc7..de7f9ed3 100644 --- a/Shared/networkingSchemas/destiny/roles.py +++ b/Shared/networkingSchemas/destiny/roles.py @@ -157,9 +157,9 @@ def from_sql_model(cls, db_model: Roles): RequirementIntegerModel.from_orm(record) for record in db_model.requirement_require_records ], require_role_ids=[role.role_id for role in db_model.requirement_require_roles], - replaced_by_role_id=db_model.requirement_replaced_by_role.role_id - if db_model.requirement_replaced_by_role - else None, + replaced_by_role_id=( + db_model.requirement_replaced_by_role.role_id if db_model.requirement_replaced_by_role else None + ), )