diff --git a/github/__init__.py b/github/__init__.py index b7f96d9..ca330a4 100644 --- a/github/__init__.py +++ b/github/__init__.py @@ -25,7 +25,7 @@ SOFTWARE. __title__ = "GitHub-API-Wrapper" __authors__ = ("VarMonke", "sudosnok", "contributors") -__version__ = "2.0a" +__version__ = "2.0.0a" __license__ = "MIT" __copyright__ = "Copyright (c) 2022-present VarMonke, sudosnok & contributors" diff --git a/github/errors.py b/github/errors.py index 4662601..abb9f1c 100644 --- a/github/errors.py +++ b/github/errors.py @@ -1,6 +1,6 @@ from __future__ import annotations -__all__ = ("GitHubError", "BaseHTTPError", "HTTPError", "RatelimitReached") +__all__ = ("GitHubError", "BaseHTTPError", "HTTPError", "RatelimitReached", "error_from_request") from datetime import datetime, timezone from typing import TYPE_CHECKING @@ -46,3 +46,7 @@ class RatelimitReached(GitHubError): "The ratelimit has been reached. You can try again in" f" {human_readable_time_until(datetime.now(timezone.utc) - self.reset_time)}" ) + +def error_from_request(request: ClientResponse, /) -> BaseHTTPError: + # TODO: Make specific errrors + return HTTPError(request) diff --git a/github/internals/http.py b/github/internals/http.py index 76c9a6e..97a2a80 100644 --- a/github/internals/http.py +++ b/github/internals/http.py @@ -9,10 +9,10 @@ import time from datetime import datetime, timezone from typing import TYPE_CHECKING, Any, Awaitable, Dict, List, Literal, NamedTuple, Optional, Union -from aiohttp import ClientSession, TraceConfig +from aiohttp import ClientSession, TraceConfig, __version__ as aiohttp_verrsion -from .. import __version__ -from ..utils import error_from_request, human_readable_time_until +from ..utils import human_readable_time_until +from ..errors import error_from_request if TYPE_CHECKING: from types import SimpleNamespace @@ -112,7 +112,7 @@ class HTTPClient: headers.setdefault( "User-Agent", "GitHub-API-Wrapper (https://github.com/Varmonke/GitHub-API-Wrapper) @" - f" {__version__} CPython/{platform.python_version()} aiohttp/{__version__}", + f" 2.0.0a CPython/{platform.python_version()} aiohttp/{aiohttp_verrsion}", ) self._rates = Ratelimits(None, None, None, None, None) @@ -202,6 +202,7 @@ class HTTPClient: if 200 <= request.status <= 299: return await request.json() + print(await request.json()) raise error_from_request(request) # === ROUTES === # diff --git a/github/utils.py b/github/utils.py index e9f5ff4..3313dd7 100644 --- a/github/utils.py +++ b/github/utils.py @@ -11,8 +11,6 @@ __all__ = ( from base64 import b64encode from typing import TYPE_CHECKING, Optional -from .errors import HTTPError - if TYPE_CHECKING: from datetime import datetime, timedelta @@ -39,8 +37,3 @@ def repr_dt(time: datetime, /) -> str: def bytes_to_b64(content: str, /) -> str: return b64encode(content.encode("utf-8")).decode("ascii") - - -def error_from_request(request: ClientResponse, /) -> BaseHTTPError: - # TODO: Make specific errrors - return HTTPError(request)