spakky-fastapi 0.7.16__tar.gz → 0.7.17__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: spakky-fastapi
3
- Version: 0.7.16
3
+ Version: 0.7.17
4
4
  Summary: Highly abstracted Framework core to use DDD & DI/IoC & AOP & Etc...
5
5
  Author: Spakky
6
6
  Author-email: sejong418@icloud.com
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "spakky-fastapi"
3
- version = "0.7.16"
3
+ version = "0.7.17"
4
4
  description = "Highly abstracted Framework core to use DDD & DI/IoC & AOP & Etc..."
5
5
  authors = ["Spakky <sejong418@icloud.com>"]
6
6
  readme = "README.md"
@@ -1,5 +1,4 @@
1
- from typing import Any, TypeVar, Protocol, Awaitable, runtime_checkable
2
- from inspect import signature
1
+ from typing import Any, TypeVar, Callable, Annotated, Awaitable, TypeAlias, Concatenate
3
2
  from logging import Logger
4
3
  from dataclasses import InitVar, field, dataclass
5
4
 
@@ -25,20 +24,7 @@ class AuthenticationFailedError(SpakkyAOPError):
25
24
  message = "사용자 인증에 실패했습니다."
26
25
 
27
26
 
28
- @runtime_checkable
29
- class IAuthenticatedFunction(Protocol[P, R_co]):
30
- __defaults__: tuple[Any, ...] | None
31
- __kwdefaults__: dict[str, Any] | None
32
-
33
- # pylint: disable=no-self-argument
34
- def __call__(
35
- self_, # type: ignore
36
- self: Any,
37
- token: JWT,
38
- *args: P.args,
39
- **kwargs: P.kwargs,
40
- ) -> Awaitable[R_co]:
41
- raise NotImplementedError
27
+ IAuthenticatedFunction: TypeAlias = Callable[Concatenate[Any, JWT, P], Awaitable[R_co]]
42
28
 
43
29
 
44
30
  @dataclass
@@ -52,12 +38,10 @@ class JWTAuth(FunctionAnnotation):
52
38
  def __call__(
53
39
  self, obj: IAuthenticatedFunction[P, R_co]
54
40
  ) -> IAuthenticatedFunction[P, R_co]:
55
- parameters = list(signature(obj).parameters.values())
56
- if obj.__defaults__ is not None:
57
- extra = obj.__defaults__
58
- else:
59
- extra = tuple(Depends() for x in parameters[1:] if x.name != "token")
60
- obj.__defaults__ = (Depends(self.authenticator),) + extra
41
+ obj.__annotations__ = {
42
+ k: Annotated[JWT, Depends(self.authenticator)] if v == JWT else v
43
+ for k, v in obj.__annotations__.items()
44
+ }
61
45
  return super().__call__(obj)
62
46
 
63
47
 
@@ -26,7 +26,7 @@ class FastAPIBeanPostProcessor(IBeanPostProcessor):
26
26
  return bean
27
27
  controller = ApiController.single(bean)
28
28
  router: APIRouter = APIRouter(prefix=controller.prefix, tags=controller.tags)
29
- for name, method in getmembers(bean):
29
+ for name, method in getmembers(bean, callable):
30
30
  route: Route | None = Route.single_or_none(method)
31
31
  websocket_route: WebSocketRoute | None = WebSocketRoute.single_or_none(method)
32
32
  if route is None and websocket_route is None: