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 v2.0.0 import error #778

Closed
kevinschaich opened this issue Jun 30, 2023 · 4 comments · Fixed by #779
Closed

Pydantic v2.0.0 import error #778

kevinschaich opened this issue Jun 30, 2023 · 4 comments · Fixed by #779

Comments

@kevinschaich
Copy link

Bug description

Just got this error upon installation a few minutes ago:

Traceback (most recent call last):
  File "/usr/local/bin/prisma-client-py", line 5, in <module>
    from prisma.cli import main
  File "/usr/local/lib/python3.11/dist-packages/prisma/__init__.py", line 11, in <module>
    from ._config import config as config
  File "/usr/local/lib/python3.11/dist-packages/prisma/_config.py", line 7, in <module>
    from pydantic import BaseSettings, Extra, Field
  File "/usr/local/lib/python3.11/dist-packages/pydantic/__init__.py", line 206, in __getattr__
    return _getattr_migration(attr_name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/pydantic/_migration.py", line 279, in wrapper
    raise PydanticImportError(
pydantic.errors.PydanticImportError: `BaseSettings` has been moved to the `pydantic-settings` package. See https://docs.pydantic.dev/2.0/migration/#basesettings-has-moved-to-pydantic-settings for more details.

I think version 2.0.0 got released like 30 minutes ago 😅

Expected behavior

I think we should pin a version dependency on either a 1.x.x version in prisma-client-py or update the imports as described in that link above.

Environment & setup

  • OS: MacOS
  • Database: Postgres
  • Python version: 3.11
  • Prisma version: 4.15.0
prisma py version
prisma                  : 4.15.0
prisma client python    : 0.9.0
platform                : darwin
expected engine version : 8fbc245156db7124f997f4cecdd8d1219e360944
installed extras        : []
install path            : /opt/homebrew/lib/python3.11/site-packages/prisma
binary cache dir        : /Users/kevinschaich/.cache/prisma-python/binaries/4.15.0/8fbc245156db7124f997f4cecdd8d1219e360944
@blinton-sc
Copy link

blinton-sc commented Jun 30, 2023

Yeah this broke it for us as well.

Should change this line: https://github.com/RobertCraigie/prisma-client-py/blob/main/requirements/base.txt#L3 to pydantic==1.10.6
@kevinschaich

@tooruu
Copy link
Contributor

tooruu commented Jul 1, 2023

You shouldn't even be using >= in the first place when ~= exists.

pydantic~=1.10.0

@RobertCraigie
Copy link
Owner

RobertCraigie commented Jul 1, 2023

You shouldn't even be using >= in the first place when ~= exists.

No, this is a common bad practice. Premature dependency pinning can cause even more annoying issues, see this blog post for reasoning: https://hynek.me/articles/semver-will-not-save-you/

Especially this part:

On the other hand, if a new major version of a package surprisingly breaks your package, they can always add a pin themselves (see step 4 above) until you fix your package. But there’s no practical way for them to remove your pin.

If you want to avoid this kind of problem in the future I recommend https://github.com/jazzband/pip-tools, otherwise this issue should only affect new projects.


Sorry for the troubles caused here! I'll be pushing a new release that pins the dependency shortly.

RobertCraigie added a commit that referenced this issue Jul 1, 2023
## Change Summary

closes #778

## Checklist

- [ ] Unit tests for the changes exist
- [ ] Tests pass without significant drop in coverage
- [ ] Documentation reflects changes where applicable
- [ ] Test snapshots have been
[updated](https://prisma-client-py.readthedocs.io/en/latest/contributing/contributing/#snapshot-tests)
if applicable

## Agreement

By submitting this pull request, I confirm that you can use, modify,
copy and redistribute this contribution, under the terms of your choice.
@RobertCraigie
Copy link
Owner

I've published v0.9.1 which pins pydantic.

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

Successfully merging a pull request may close this issue.

4 participants