Skip to content

Commit

Permalink
Resolve deprecated pkg_resources warning
Browse files Browse the repository at this point in the history
raidensakura committed Dec 22, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 357d5cc commit 1bdcf2e
Showing 5 changed files with 12 additions and 11 deletions.
6 changes: 3 additions & 3 deletions bot.py
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@
from discord.ext.commands import MemberConverter
from discord.ext.commands.view import StringView
from emoji import UNICODE_EMOJI
from pkg_resources import parse_version
from packaging import version

from core.blocklist import Blocklist, BlockReason

@@ -211,7 +211,7 @@ def _configure_logging(self):

@property
def version(self):
return parse_version(__version__)
return version.parse(__version__)

@property
def api(self) -> ApiClient:
@@ -1627,7 +1627,7 @@ async def autoupdate(self):
changelog = await Changelog.from_url(self)
latest = changelog.latest_version

if self.version < parse_version(latest.version):
if self.version < version.parse(latest.version):
error = None
data = {}
try:
6 changes: 3 additions & 3 deletions cogs/plugins.py
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@

import discord
from discord.ext import commands
from pkg_resources import parse_version
from packaging import version

from core import checks
from core.models import PermissionLevel, getLogger
@@ -288,7 +288,7 @@ async def parse_user_input(self, ctx, plugin_name, check_version=False):
if check_version:
required_version = details.get("bot_version", False)

if required_version and self.bot.version < parse_version(required_version):
if required_version and self.bot.version < version.parse(required_version):
embed = discord.Embed(
description="Your bot's version is too low. "
f"This plugin requires version `{required_version}`.",
@@ -672,7 +672,7 @@ async def plugins_registry(self, ctx, *, plugin_name: typing.Union[int, str] = N
embed.set_footer(text="This plugin is currently loaded.")
else:
required_version = details.get("bot_version", False)
if required_version and self.bot.version < parse_version(required_version):
if required_version and self.bot.version < version.parse(required_version):
embed.set_footer(
text="Your bot is unable to install this plugin, "
f"minimum required version is v{required_version}."
8 changes: 4 additions & 4 deletions cogs/utility.py
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@
from discord.enums import ActivityType, Status
from discord.ext import commands, tasks
from discord.ext.commands.view import StringView
from pkg_resources import parse_version
from packaging import version

from core import checks, migrations, utils
from core.changelog import Changelog
@@ -353,9 +353,9 @@ async def about(self, ctx):
latest = changelog.latest_version

if self.bot.version.is_prerelease:
stable = next(filter(lambda v: not parse_version(v.version).is_prerelease, changelog.versions))
stable = next(filter(lambda v: not version.parse(v.version).is_prerelease, changelog.versions))
footer = f"You are on the prerelease version • the latest version is v{stable.version}."
elif self.bot.version < parse_version(latest.version):
elif self.bot.version < version.parse(latest.version):
footer = f"A newer version is available v{latest.version}."
else:
footer = "You are up to date with the latest version."
@@ -2003,7 +2003,7 @@ async def update(self, ctx, *, flag: str = ""):
"(https://github.com/raidensakura/modmail/blob/stable/bot.py#L1)"
)

if self.bot.version >= parse_version(latest.version) and flag.lower() != "force":
if self.bot.version >= version.parse(latest.version) and flag.lower() != "force":
embed = discord.Embed(title="Already up to date", description=desc, color=self.bot.main_color)

data = await self.bot.api.get_user_info()
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -30,6 +30,7 @@ cairocffi = "~=1.3.0"
cffi = "~=1.15.0"
strenum = "*"
"discord.py" = "==2.3.0"
packaging = "^23.2"

[tool.poetry.group.dev.dependencies]
black = "^23.12.0"

0 comments on commit 1bdcf2e

Please sign in to comment.