mirror of
https://github.com/kennethreitz/pydantic.git
synced 2026-06-05 14:50:19 +00:00
18 lines
317 B
Python
18 lines
317 B
Python
from typing import TypeVar, Generic
|
|
from pydantic.generics import GenericModel
|
|
|
|
TypeX = TypeVar('TypeX')
|
|
|
|
|
|
class BaseClass(GenericModel, Generic[TypeX]):
|
|
X: TypeX
|
|
|
|
|
|
class ChildClass(BaseClass[TypeX], Generic[TypeX]):
|
|
# Inherit from Generic[TypeX]
|
|
pass
|
|
|
|
|
|
# Replace TypeX by int
|
|
print(ChildClass[int](X=1))
|