mirror of
https://github.com/kennethreitz/pydantic.git
synced 2026-06-05 23:00:18 +00:00
18 lines
404 B
Python
18 lines
404 B
Python
from typing import Generic, TypeVar, Type, Any, Tuple
|
|
|
|
from pydantic.generics import GenericModel
|
|
|
|
DataT = TypeVar('DataT')
|
|
|
|
|
|
class Response(GenericModel, Generic[DataT]):
|
|
data: DataT
|
|
|
|
@classmethod
|
|
def __concrete_name__(cls: Type[Any], params: Tuple[Type[Any], ...]) -> str:
|
|
return f'{params[0].__name__.title()}Response'
|
|
|
|
|
|
print(Response[int](data=1))
|
|
print(Response[str](data='a'))
|