8000 breaking change in 2.11.4: `create_model` no longer accepts class-based `Config` · Issue #11819 · pydantic/pydantic · GitHub
[go: up one dir, main page]

Skip to content
breaking change in 2.11.4: create_model no longer accepts class-based Config #11819
@zzstoatzz

Description

@zzstoatzz

Initial Checks

  • I confirm that I'm using Pydantic V2

Description

I understand that ConfigDict is the right thing to do at this point, we had some compat code that handled v1 objects in the case of a v2 pydantic install which is where our users encountered this.

we easily worked around this but reporting because it technically seems like a breaking change

seems related to #11714

» uv run --with 'pydantic==2.11.4' repros/pydantic/configdict.py
Traceback (most recent call last):
  File "/Users/nate/github.com/prefecthq/prefect/repros/pydantic/configdict.py", line 7, in <module>
    Model = create_model("Model", __config__=Config)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nate/Library/Caches/uv/archive-v0/a1MACwVa0TRCWn5WltviZ/lib/python3.12/site-packages/pydantic/main.py", line 1761, in create_model
    return meta(
           ^^^^^
  File "/Users/nate/Library/Caches/uv/archive-v0/a1MACwVa0TRCWn5WltviZ/lib/python3.12/site-packages/pydantic/_internal/_model_construction.py", line 110, in __new__
    config_wrapper = ConfigWrapper.for_model(bases, namespace, kwargs)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nate/Library/Caches/uv/archive-v0/a1MACwVa0TRCWn5WltviZ/lib/python3.12/site-packages/pydantic/_internal/_config.py", line 138, in for_model
    config_new.update(config_from_namespace)
TypeError: 'type' object is not iterable

» uv run --with 'pydantic==2.11.3' repros/pydantic/configdict.py
{'properties': {}, 'title': 'Model', 'type': 'object'}

Example Code

from pydantic import create_model


class Config: ...


Model = create_model("Model", __config__=Config)

print(Model.model_json_schema())

Python, Pydantic & OS Version

             pydantic version: 2.11.4
        pydantic-core version: 2.33.2
          pydantic-core build: profile=release pgo=false
               python version: 3.12.8 (main, Jan 14 2025, 23:36:58) [Clang 19.1.6 ]
                     platform: macOS-15.3.2-arm64-arm-64bit
             related packages: typing_extensions-4.13.2 pydantic-settings-2.9.1 pydantic-extra-types-2.10.4 mypy-1.15.0 typing_extensions-4.13.2 fastapi-0.115.12 pyright-1.1.400
                       commit: unknown

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug V2Bug related to Pydantic V2pendingIs unconfirmed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone
      < 2F1B div class="Milestone-module__hiddenPlaceholder--tPOjC">

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0