Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pydantic does not support contextlib.ExitStack. #187

Open
1 task done
theunkn0wn1 opened this issue Mar 27, 2024 · 1 comment
Open
1 task done

Pydantic does not support contextlib.ExitStack. #187

theunkn0wn1 opened this issue Mar 27, 2024 · 1 comment

Comments

@theunkn0wn1
Copy link
Contributor

theunkn0wn1 commented Mar 27, 2024

Initial Checks

  • I confirm that I'm using Pydantic V2

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

from contextlib import ExitStack
from pydantic import BaseModel
class Demo(BaseModel):
    stack: ExitStack

Python, Pydantic & OS Version

pydantic version: 2.6.4
        pydantic-core version: 2.16.3
          pydantic-core build: profile=release pgo=true
                 install path: PATH_EXPUNGED/lib/python3.10/site-packages/pydantic
               python version: 3.10.11 (main, Apr 20 2023, 14:14:57) [GCC 9.4.0]
                     platform: Linux-6.5.0-18-generic-x86_64-with-glibc2.35
             related packages: fastapi-0.110.0 pydantic-settings-2.2.1 typing_extensions-4.10.0
                       commit: unknown
@sydney-runkle
Copy link
Member

@theunkn0wn1,

I think this is a valid feature request. Marked it as such!

@sydney-runkle sydney-runkle transferred this issue from pydantic/pydantic Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants