Skip to content

Extend pydantic input model to hold primitive defaults #146

@liamhuber

Description

@liamhuber

@samwaseda and I were chatting on how to handle actual input data in a recipe context. We don't have a conclusion on actual input values, but he did convince me to include primitive defaults.

I'm not sure how to modify the actual model structure to fit these in yet, but the rough idea is to permit a new default field per-input like default: OK where

from typing import Union

JsonPrimitive = str | int | float | bool | None
OK = JsonPrimitive | tuple[OK]  # Forgive the recursion, I'm just trying to log the point

Where deserialization converts the json list back to a python tuple.

Don't support mutable json-compliant stuff (list and dict) because actual uses of mutable defaults are almost exclusively going to be mistakes, and for the odd time it wouldn't be there are alternative approaches.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions