Skip to content

pydantic-core out of date relative to pydantic version #162

@mahmoud

Description

@mahmoud

🐛 Bug

Certain Pydantic models cannot be declared under Pyodide 0.27.0+

To Reproduce

Import a Pydantic model similar to this:

class ExtraModel(BaseModel):
    __pydantic_config__ = ConfigDict(extra='allow')

Under one of these versions and you'll get an exception:

  File "/lib/python3.12/site-packages/tmpkg/utils.py", line 265, in <module>
    class ExtraModel(BaseModel):

  File "/lib/python3.12/site-packages/pydantic/_internal/_model_construction.py", line 237, in __new__
    complete_model_class(

  File "/lib/python3.12/site-packages/pydantic/_internal/_model_construction.py", line 597, in complete_model_class
    schema = gen_schema.generate_schema(cls)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/lib/python3.12/site-packages/pydantic/_internal/_generate_schema.py", line 711, in generate_schema
    schema = self._generate_schema_inner(obj)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/lib/python3.12/site-packages/pydantic/_internal/_generate_schema.py", line 1004, in _generate_schema_inner
    return self._model_schema(obj)
           ^^^^^^^^^^^^^^^^^^^^^^^

  File "/lib/python3.12/site-packages/pydantic/_internal/_generate_schema.py", line 836, in _model_schema
    fields_schema: core_schema.CoreSchema = core_schema.model_fields_schema(
                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

TypeError: model_fields_schema() got an unexpected keyword argument 'extras_keys_schema'

Environment

  • Pyodide Version: 0.27.1, 0.27.7, 0.28.0
  • Browser version: Chromium Version 138.0.7204.49 (Official Build) snap (64-bit)

Additional context

Based on what I've seen from Pydantic's issue #11641, this is caused by using a newer version of Pydantic with pydantic-core < 2.33.0 (0.27.1 has 2.25.1, 0.27.7 and 0.28.0 have 2.27.2).

Not sure who's doing the building these days, but I can cross-post on Pydantic's repo, too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis item suggests that womething isn't working correctly and we should investigate a fix

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions