Stop waiting for update check on bot startup (#6687)

This commit is contained in:
Jakub Kuczys
2026-03-06 01:51:22 +01:00
committed by GitHub
parent 9a458fdd83
commit 34cbd15ba9
3 changed files with 51 additions and 24 deletions

View File

@@ -326,18 +326,29 @@ def expected_version(current: str, expected: str) -> bool:
return Requirement(f"x{expected}").specifier.contains(current, prereleases=True)
async def fetch_latest_red_version_info() -> Tuple[Optional[VersionInfo], Optional[str]]:
try:
async with aiohttp.ClientSession() as session:
async with session.get("https://pypi.org/pypi/Red-DiscordBot/json") as r:
data = await r.json()
except (aiohttp.ClientError, asyncio.TimeoutError):
return None, None
else:
release = VersionInfo.from_str(data["info"]["version"])
required_python = data["info"]["requires_python"]
async def fetch_latest_red_version_info() -> Tuple[VersionInfo, Optional[str]]:
"""
Fetch information about latest Red release on PyPI.
return release, required_python
Raises
------
aiohttp.ClientError
An error occurred during request to PyPI.
TimeoutError
The request to PyPI timed out.
ValueError
An invalid version string was returned in PyPI metadata.
KeyError
The PyPI metadata is missing some of the required information.
"""
async with aiohttp.ClientSession() as session:
async with session.get("https://pypi.org/pypi/Red-DiscordBot/json") as r:
data = await r.json()
release = VersionInfo.from_str(data["info"]["version"])
required_python = data["info"]["requires_python"]
return release, required_python
def deprecated_removed(