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

Depending on email-validator>=2 is backwards incompatible #8196

Closed
1 task done
marcuslimdw opened this issue Nov 22, 2023 · 5 comments · Fixed by #8200
Closed
1 task done

Depending on email-validator>=2 is backwards incompatible #8196

marcuslimdw opened this issue Nov 22, 2023 · 5 comments · Fixed by #8200
Assignees

Comments

@marcuslimdw
Copy link

marcuslimdw commented Nov 22, 2023

Initial Checks

  • I confirm that I'm using Pydantic V2

Description

Pydantic v1 has code to check whether the installed version of email-validator is 1 or 2 and act accordingly. On the other hand, Pydantic v2 only works with email-validator>=2, which is a backwards incompatible change that is not in the migration guide, which seems like a bug to me. IMO, there're two possible resolutions to this issue:

  1. Add code to make Pydantic v2 able to handle email-validator<2 (and therefore drop the constraint in the optional dependency)
  2. Change the docs to note that if you had email-validator<2 installed and upgraded to Pydantic 2, your code will break

This is not directly relevant, but I would really prefer 1, because currently I have Airflow, FastAPI, and Pydantic 2 installed in the same pyproject.toml. Airflow is preventing me from updating email-validator, and FastAPI's /docs endpoint is not displaying because it depends on Pydantic 2's EmailStr, which breaks with email-validator<2.

Example Code

No response

Python, Pydantic & OS Version

pydantic version: 2.5.1
        pydantic-core version: 2.14.3
          pydantic-core build: profile=release pgo=false
                 install path: <redacted>/venv/lib/python3.8/site-packages/pydantic
               python version: 3.8.16 (default, May 29 2023, 14:51:39)  [Clang 14.0.3 (clang-1403.0.22.14.1)]
                     platform: macOS-14.1.1-arm64-arm-64bit
             related packages: email-validator-1.3.1 typing_extensions-4.8.0 pyright-1.1.329 fastapi-0.104.1
@marcuslimdw marcuslimdw added bug V2 Bug related to Pydantic V2 pending Awaiting a response / confirmation labels Nov 22, 2023
@Viicos
Copy link
Contributor

Viicos commented Nov 22, 2023

Version was bumped because of #3772.

Airflow is preventing me from updating email-validator

I'm not sure I understand, I don't see any dependency to email-validator in airflow?

Change the docs to note that if you had email-validator<2 installed and upgraded to Pydantic 2, your code will break

There's an open PR to add a version check (that could prevent breaking user code without them knowing it): #6033

@marcuslimdw
Copy link
Author

@Viicos it's a transitive dependency; Airflow depends on Flask-AppBuilder, which depends on email-validator.

@Viicos
Copy link
Contributor

Viicos commented Nov 22, 2023

Best would be to have Flask-AppBuilder loosen their dependencies. I see they put hard caps on almost every library which isn't really a good practice. But as it is not one of your direct dependencies it might be hard to have the change reflected on your environment even if a new release of Flask-AppBuilder gets out :/

@marcuslimdw
Copy link
Author

@Viicos you're definitely right - not really looking for pydantic to change anything on the code side here, but IMO it would be really good to note this in the migration guide, above and beyond the PR you mentioned, because if the problematic code is only run in an obscure code path that is not tested, it may be hard to debug

@sydney-runkle
Copy link
Member

Also related: #6033.

Can clean that up and work on getting that across the line today.

@sydney-runkle sydney-runkle self-assigned this Nov 22, 2023
@sydney-runkle sydney-runkle added documentation and removed bug V2 Bug related to Pydantic V2 pending Awaiting a response / confirmation labels Nov 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants