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

TypeAdapter doesn't respect config['schema_generator'] #9289

Open
1 task done
samuelcolvin opened this issue Apr 19, 2024 · 0 comments
Open
1 task done

TypeAdapter doesn't respect config['schema_generator'] #9289

samuelcolvin opened this issue Apr 19, 2024 · 0 comments
Labels
bug V2 Bug related to Pydantic V2

Comments

@samuelcolvin
Copy link
Member

Initial Checks

  • I confirm that I'm using Pydantic V2

Description

gen = _generate_schema.GenerateSchema(config_wrapper, types_namespace=global_ns, typevars_map={})

We're not using config['schema_generator'], we should.

BaseModel and RootModel do respect it.

Example Code

from typing import Any
from pydantic_core import core_schema

from pydantic import RootModel
from pydantic._internal._generate_schema import GenerateSchema
from pydantic.config import ConfigDict


class MyGenerateSchema(GenerateSchema):
    def _unknown_type_schema(self, obj: Any):
        return core_schema.int_schema()


class MyType:
    pass


class MyModel(RootModel):
    model_config = ConfigDict(schema_generator=MyGenerateSchema)
    root: MyType


debug(MyModel('123').root)

Python, Pydantic & OS Version

all v2 I guess
@samuelcolvin samuelcolvin added bug V2 Bug related to Pydantic V2 pending Awaiting a response / confirmation and removed pending Awaiting a response / confirmation labels Apr 19, 2024
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

1 participant