mirror of
https://github.com/Paillat-dev/pycord-rest.git
synced 2026-01-02 00:56:19 +00:00
✨ Add not_supported decorator and override latency property in App class (#4)
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
# Copyright (c) Paillat-dev
|
# Copyright (c) Paillat-dev
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import functools
|
||||||
import logging
|
import logging
|
||||||
from collections.abc import Callable, Coroutine
|
from collections.abc import Callable, Coroutine
|
||||||
from functools import cached_property
|
from functools import cached_property
|
||||||
@@ -42,6 +43,15 @@ class InvalidCredentialsError(PycordRestError):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def not_supported[T, U](func: Callable[[T], U]) -> Callable[[T], U]:
|
||||||
|
@functools.wraps(func)
|
||||||
|
def inner(*args: T, **kwargs: T) -> U:
|
||||||
|
logger.warning(f"{func.__qualname__} is not supported by REST apps.")
|
||||||
|
return func(*args, **kwargs)
|
||||||
|
|
||||||
|
return inner
|
||||||
|
|
||||||
|
|
||||||
class App(discord.Bot):
|
class App(discord.Bot):
|
||||||
def __init__(self, *args: Any, **options: Any) -> None: # pyright: ignore [reportExplicitAny]
|
def __init__(self, *args: Any, **options: Any) -> None: # pyright: ignore [reportExplicitAny]
|
||||||
super().__init__(*args, **options) # pyright: ignore [reportUnknownMemberType]
|
super().__init__(*args, **options) # pyright: ignore [reportUnknownMemberType]
|
||||||
@@ -49,6 +59,12 @@ class App(discord.Bot):
|
|||||||
self.router: APIRouter = APIRouter()
|
self.router: APIRouter = APIRouter()
|
||||||
self._public_key: str | None = None
|
self._public_key: str | None = None
|
||||||
|
|
||||||
|
@property
|
||||||
|
@override
|
||||||
|
@not_supported
|
||||||
|
def latency(self) -> float:
|
||||||
|
return 0.0
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def _verify_key(self) -> VerifyKey:
|
def _verify_key(self) -> VerifyKey:
|
||||||
if self._public_key is None:
|
if self._public_key is None:
|
||||||
|
|||||||
Reference in New Issue
Block a user