Skip to content

Commit

Permalink
Black 24
Browse files Browse the repository at this point in the history
  • Loading branch information
hynek committed Jan 26, 2024
1 parent e6b200e commit 2590e12
Show file tree
Hide file tree
Showing 13 changed files with 102 additions and 169 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ci:

repos:
- repo: https://github.com/psf/black
rev: 23.12.1
rev: 24.1.0
hooks:
- id: black

Expand Down
60 changes: 20 additions & 40 deletions src/svcs/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,20 +745,17 @@ def register_local_value(
)

@overload
def get(self, svc_type: type[T1], /) -> T1:
...
def get(self, svc_type: type[T1], /) -> T1: ...

@overload
def get(
self, svc_type1: type[T1], svc_type2: type[T2], /
) -> tuple[T1, T2]:
...
) -> tuple[T1, T2]: ...

@overload
def get(
self, svc_type1: type[T1], svc_type2: type[T2], svc_type3: type[T3], /
) -> tuple[T1, T2, T3]:
...
) -> tuple[T1, T2, T3]: ...

@overload
def get(
Expand All @@ -768,8 +765,7 @@ def get(
svc_type3: type[T3],
svc_type4: type[T4],
/,
) -> tuple[T1, T2, T3, T4]:
...
) -> tuple[T1, T2, T3, T4]: ...

@overload
def get(
Expand All @@ -780,8 +776,7 @@ def get(
svc_type4: type[T4],
svc_type5: type[T5],
/,
) -> tuple[T1, T2, T3, T4, T5]:
...
) -> tuple[T1, T2, T3, T4, T5]: ...

@overload
def get(
Expand All @@ -793,8 +788,7 @@ def get(
svc_type5: type[T5],
svc_type6: type[T6],
/,
) -> tuple[T1, T2, T3, T4, T5, T6]:
...
) -> tuple[T1, T2, T3, T4, T5, T6]: ...

@overload
def get(
Expand All @@ -807,8 +801,7 @@ def get(
svc_type6: type[T6],
svc_type7: type[T7],
/,
) -> tuple[T1, T2, T3, T4, T5, T6, T7]:
...
) -> tuple[T1, T2, T3, T4, T5, T6, T7]: ...

@overload
def get(
Expand All @@ -822,8 +815,7 @@ def get(
svc_type7: type[T7],
svc_type8: type[T8],
/,
) -> tuple[T1, T2, T3, T4, T5, T6, T7, T8]:
...
) -> tuple[T1, T2, T3, T4, T5, T6, T7, T8]: ...

@overload
def get(
Expand All @@ -838,8 +830,7 @@ def get(
svc_type8: type[T8],
svc_type9: type[T9],
/,
) -> tuple[T1, T2, T3, T4, T5, T6, T7, T8, T9]:
...
) -> tuple[T1, T2, T3, T4, T5, T6, T7, T8, T9]: ...

@overload
def get(
Expand All @@ -855,8 +846,7 @@ def get(
svc_type9: type[T9],
svc_type10: type[T10],
/,
) -> tuple[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]:
...
) -> tuple[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]: ...

def get(self, *svc_types: type) -> object:
"""
Expand Down Expand Up @@ -896,20 +886,17 @@ def get(self, *svc_types: type) -> object:
return rv

@overload
async def aget(self, svc_type: type[T1], /) -> T1:
...
async def aget(self, svc_type: type[T1], /) -> T1: ...

@overload
async def aget(
self, svc_type1: type[T1], svc_type2: type[T2], /
) -> tuple[T1, T2]:
...
) -> tuple[T1, T2]: ...

@overload
async def aget(
self, svc_type1: type[T1], svc_type2: type[T2], svc_type3: type[T3], /
) -> tuple[T1, T2, T3]:
...
) -> tuple[T1, T2, T3]: ...

@overload
async def aget(
Expand All @@ -919,8 +906,7 @@ async def aget(
svc_type3: type[T3],
svc_type4: type[T4],
/,
) -> tuple[T1, T2, T3, T4]:
...
) -> tuple[T1, T2, T3, T4]: ...

@overload
async def aget(
Expand All @@ -931,8 +917,7 @@ async def aget(
svc_type4: type[T4],
svc_type5: type[T5],
/,
) -> tuple[T1, T2, T3, T4, T5]:
...
) -> tuple[T1, T2, T3, T4, T5]: ...

@overload
async def aget(
Expand All @@ -944,8 +929,7 @@ async def aget(
svc_type5: type[T5],
svc_type6: type[T6],
/,
) -> tuple[T1, T2, T3, T4, T5, T6]:
...
) -> tuple[T1, T2, T3, T4, T5, T6]: ...

@overload
async def aget(
Expand All @@ -958,8 +942,7 @@ async def aget(
svc_type6: type[T6],
svc_type7: type[T7],
/,
) -> tuple[T1, T2, T3, T4, T5, T6, T7]:
...
) -> tuple[T1, T2, T3, T4, T5, T6, T7]: ...

@overload
async def aget(
Expand All @@ -973,8 +956,7 @@ async def aget(
svc_type7: type[T7],
svc_type8: type[T8],
/,
) -> tuple[T1, T2, T3, T4, T5, T6, T7, T8]:
...
) -> tuple[T1, T2, T3, T4, T5, T6, T7, T8]: ...

@overload
async def aget(
Expand All @@ -989,8 +971,7 @@ async def aget(
svc_type8: type[T8],
svc_type9: type[T9],
/,
) -> tuple[T1, T2, T3, T4, T5, T6, T7, T8, T9]:
...
) -> tuple[T1, T2, T3, T4, T5, T6, T7, T8, T9]: ...

@overload
async def aget(
Expand All @@ -1006,8 +987,7 @@ async def aget(
svc_type9: type[T9],
svc_type10: type[T10],
/,
) -> tuple[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]:
...
) -> tuple[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]: ...

async def aget(self, *svc_types: type) -> object:
"""
Expand Down
30 changes: 10 additions & 20 deletions src/svcs/aiohttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,13 @@ async def aget_abstract(request: web.Request, *svc_types: type) -> Any:


