Skip to content

Commit 5482e94

Browse files
committed
Remove pkg_resources and replaced with packaging, updated requirements.txt
1 parent 55f9ba8 commit 5482e94

File tree

6 files changed

+152
-129
lines changed

6 files changed

+152
-129
lines changed

Pipfile

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ emoji = "==2.8.0"
1717
isodate = "==0.6.1"
1818
motor = "==3.3.2"
1919
natural = "==0.2.0" # Why is this needed?
20+
packaging = "==23.2"
2021
parsedatetime = "==2.6"
2122
pymongo = {extras = ["srv"], version = "*"} # Required by motor
2223
python-dateutil = "==2.8.2"

Pipfile.lock

+111-87
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bot.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from discord.ext import commands, tasks
2323
from discord.ext.commands.view import StringView
2424
from emoji import is_emoji
25-
from pkg_resources import parse_version
25+
from packaging.version import Version
2626

2727

2828
try:
@@ -186,7 +186,7 @@ async def load_extensions(self):
186186

187187
@property
188188
def version(self):
189-
return parse_version(__version__)
189+
return Version(__version__)
190190

191191
@property
192192
def api(self) -> ApiClient:
@@ -1586,7 +1586,7 @@ async def autoupdate(self):
15861586
changelog = await Changelog.from_url(self)
15871587
latest = changelog.latest_version
15881588

1589-
if self.version < parse_version(latest.version):
1589+
if self.version < Version(latest.version):
15901590
error = None
15911591
data = {}
15921592
try:

cogs/plugins.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import discord
1717
from discord.ext import commands
1818

19-
from pkg_resources import parse_version
19+
from packaging.version import Version
2020

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

303-
if required_version and self.bot.version < parse_version(required_version):
303+
if required_version and self.bot.version < Version(required_version):
304304
embed = discord.Embed(
305305
description="Your bot's version is too low. "
306306
f"This plugin requires version `{required_version}`.",
@@ -688,7 +688,7 @@ async def plugins_registry(self, ctx, *, plugin_name: typing.Union[int, str] = N
688688
embed.set_footer(text="This plugin is currently loaded.")
689689
else:
690690
required_version = details.get("bot_version", False)
691-
if required_version and self.bot.version < parse_version(required_version):
691+
if required_version and self.bot.version < Version(required_version):
692692
embed.set_footer(
693693
text="Your bot is unable to install this plugin, "
694694
f"minimum required version is v{required_version}."

cogs/utility.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@
1414
from typing import Union
1515

1616
import discord
17-
from aiohttp import ClientResponseError
1817
from discord.enums import ActivityType, Status
1918
from discord.ext import commands, tasks
2019
from discord.ext.commands.view import StringView
21-
from pkg_resources import parse_version
20+
21+
from aiohttp import ClientResponseError
22+
from packaging.version import Version
2223

2324
from core import checks, utils
2425
from core.changelog import Changelog
@@ -341,9 +342,9 @@ async def about(self, ctx):
341342
latest = changelog.latest_version
342343

343344
if self.bot.version.is_prerelease:
344-
stable = next(filter(lambda v: not parse_version(v.version).is_prerelease, changelog.versions))
345+
stable = next(filter(lambda v: not Version(v.version).is_prerelease, changelog.versions))
345346
footer = f"You are on the prerelease version • the latest version is v{stable.version}."
346-
elif self.bot.version < parse_version(latest.version):
347+
elif self.bot.version < Version(latest.version):
347348
footer = f"A newer version is available v{latest.version}."
348349
else:
349350
footer = "You are up to date with the latest version."
@@ -1930,7 +1931,7 @@ async def update(self, ctx, *, flag: str = ""):
19301931
"(https://github.com/modmail-dev/modmail/blob/master/bot.py#L1)"
19311932
)
19321933

1933-
if self.bot.version >= parse_version(latest.version) and flag.lower() != "force":
1934+
if self.bot.version >= Version(latest.version) and flag.lower() != "force":
19341935
embed = discord.Embed(title="Already up to date", description=desc, color=self.bot.main_color)
19351936

19361937
data = await self.bot.api.get_user_info()

requirements.txt

+28-31
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,37 @@
1-
#
2-
# These requirements were autogenerated by pipenv
3-
# To regenerate from the project's Pipfile, run:
4-
#
5-
# pipenv lock --requirements
6-
#
7-
81
-i https://pypi.org/simple
9-
aiohttp==3.8.1
10-
aiosignal==1.2.0; python_version >= '3.6'
11-
async-timeout==4.0.2; python_version >= '3.6'
12-
attrs==21.4.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'
13-
cairocffi==1.3.0; python_version >= '3.7'
14-
cairosvg==2.5.2
15-
cffi==1.15.0
16-
charset-normalizer==2.0.12; python_version >= '3.5'
17-
colorama==0.4.4
18-
cssselect2==0.6.0; python_version >= '3.7'
2+
aiohttp==3.9.0
3+
aiosignal==1.3.1; python_version >= '3.7'
4+
async-timeout==4.0.3; python_version < '3.11'
5+
attrs==23.1.0; python_version >= '3.7'
6+
cairocffi==1.6.1; python_version >= '3.7'
7+
cairosvg==2.7.1; python_version >= '3.5'
8+
certifi==2023.11.17; python_version >= '3.6'
9+
cffi==1.16.0; python_version >= '3.8'
10+
charset-normalizer==3.3.2; python_version >= '3.7'
11+
colorama==0.4.6
12+
cssselect2==0.7.0; python_version >= '3.7'
1913
defusedxml==0.7.1; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'
20-
dnspython==2.2.1; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
21-
emoji==1.7.0
22-
frozenlist==1.3.0; python_version >= '3.7'
23-
discord.py==2.0.1
24-
idna==3.3; python_version >= '3.5'
14+
discord.py==2.3.2
15+
dnspython==2.4.2; python_version >= '3.8' and python_version < '4.0'
16+
emoji==2.8.0
17+
frozenlist==1.4.0; python_version >= '3.8'
18+
idna==3.4; python_version >= '3.5'
2519
isodate==0.6.1
26-
lottie[pdf]==0.6.11
27-
motor==2.5.1
28-
multidict==6.0.2; python_version >= '3.7'
20+
lottie[pdf]==0.7.0
21+
motor==3.3.2
22+
multidict==6.0.4; python_version >= '3.7'
2923
natural==0.2.0
24+
packaging==23.2
3025
parsedatetime==2.6
31-
pillow==9.1.0; python_version >= '3.7'
26+
pillow==10.1.0; python_version >= '3.8'
3227
pycparser==2.21
33-
pymongo==3.12.3
28+
pymongo[srv]==4.6.0
3429
python-dateutil==2.8.2
35-
python-dotenv==0.20.0
30+
python-dotenv==1.0.0
31+
requests==2.31.0
3632
six==1.16.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
37-
tinycss2==1.1.1; python_version >= '3.6'
38-
uvloop==0.16.0; sys_platform != 'win32'
33+
tinycss2==1.2.1; python_version >= '3.7'
34+
urllib3==2.1.0; python_version >= '3.8'
35+
uvloop==0.19.0; sys_platform != 'win32'
3936
webencodings==0.5.1
40-
yarl==1.7.2; python_version >= '3.6'
37+
yarl==1.9.3; python_version >= '3.7'

0 commit comments

Comments
 (0)