From e6154d8038eeaaafbd456183ea33578a2f945fde Mon Sep 17 00:00:00 2001 From: Timur Enikeev <163281083+DaymasS@users.noreply.github.com> Date: Thu, 19 Sep 2024 13:52:05 -0400 Subject: [PATCH] Pydantic 2.9 fix (#208) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Изменения Фикс для Pydantic 2.9... ## Детали реализации Добавил обязательный хэндлер ## Check-List - [ ] Вы проверили свой код перед отправкой запроса? - [ ] Вы написали тесты к реализованным функциям? - [ ] Вы не забыли применить форматирование `black` и `isort` для _Back-End_ или `Prettier` для _Front-End_? --- auth_backend/schemas/types/scopes.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/auth_backend/schemas/types/scopes.py b/auth_backend/schemas/types/scopes.py index e3216ffd..ce33acfc 100644 --- a/auth_backend/schemas/types/scopes.py +++ b/auth_backend/schemas/types/scopes.py @@ -1,7 +1,7 @@ import string from typing import Any -from pydantic._internal import _schema_generation_shared +from pydantic import GetCoreSchemaHandler, GetJsonSchemaHandler from pydantic.json_schema import JsonSchemaValue from pydantic_core import core_schema @@ -19,12 +19,13 @@ class Scope: def __get_pydantic_core_schema__( cls, source: type[Any], + handler: GetCoreSchemaHandler, ) -> core_schema.CoreSchema: return core_schema.general_after_validator_function(cls._validate, core_schema.str_schema()) @classmethod def __get_pydantic_json_schema__( - cls, core_schema: core_schema.CoreSchema, handler: _schema_generation_shared.GetJsonSchemaHandler + cls, core_schema: core_schema.CoreSchema, handler: GetJsonSchemaHandler ) -> JsonSchemaValue: field_schema = handler(core_schema) field_schema.update(type='string', format='scope')