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.
@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.
Most helpful comment
@cjw296 Sorry I forgot to mention
PyObjectin Exotic Types: https://pydantic-docs.helpmanual.io/#exotic-typesIt might help with that.