As I am using Pydantic in the context of FastAPI, using a Pydantic type for internal (non-user-facing) types was my first thought, as im already using it for user-facing components.
Example Code
from contextlib import ExitStack
from pydantic import BaseModel
class Demo(BaseModel):
stack: ExitStack
Initial Checks
Description
Pydantic does not allow contextlib.ExitStack nor contextlib.AsyncExitStack in models.
As I am using Pydantic in the context of FastAPI, using a Pydantic type for internal (non-user-facing) types was my first thought, as im already using it for user-facing components.
Example Code
Python, Pydantic & OS Version