8000 pydantic v2 fails on model rebuild · Issue #7618 · pydantic/pydantic · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

pydantic v2 fails on model rebuild #7618

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

Closed
1 task done
Tracked by #7617
zworkb opened this issue Sep 25, 2023 · 4 comments
Closed
1 task done
Tracked by #7617

pydantic v2 fails on model rebuild #7618

zworkb opened this issue Sep 25, 2023 · 4 comments
Assignees
Labels
bug V2 Bug related to Pydantic V2

Comments

@zworkb
Copy link
zworkb commented Sep 25, 2023

Initial Checks

  • I confirm that I'm using Pydantic V2

Description

pydantic version 2.4.0 fails at rebuilding a model.

the same code works with pydantic 2.3.0

steps with which I can reproduce the error on OSX and Linux:

python3 -m venv venv
. venv/bin/activate
pip install pydantic=="2.4.0"
python killpydantic.py

where killpydantic.py contains the code below

Example Code

from enum import Enum
from pydantic import BaseModel
    

class Alignment(Enum):
    LEFT = "PKTextAlignmentLeft"


class DateStyle(Enum):
    SHORT = "PKDateStyleShort"


class Field(BaseModel):
    i:int = 0
    textAlignment: Alignment = Alignment.LEFT  # when I comment out this line, it works


class DateField(Field):
    """"""
    # when I comment out one of these lines, it works
    dateStyle: DateStyle = DateStyle.SHORT
    timeStyle: DateStyle = DateStyle.SHORT
    

class Pass(BaseModel):
    # when I comment out one of these lines, it works
    relevantDate: DateField | str | None = None
    expirationDate: DateField | None = None 


Pass.model_rebuild(force=True)

Python, Pydantic & OS Version

OSX:

             pydantic version: 2.4.0
        pydantic-core version: 2.10.0
          pydantic-core build: profile=release pgo=false
                 install path: /Users/phil/tmp/schas1/venv/lib/python3.11/site-packages/pydantic
               python version: 3.11.3 (main, Apr  7 2023, 19:25:52) [Clang 14.0.0 (clang-1400.0.29.202)]
                     platform: macOS-13.2.1-x86_64-i386-64bit
             related packages: typing_extensions-4.8.0


LINUX:
             pydantic version: 2.4.0
        pydantic-core version: 2.10.0
          pydantic-core build: profile=release pgo=true
                 install path: /home/phil/dev/projects/edutap/apple-pass-creator-service/venv/lib/python3.10/site-packages/pydantic
               python version: 3.10.7 (main, May 29 2023, 13:51:48) [GCC 12.2.0]
                     platform: Linux-5.19.0-46-generic-x86_64-with-glibc2.36
             related packages: typing_extensions-4.8.0 fastapi-0.103.1

As stated above, everything works fine with pydantic 2.3.0
@zworkb zworkb added bug V2 Bug related to Pydantic V2 unconfirmed labels Sep 25, 2023
@samuelcolvin
Copy link
Member

What's the error?

@davidhewitt
Copy link
Contributor

Based on manual testing I'm calling this a duplicate of #7611

@adriangb and I have a solution underway so should be able to confirm if our patches fix this case too.

@adriangb
Copy link
Member

This is fixed in 38bc2da

@zworkb
Copy link
Author
zworkb commented Sep 26, 2023

thanks for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug V2 Bug related to Pydantic V2
Projects
None yet
Development

No branches or pull requests

5 participants
0