@@ -50,7 +50,7 @@ class Monty(commands.Bot):
5050
5151 name = constants .Client .name
5252
53- def __init__ (self , redis_session : redis .asyncio .Redis , proxy : str = None , ** kwargs ) -> None :
53+ def __init__ (self , redis_session : redis .asyncio .Redis , proxy : str | None = None , ** kwargs ) -> None :
5454 if TEST_GUILDS :
5555 kwargs ["test_guilds" ] = TEST_GUILDS
5656 log .warning ("registering as test_guilds" )
@@ -87,7 +87,7 @@ def db(self) -> async_sessionmaker[AsyncSession]:
8787 """Alias of `bot.db_session`."""
8888 return self .db_session
8989
90- def create_http_session (self , proxy : str = None ) -> None :
90+ def create_http_session (self , proxy : str | None = None ) -> None :
9191 """Create the bot's aiohttp session."""
9292 self .http_session = CachingClientSession (proxy = proxy )
9393
@@ -163,17 +163,16 @@ async def _create_features(self) -> None:
163163 """Update the database with all features defined immediately upon launch. No more lazy creation."""
164164 await self .wait_until_first_connect ()
165165
166- async with self ._feature_db_lock :
167- async with self .db .begin () as session :
168- stmt = sa .select (Feature ).options (selectinload (Feature .rollout ))
169- result = await session .scalars (stmt )
170- existing_feature_names = {feature .name for feature in result .all ()}
171- for feature_enum in constants .Feature :
172- if feature_enum .value in existing_feature_names :
173- continue
174- feature_instance = Feature (feature_enum .value )
175- session .add (feature_instance )
176- await session .commit () # this will error out if it cannot be made
166+ async with self ._feature_db_lock , self .db .begin () as session :
167+ stmt = sa .select (Feature ).options (selectinload (Feature .rollout ))
168+ result = await session .scalars (stmt )
169+ existing_feature_names = {feature .name for feature in result .all ()}
170+ for feature_enum in constants .Feature :
171+ if feature_enum .value in existing_feature_names :
172+ continue
173+ feature_instance = Feature (feature_enum .value )
174+ session .add (feature_instance )
175+ await session .commit () # this will error out if it cannot be made
177176
178177 await self .refresh_features ()
179178
@@ -228,9 +227,8 @@ async def guild_has_feature(
228227 self .features [feature ] = feature_instance
229228 # we're defaulting to non-existing features as None, rather than False.
230229 # this might change later.
231- if include_feature_status and feature_instance :
232- if feature_instance .enabled is not None :
233- return feature_instance .enabled
230+ if include_feature_status and feature_instance and feature_instance .enabled is not None :
231+ return feature_instance .enabled
234232
235233 # the feature's enabled status is None, so we should check the guild
236234 # support the guild being None to make it easier to use
@@ -353,7 +351,7 @@ def remove_command(self, name: str) -> commands.Command | None:
353351 command = super ().remove_command (name )
354352 if command is None :
355353 # Even if it's a root alias, there's no way to get the Bot instance to remove the alias.
356- return
354+ return None
357355
358356 self .dispatch ("command_remove" , command )
359357 self ._remove_root_aliases (command )
0 commit comments