Pydantic: Add Import type

Created on 22 May 2019  路  4Comments  路  Source: samuelcolvin/pydantic

Feature Request

Would there be interest in adding an Import type so you could do things like:

class AppConfig(BaseModel):
    middleware: List[Import] = []

config = AppConfig(middlewear=['diary.api:make_session'])

...

config.make_session()

I have a prototype here and I'm happy to work it up into a PR, but thought I'd check if there was interest first.

documentation

Most helpful comment

@cjw296 Sorry I forgot to mention PyObject in Exotic Types: https://pydantic-docs.helpmanual.io/#exotic-types

It might help with that.

All 4 comments

@cjw296 Sorry I forgot to mention PyObject in Exotic Types: https://pydantic-docs.helpmanual.io/#exotic-types

It might help with that.

PyObject is for exactly this.

@samuelcolvin - thanks, would you be up for re-opening this issue to better document PyObject? I mean, I looked in the exotics section and managed to totally miss it.

yes, totally. Might deserve it's own section.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gangefors picture gangefors  路  3Comments

samuelcolvin picture samuelcolvin  路  3Comments

cdeil picture cdeil  路  3Comments

dmontagu picture dmontagu  路  3Comments

sbv-trueenergy picture sbv-trueenergy  路  3Comments