Skip to content

callables as defaults for fields #409

@samuelcolvin

Description

@samuelcolvin

The following doesn't work as foobar gets bound to the class, even if static it would be skipped.

Need a helper wrapper to get his to work.

from pydantic import BaseSettings, PyObject

def foobar():
    pass

class Settings(BaseSettings):
    foo: PyObject = foobar

s = Settings()
debug(s, s.foo)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug V1Bug related to Pydantic V1.X

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions