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

Schema build runs forever on main #8049

Closed
1 task done
Tracked by #8028
samuelcolvin opened this issue Nov 7, 2023 · 1 comment · Fixed by pydantic/pydantic-core#867
Closed
1 task done
Tracked by #8028

Schema build runs forever on main #8049

samuelcolvin opened this issue Nov 7, 2023 · 1 comment · Fixed by pydantic/pydantic-core#867
Assignees
Labels
bug V2 Bug related to Pydantic V2

Comments

@samuelcolvin
Copy link
Member

Initial Checks

  • I confirm that I'm using Pydantic V2

Description

Run the below code and building the schema runs forever.

Oddly it doesn't if:

  • you remove Ham from the union, still takes a long time but not forever
  • move the definition of DiscUnion to the end of the file, in this case it's very fast
  • use 2.4.2

Example Code

from __future__ import annotations as _annotations

from pydantic import BaseModel


class Foo(BaseModel):
    f: DiscUnion


class Bar(BaseModel):
    b: DiscUnion


class Spam(BaseModel):
    s: DiscUnion


class Egg(BaseModel):
    e: DiscUnion


class Ham(BaseModel):
    h: DiscUnion


DiscUnion = Foo | Bar | Spam | Egg | Ham


class Final(BaseModel):
    d: DiscUnion

Python, Pydantic & OS Version

Using current main da2173ed6d7065d1f89236824403bf758b86f20d
@samuelcolvin samuelcolvin added bug V2 Bug related to Pydantic V2 pending Awaiting a response / confirmation and removed pending Awaiting a response / confirmation labels Nov 7, 2023
@davidhewitt

This comment was marked as resolved.

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

Successfully merging a pull request may close this issue.

2 participants