Allow using uuid.UUID as a dict key

This commit is contained in:
2026-02-18 20:30:53 +03:00
parent 1f45777add
commit facf4ceade
3 changed files with 4 additions and 4 deletions

View File

@@ -1,6 +1,6 @@
[project] [project]
name = "turbosloth" name = "turbosloth"
version = "0.1.0" version = "0.1.0.post1"
description = "ASGI REST framework for lazy devs" description = "ASGI REST framework for lazy devs"
authors = [ authors = [
{ name = "nikto_b", email = "niktob560@yandex.ru" } { name = "nikto_b", email = "niktob560@yandex.ru" }

View File

@@ -145,7 +145,7 @@ async def test_body(r: RequestBody(UserPostSchema),
h1: HeaderParam(str, 'header1'), h1: HeaderParam(str, 'header1'),
db: DummyDbConnection, db: DummyDbConnection,
user: User, user: User,
q2: int = 321) -> (Resp((TestResp, HeadersResp), 200) q2: int = 321) -> (Resp(TestResp, 200)
| Resp(TestResp1, 201) | Resp(TestResp1, 201)
| Resp(ErrResp, 500)): | Resp(ErrResp, 500)):
print(r.user_id) print(r.user_id)
@@ -162,7 +162,7 @@ async def test_body(r: RequestBody(UserPostSchema),
return ErrResp('hehe'), {} return ErrResp('hehe'), {}
if q1 == 'a': if q1 == 'a':
return TestResp1(**resp) return TestResp1(**resp)
return TestResp(**resp), HeadersResp('asdf') return TestResp(**resp)
@dataclass @dataclass

View File

@@ -101,7 +101,7 @@ def type_to_schema(tp, components: Components, *,
# Dict # Dict
if origin is dict: if origin is dict:
key_type, value_type = args if args else (str, Any) key_type, value_type = args if args else (str, Any)
if key_type is not str: if key_type is not str and not uuid.UUID:
raise ValueError("OpenAPI dict keys must be strings") raise ValueError("OpenAPI dict keys must be strings")
return Schema( return Schema(
type="object", type="object",