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_DISABLE_PLUGINS: env var to disable all plugins #7709

Closed
samuelcolvin opened this issue Sep 30, 2023 · 11 comments
Closed

PYDANTIC_DISABLE_PLUGINS: env var to disable all plugins #7709

samuelcolvin opened this issue Sep 30, 2023 · 11 comments

Comments

@samuelcolvin
Copy link
Member

Should be fairly simple to setup.

@samuelcolvin
Copy link
Member Author

maybe configurable, so:

  • PYDANTIC_DISABLE_PLUGINS=__all__ disables all, same for PYDANTIC_DISABLE_PLUGINS=1
  • PYDANTIC_DISABLE_PLUGINS=foobar disables just the plugin from the foobar package
  • PYDANTIC_DISABLE_PLUGINS=foobar,span disables the plugins from the foobar and spam packages

@geospackle
Copy link
Contributor

@samuelcolvin @Kludex

I could pick this up!

@sydney-runkle
Copy link
Member

@geospackle,

That'd be great! Thanks. I've assigned the issue to you :).

@sydney-runkle sydney-runkle added this to the v2.7.0 milestone Jan 23, 2024
@geospackle
Copy link
Contributor

Will be able to work on this next week.

@geospackle
Copy link
Contributor

Found the test plugin. That also fails, the log is empty.

pydantic version: 2.6.0
pydantic-core version: 2.16.1
pydantic-core build: profile=release pgo=true
python version: 3.12.1 (main, Dec 12 2023, 11:43:12) [GCC 9.4.0]
platform: Linux-6.0.12-76060012-generic-x86_64-with-glibc2.31
related packages: typing_extensions-4.9.0 email-validator-2.1.0.post1 mypy-1.1.1 pydantic-settings-2.1.0 pydantic-extra-types-2.5.0
commit: 5fc166c0

@geospackle
Copy link
Contributor

geospackle commented Feb 5, 2024

@sydney-runkle @samuelcolvin
Any assist available with this? If not, I can open an issue and pick something else to work on. Or hmmm... work on that issue...

@hramezani
Copy link
Member

@geospackle

  1. Create a new environment
  2. Create a new directory and copy pyproject.toml and example_plugin.py from plugin directory to it
  3. Install the current project and pedantic in editable mode. run the pip install -e . in the new directory that you've created in previous step and run pip install -e <pydantic directory in your local machine>
  4. Now, you can create a pedantic model and check the plugin events
from pydantic import BaseModel

class MyModel(BaseModel):
    x: int
    y: str

m = MyModel(x='10', y='hello')
assert m.x == 10
assert m.y == 'hello'

@sydney-runkle
Copy link
Member

@geospackle,

Apologies for the delay in response! Was a bit tied up with the patch release last week. Feel free to also tag @Kludex if you have any other questions re this issue.

@hramezani, thanks for the guidance on getting started with this :).

@geospackle
Copy link
Contributor

thanks @hramezani

for some reason the test fails with pdm's env even though the plugin is installed. I can proceed with a fresh environment.

@hramezani
Copy link
Member

@sydney-runkle can we close this as the PR got merged?

@hramezani
Copy link
Member

Done in #8767

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants