From 308e82722830a43dc64c2d9961c981072cbae179 Mon Sep 17 00:00:00 2001 From: Emre Terzioglu <50607143+EmreTech@users.noreply.github.com> Date: Sat, 30 Sep 2023 10:18:06 -0700 Subject: [PATCH] refactor: remove _modify_api_version (#1115) * refactor: remove _modify_api_version * style: auto fixes from pre-commit hooks * typing: constrain _API_VERSION to just v10 --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- nextcord/http.py | 37 ++----------------------------------- 1 file changed, 2 insertions(+), 35 deletions(-) diff --git a/nextcord/http.py b/nextcord/http.py index 280254ec33..eca6becee7 100644 --- a/nextcord/http.py +++ b/nextcord/http.py @@ -5,7 +5,6 @@ import asyncio import logging import sys -import warnings import weakref from typing import ( TYPE_CHECKING, @@ -95,43 +94,11 @@ async def json_or_text(response: aiohttp.ClientResponse) -> Union[Dict[str, Any] _DEFAULT_API_VERSION = 10 -_API_VERSION: Literal[9, 10] = _DEFAULT_API_VERSION - - -class UnsupportedAPIVersion(UserWarning): - """Warning category raised when changing the API version to an unsupported version.""" - - -def _modify_api_version(version: Literal[9, 10]): - """Modify the API version used by the HTTP client. - - Additional versions may be added around the time of a Discord API - version bump to allow temporarily downgrading to an older API version - or upgrading to a newer version that is not yet supported by the library. - - Changing the API version from the default is not supported and may result in - unexpected behaviour. - """ - available_versions = (9, 10) - - if version not in available_versions: - raise ValueError(f"Only API versions {available_versions} are available.") - - if version != _DEFAULT_API_VERSION: - warnings.warn( - "Changing the API version is not supported and may result in unexpected behaviour.", - category=UnsupportedAPIVersion, - stacklevel=2, - ) - - global _API_VERSION - _API_VERSION = version - - Route.BASE = f"https://discord.com/api/v{version}" +_API_VERSION: Literal[10] = _DEFAULT_API_VERSION class Route: - BASE: ClassVar[str] = f"https://discord.com/api/v{_DEFAULT_API_VERSION}" + BASE: ClassVar[str] = f"https://discord.com/api/v{_API_VERSION}" def __init__(self, method: str, path: str, **parameters: Any) -> None: self.path: str = path