Merge pull request #12032 from AUTOMATIC1111/fix-api-get-options-sd_model_checkpoint

api /sdapi/v1/options use "Any" type when default type is None
This commit is contained in:
AUTOMATIC1111 2023-07-26 11:52:42 +03:00
parent eb6d330bb7
commit 6b877c35da

View File

@ -208,11 +208,9 @@ class PreprocessResponse(BaseModel):
fields = {} fields = {}
for key, metadata in opts.data_labels.items(): for key, metadata in opts.data_labels.items():
value = opts.data.get(key) value = opts.data.get(key)
optType = opts.typemap.get(type(metadata.default), type(metadata.default)) optType = opts.typemap.get(type(metadata.default), type(metadata.default)) if metadata.default else Any
if metadata.default is None: if metadata is not None:
pass
elif metadata is not None:
fields.update({key: (Optional[optType], Field(default=metadata.default, description=metadata.label))}) fields.update({key: (Optional[optType], Field(default=metadata.default, description=metadata.label))})
else: else:
fields.update({key: (Optional[optType], Field())}) fields.update({key: (Optional[optType], Field())})