@overload
async def aget(request: web.Request, svc_type: type[T1], /) -> T1:
...
async def aget(request: web.Request, svc_type: type[T1], /) -> T1: ...


@overload
async def aget(
request: web.Request, svc_type1: type[T1], svc_type2: type[T2], /
) -> tuple[T1, T2]:
...
) -> tuple[T1, T2]: ...


@overload
Expand All @@ -178,8 +176,7 @@ async def aget(
svc_type2: type[T2],
svc_type3: type[T3],
/,
) -> tuple[T1, T2, T3]:
...
) -> tuple[T1, T2, T3]: ...


@overload
Expand All @@ -190,8 +187,7 @@ async def aget(
svc_type3: type[T3],
svc_type4: type[T4],
/,
) -> tuple[T1, T2, T3, T4]:
...
) -> tuple[T1, T2, T3, T4]: ...


@overload
Expand All @@ -203,8 +199,7 @@ async def aget(
svc_type4: type[T4],
svc_type5: type[T5],
/,
) -> tuple[T1, T2, T3, T4, T5]:
...
) -> tuple[T1, T2, T3, T4, T5]: ...


@overload
Expand All @@ -217,8 +212,7 @@ async def aget(
svc_type5: type[T5],
svc_type6: type[T6],
/,
) -> tuple[T1, T2, T3, T4, T5, T6]:
...
) -> tuple[T1, T2, T3, T4, T5, T6]: ...


@overload
Expand All @@ -232,8 +226,7 @@ async def aget(
svc_type6: type[T6],
svc_type7: type[T7],
/,
) -> tuple[T1, T2, T3, T4, T5, T6, T7]:
...
) -> tuple[T1, T2, T3, T4, T5, T6, T7]: ...


@overload
Expand All @@ -248,8 +241,7 @@ async def aget(
svc_type7: type[T7],
svc_type8: type[T8],
/,
) -> tuple[T1, T2, T3, T4, T5, T6, T7, T8]:
...
) -> tuple[T1, T2, T3, T4, T5, T6, T7, T8]: ...


@overload
Expand All @@ -265,8 +257,7 @@ async def aget(
svc_type8: type[T8],
svc_type9: type[T9],
/,
) -> tuple[T1, T2, T3, T4, T5, T6, T7, T8, T9]:
...
) -> tuple[T1, T2, T3, T4, T5, T6, T7, T8, T9]: ...


@overload
Expand All @@ -283,8 +274,7 @@ async def aget(
svc_type9: type[T9],
svc_type10: type[T10],
/,
) -> tuple[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]:
...
) -> tuple[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]: ...


async def aget(request: web.Request, *svc_types: type) -> object:
Expand Down
25 changes: 14 additions & 11 deletions src/svcs/fastapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,20 @@ class lifespan: # noqa: N801
lifespan: The lifespan function to make *svcs*-aware.
"""

_lifespan: Callable[
[FastAPI, svcs.Registry],
contextlib.AbstractAsyncContextManager[dict[str, object]],
] | Callable[
[FastAPI, svcs.Registry],
contextlib.AbstractAsyncContextManager[None],
] | Callable[
[FastAPI, svcs.Registry], AsyncGenerator[dict[str, object], None]
] | Callable[
[FastAPI, svcs.Registry], AsyncGenerator[None, None]
]
_lifespan: (
Callable[
[FastAPI, svcs.Registry],
contextlib.AbstractAsyncContextManager[dict[str, object]],
]
| Callable[
[FastAPI, svcs.Registry],
contextlib.AbstractAsyncContextManager[None],
]
| Callable[
[FastAPI, svcs.Registry], AsyncGenerator[dict[str, object], None]
]
| Callable[[FastAPI, svcs.Registry], AsyncGenerator[None, None]]
)
_state: dict[str, object] = attrs.field(factory=dict)
registry: svcs.Registry = attrs.field(factory=svcs.Registry)

Expand Down
Loading

0 comments on commit 2590e12

Please sign in to comment.