Voice et bot modif
This commit is contained in:
parent
189d56026b
commit
7333a22bcd
10774 changed files with 634644 additions and 933308 deletions
|
|
@ -1,18 +1,7 @@
|
|||
import abc
|
||||
import os # noqa
|
||||
from typing import (
|
||||
TYPE_CHECKING,
|
||||
Any,
|
||||
Callable,
|
||||
Dict,
|
||||
Iterator,
|
||||
List,
|
||||
Optional,
|
||||
Sequence,
|
||||
Type,
|
||||
Union,
|
||||
overload,
|
||||
)
|
||||
from collections.abc import Callable, Iterator, Sequence
|
||||
from typing import TYPE_CHECKING, Any, Union, overload
|
||||
|
||||
import attr
|
||||
|
||||
|
|
@ -48,11 +37,11 @@ __all__ = (
|
|||
|
||||
class AbstractRouteDef(abc.ABC):
|
||||
@abc.abstractmethod
|
||||
def register(self, router: UrlDispatcher) -> List[AbstractRoute]:
|
||||
def register(self, router: UrlDispatcher) -> list[AbstractRoute]:
|
||||
pass # pragma: no cover
|
||||
|
||||
|
||||
_HandlerType = Union[Type[AbstractView], Handler]
|
||||
_HandlerType = Union[type[AbstractView], Handler]
|
||||
|
||||
|
||||
@attr.s(auto_attribs=True, frozen=True, repr=False, slots=True)
|
||||
|
|
@ -60,7 +49,7 @@ class RouteDef(AbstractRouteDef):
|
|||
method: str
|
||||
path: str
|
||||
handler: _HandlerType
|
||||
kwargs: Dict[str, Any]
|
||||
kwargs: dict[str, Any]
|
||||
|
||||
def __repr__(self) -> str:
|
||||
info = []
|
||||
|
|
@ -70,7 +59,7 @@ class RouteDef(AbstractRouteDef):
|
|||
method=self.method, path=self.path, handler=self.handler, info="".join(info)
|
||||
)
|
||||
|
||||
def register(self, router: UrlDispatcher) -> List[AbstractRoute]:
|
||||
def register(self, router: UrlDispatcher) -> list[AbstractRoute]:
|
||||
if self.method in hdrs.METH_ALL:
|
||||
reg = getattr(router, "add_" + self.method.lower())
|
||||
return [reg(self.path, self.handler, **self.kwargs)]
|
||||
|
|
@ -84,7 +73,7 @@ class RouteDef(AbstractRouteDef):
|
|||
class StaticDef(AbstractRouteDef):
|
||||
prefix: str
|
||||
path: PathLike
|
||||
kwargs: Dict[str, Any]
|
||||
kwargs: dict[str, Any]
|
||||
|
||||
def __repr__(self) -> str:
|
||||
info = []
|
||||
|
|
@ -94,7 +83,7 @@ class StaticDef(AbstractRouteDef):
|
|||
prefix=self.prefix, path=self.path, info="".join(info)
|
||||
)
|
||||
|
||||
def register(self, router: UrlDispatcher) -> List[AbstractRoute]:
|
||||
def register(self, router: UrlDispatcher) -> list[AbstractRoute]:
|
||||
resource = router.add_static(self.prefix, self.path, **self.kwargs)
|
||||
routes = resource.get_info().get("routes", {})
|
||||
return list(routes.values())
|
||||
|
|
@ -116,7 +105,7 @@ def get(
|
|||
path: str,
|
||||
handler: _HandlerType,
|
||||
*,
|
||||
name: Optional[str] = None,
|
||||
name: str | None = None,
|
||||
allow_head: bool = True,
|
||||
**kwargs: Any,
|
||||
) -> RouteDef:
|
||||
|
|
@ -141,7 +130,7 @@ def delete(path: str, handler: _HandlerType, **kwargs: Any) -> RouteDef:
|
|||
return route(hdrs.METH_DELETE, path, handler, **kwargs)
|
||||
|
||||
|
||||
def view(path: str, handler: Type[AbstractView], **kwargs: Any) -> RouteDef:
|
||||
def view(path: str, handler: type[AbstractView], **kwargs: Any) -> RouteDef:
|
||||
return route(hdrs.METH_ANY, path, handler, **kwargs)
|
||||
|
||||
|
||||
|
|
@ -156,7 +145,7 @@ class RouteTableDef(Sequence[AbstractRouteDef]):
|
|||
"""Route definition table"""
|
||||
|
||||
def __init__(self) -> None:
|
||||
self._items: List[AbstractRouteDef] = []
|
||||
self._items: list[AbstractRouteDef] = []
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"<RouteTableDef count={len(self._items)}>"
|
||||
|
|
@ -165,7 +154,7 @@ class RouteTableDef(Sequence[AbstractRouteDef]):
|
|||
def __getitem__(self, index: int) -> AbstractRouteDef: ...
|
||||
|
||||
@overload
|
||||
def __getitem__(self, index: slice) -> List[AbstractRouteDef]: ...
|
||||
def __getitem__(self, index: slice) -> list[AbstractRouteDef]: ...
|
||||
|
||||
def __getitem__(self, index): # type: ignore[no-untyped-def]
|
||||
return self._items[index]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue