sotkalib 0.0.5.post3__tar.gz → 0.0.6__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.
- {sotkalib-0.0.5.post3 → sotkalib-0.0.6}/PKG-INFO +1 -1
- {sotkalib-0.0.5.post3 → sotkalib-0.0.6}/pyproject.toml +2 -2
- {sotkalib-0.0.5.post3 → sotkalib-0.0.6}/src/sotkalib/http/__init__.py +0 -3
- {sotkalib-0.0.5.post3 → sotkalib-0.0.6}/src/sotkalib/http/client_session.py +12 -22
- {sotkalib-0.0.5.post3 → sotkalib-0.0.6}/src/sotkalib/redis/client.py +2 -1
- {sotkalib-0.0.5.post3 → sotkalib-0.0.6}/README.md +0 -0
- {sotkalib-0.0.5.post3 → sotkalib-0.0.6}/src/sotkalib/__init__.py +0 -0
- {sotkalib-0.0.5.post3 → sotkalib-0.0.6}/src/sotkalib/config/__init__.py +0 -0
- {sotkalib-0.0.5.post3 → sotkalib-0.0.6}/src/sotkalib/config/field.py +0 -0
- {sotkalib-0.0.5.post3 → sotkalib-0.0.6}/src/sotkalib/config/struct.py +0 -0
- {sotkalib-0.0.5.post3 → sotkalib-0.0.6}/src/sotkalib/enum/__init__.py +0 -0
- {sotkalib-0.0.5.post3 → sotkalib-0.0.6}/src/sotkalib/enum/mixins.py +0 -0
- {sotkalib-0.0.5.post3 → sotkalib-0.0.6}/src/sotkalib/exceptions/__init__.py +0 -0
- {sotkalib-0.0.5.post3 → sotkalib-0.0.6}/src/sotkalib/exceptions/api/__init__.py +0 -0
- {sotkalib-0.0.5.post3 → sotkalib-0.0.6}/src/sotkalib/exceptions/api/exc.py +0 -0
- {sotkalib-0.0.5.post3 → sotkalib-0.0.6}/src/sotkalib/exceptions/handlers/__init__.py +0 -0
- {sotkalib-0.0.5.post3 → sotkalib-0.0.6}/src/sotkalib/exceptions/handlers/args_incl_error.py +0 -0
- {sotkalib-0.0.5.post3 → sotkalib-0.0.6}/src/sotkalib/exceptions/handlers/core.py +0 -0
- {sotkalib-0.0.5.post3 → sotkalib-0.0.6}/src/sotkalib/log/__init__.py +0 -0
- {sotkalib-0.0.5.post3 → sotkalib-0.0.6}/src/sotkalib/log/factory.py +0 -0
- {sotkalib-0.0.5.post3 → sotkalib-0.0.6}/src/sotkalib/py.typed +0 -0
- {sotkalib-0.0.5.post3 → sotkalib-0.0.6}/src/sotkalib/redis/__init__.py +0 -0
- {sotkalib-0.0.5.post3 → sotkalib-0.0.6}/src/sotkalib/redis/lock.py +0 -0
- {sotkalib-0.0.5.post3 → sotkalib-0.0.6}/src/sotkalib/sqla/__init__.py +0 -0
- {sotkalib-0.0.5.post3 → sotkalib-0.0.6}/src/sotkalib/sqla/db.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "sotkalib"
|
|
3
|
-
version = "0.0.
|
|
3
|
+
version = "0.0.6"
|
|
4
4
|
description = ""
|
|
5
5
|
authors = [
|
|
6
6
|
{ email = "me@pyrorhythm.dev", name = "alexey" }
|
|
@@ -78,7 +78,7 @@ select = [
|
|
|
78
78
|
"PL",
|
|
79
79
|
"PERF"
|
|
80
80
|
]
|
|
81
|
-
ignore = ["PERF401", "G004"]
|
|
81
|
+
ignore = ["PERF401", "G004", "UP037"]
|
|
82
82
|
|
|
83
83
|
[tool.ruff.lint.isort]
|
|
84
84
|
known-first-party = [
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
from .client_session import (
|
|
2
2
|
ClientSettings,
|
|
3
|
-
# Exceptions
|
|
4
3
|
CriticalStatusError,
|
|
5
4
|
ExceptionSettings,
|
|
6
|
-
Handler,
|
|
7
5
|
HTTPSession,
|
|
8
6
|
Middleware,
|
|
9
7
|
Next,
|
|
@@ -19,7 +17,6 @@ __all__ = (
|
|
|
19
17
|
"ExceptionSettings",
|
|
20
18
|
"StatusSettings",
|
|
21
19
|
"ClientSettings",
|
|
22
|
-
"Handler",
|
|
23
20
|
"Middleware",
|
|
24
21
|
"Next",
|
|
25
22
|
# Exceptions
|
|
@@ -86,6 +86,12 @@ class RequestContext:
|
|
|
86
86
|
def status(self) -> int | None:
|
|
87
87
|
return self.response.status if self.response else None
|
|
88
88
|
|
|
89
|
+
def with_(self, **kws) -> Self:
|
|
90
|
+
for k, v in kws.items():
|
|
91
|
+
setattr(self, k, v)
|
|
92
|
+
|
|
93
|
+
return self
|
|
94
|
+
|
|
89
95
|
def merge_headers(self, headers: dict[str, str]) -> None:
|
|
90
96
|
if self.headers is None:
|
|
91
97
|
self.headers = {}
|
|
@@ -119,9 +125,11 @@ async def default_stat_arg_func(ctx: RequestContext) -> tuple[Sequence[Any], Non
|
|
|
119
125
|
|
|
120
126
|
|
|
121
127
|
def default_exc_arg_func(ctx: RequestContext) -> tuple[Sequence[Any], None]:
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
128
|
+
return (
|
|
129
|
+
(
|
|
130
|
+
f"exception {type(ctx.last_error)}: ({ctx.last_error=}) attempt={ctx.attempt}; url={ctx.url} method={ctx.method}"
|
|
131
|
+
),
|
|
132
|
+
), None
|
|
125
133
|
|
|
126
134
|
|
|
127
135
|
class StatusSettings(BaseModel):
|
|
@@ -215,7 +223,7 @@ class HTTPSession[R = aiohttp.ClientResponse | None]:
|
|
|
215
223
|
self._middlewares = _middlewares or []
|
|
216
224
|
self._logger = get_logger("http.client_session")
|
|
217
225
|
|
|
218
|
-
def use[NewR](self, middleware: Middleware[R, NewR]) -> HTTPSession[NewR]:
|
|
226
|
+
def use[NewR](self, middleware: Middleware[R, NewR]) -> "HTTPSession[NewR]":
|
|
219
227
|
return HTTPSession[NewR](
|
|
220
228
|
config=self.config,
|
|
221
229
|
_middlewares=[*self._middlewares, middleware],
|
|
@@ -424,21 +432,3 @@ class HTTPSession[R = aiohttp.ClientResponse | None]:
|
|
|
424
432
|
|
|
425
433
|
def merge_tuples[T](t1: tuple[T, ...], t2: tuple[T, ...]) -> tuple[T, ...]:
|
|
426
434
|
return t1 + t2
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
# ============================================================================
|
|
430
|
-
# Legacy compatibility aliases
|
|
431
|
-
# ============================================================================
|
|
432
|
-
|
|
433
|
-
# Old Handler protocol - kept for backwards compatibility but deprecated
|
|
434
|
-
from typing import Protocol
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
class Handler[**P, T](Protocol):
|
|
438
|
-
"""
|
|
439
|
-
DEPRECATED: Use Middleware type instead.
|
|
440
|
-
|
|
441
|
-
Old handler protocol for backwards compatibility.
|
|
442
|
-
"""
|
|
443
|
-
|
|
444
|
-
async def __call__(self, *args: P.args, **kwargs: P.kwargs) -> T: ...
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import asyncio
|
|
2
2
|
from contextlib import AbstractAsyncContextManager
|
|
3
|
+
from typing import Self
|
|
3
4
|
|
|
4
5
|
from pydantic import BaseModel, Field
|
|
5
6
|
from redis.asyncio import ConnectionPool, Redis
|
|
@@ -29,7 +30,7 @@ class RedisPool(AbstractAsyncContextManager):
|
|
|
29
30
|
self._usage_counter = 0
|
|
30
31
|
self._usage_lock = asyncio.Lock()
|
|
31
32
|
|
|
32
|
-
async def __aenter__(self:
|
|
33
|
+
async def __aenter__(self: Self) -> Redis:
|
|
33
34
|
try:
|
|
34
35
|
return Redis(connection_pool=self._pool)
|
|
35
36
|
except Exception:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|