Coverage for /usr/local/lib/python3.12/site-packages/prefect/utilities/_deprecated.py: 0%

17 statements  

« prev     ^ index     » next       coverage.py v7.10.6, created at 2025-12-05 10:48 +0000

1from typing import Any 

2 

3from jsonpatch import ( # type: ignore # no typing stubs available, see https://github.com/stefankoegl/python-json-patch/issues/158 

4 JsonPatch as JsonPatchBase, 

5) 

6from pydantic import GetJsonSchemaHandler 

7from pydantic.json_schema import JsonSchemaValue 

8from pydantic_core import core_schema 

9 

10 

11class JsonPatch(JsonPatchBase): 

12 @classmethod 

13 def __get_pydantic_core_schema__( 

14 cls, source_type: Any, handler: GetJsonSchemaHandler 

15 ) -> core_schema.CoreSchema: 

16 return core_schema.typed_dict_schema( 

17 {"patch": core_schema.typed_dict_field(core_schema.dict_schema())} 

18 ) 

19 

20 @classmethod 

21 def __get_pydantic_json_schema__( 

22 cls, core_schema: core_schema.CoreSchema, handler: GetJsonSchemaHandler 

23 ) -> JsonSchemaValue: 

24 json_schema = handler(core_schema) 

25 json_schema = handler.resolve_ref_schema(json_schema) 

26 json_schema.pop("required", None) 

27 json_schema.pop("properties", None) 

28 json_schema.update( 

29 { 

30 "type": "array", 

31 "format": "rfc6902", 

32 "items": { 

33 "type": "object", 

34 "additionalProperties": {"type": "string"}, 

35 }, 

36 } 

37 ) 

38 return json_schema