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

7 statements  

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

1from typing import Any, TypeVar 1a

2 

3from pydantic import BaseModel 1a

4from pydantic_core import SchemaValidator, core_schema 1a

5 

6T = TypeVar("T", bound=BaseModel) 1a

7 

8ListValidator: SchemaValidator = SchemaValidator( 1a

9 schema=core_schema.list_schema( 

10 items_schema=core_schema.dict_schema( 

11 keys_schema=core_schema.str_schema(), values_schema=core_schema.any_schema() 

12 ) 

13 ) 

14) 

15 

16 

17def validate_list(model: type[T], input: Any) -> list[T]: 1a

18 return [model.model_validate(item) for item in ListValidator.validate_python(input)]