diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ccb8385..b9b9a44 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -30,4 +30,9 @@ repos: hooks: - id: clean-dotenv + - repo: https://github.com/asottile/pyupgrade + rev: v3.16.0 + hooks: + - id: pyupgrade + exclude: ".archive/" diff --git a/config/parser.py b/config/parser.py index bf4fb7e..82f8602 100644 --- a/config/parser.py +++ b/config/parser.py @@ -10,7 +10,7 @@ class JsonCache: def read_json(path): """Read and cache the JSON data if not already cached.""" if path not in JsonCache._cache: - with open(f"config/JSON/{path}.json", "r") as file: + with open(f"config/JSON/{path}.json") as file: JsonCache._cache[path] = json.load(file) logger.debug(f"{path}.json was loaded and cached.") @@ -25,7 +25,7 @@ class YamlCache: """Read and cache the creds.yaml data if not already cached.""" path = "creds" if path not in YamlCache._cache: - with open(f"{path}.yaml", "r") as file: + with open(f"{path}.yaml") as file: YamlCache._cache[path] = yaml.safe_load(file) logger.debug(f"{path}.yaml was loaded and cached.") diff --git a/handlers/event_handler.py b/handlers/event_handler.py index 805914b..60d61f7 100644 --- a/handlers/event_handler.py +++ b/handlers/event_handler.py @@ -67,7 +67,7 @@ class EventHandler(Cog): @Cog.listener() async def on_command_completion(self, ctx) -> None: - log_msg = "%s executed .%s" % (ctx.author.name, ctx.command.qualified_name) + log_msg = "{} executed .{}".format(ctx.author.name, ctx.command.qualified_name) if ctx.guild is not None: logger.debug(f"{log_msg} | guild: {ctx.guild.name} ") @@ -76,7 +76,7 @@ class EventHandler(Cog): @Cog.listener() async def on_application_command_completion(self, ctx) -> None: - log_msg = "%s executed /%s" % (ctx.author.name, ctx.command.qualified_name) + log_msg = "{} executed /{}".format(ctx.author.name, ctx.command.qualified_name) if ctx.guild is not None: logger.debug(f"{log_msg} | guild: {ctx.guild.name} ") diff --git a/services/help_service.py b/services/help_service.py index 4099458..706335b 100644 --- a/services/help_service.py +++ b/services/help_service.py @@ -19,7 +19,7 @@ class LumiHelp(commands.HelpCommand): } def get_command_qualified_name(self, command): - return "`%s%s`" % (self.context.clean_prefix, command.qualified_name) + return "`{}{}`".format(self.context.clean_prefix, command.qualified_name) async def send_bot_help(self, mapping): embed = discord.Embed(color=discord.Color.blurple()) @@ -52,13 +52,13 @@ class LumiHelp(commands.HelpCommand): description=command.help, ) - usage_value = "`%s%s %s`" % ( + usage_value = "`{}{} {}`".format( self.context.clean_prefix, command.qualified_name, command.signature, ) for alias in command.aliases: - usage_value += "\n`%s%s %s`" % ( + usage_value += "\n`{}{} {}`".format( self.context.clean_prefix, alias, command.signature,