mirror of
https://github.com/meta-llama/llama-stack.git
synced 2026-01-02 10:54:31 +00:00
chore: add some explanations and explicit check callouts to mypy ignores
Signed-off-by: Ihar Hrachyshka <ihar.hrachyshka@gmail.com>
This commit is contained in:
parent
6df600f014
commit
d443607d65
4 changed files with 18 additions and 12 deletions
|
|
@ -463,10 +463,14 @@ class JsonSchemaGenerator:
|
|||
ret: Schema = {"oneOf": [self.type_to_schema(union_type) for union_type in typing.get_args(typ)]}
|
||||
if discriminator:
|
||||
# for each union type, we need to read the value of the discriminator
|
||||
mapping: JsonType = {}
|
||||
mapping: dict[str, JsonType] = {}
|
||||
for union_type in typing.get_args(typ):
|
||||
props = self.type_to_schema(union_type, force_expand=True)["properties"]
|
||||
mapping[props[discriminator]["default"]] = self.type_to_schema(union_type)["$ref"] # type: ignore
|
||||
# mypy is confused here because JsonType allows multiple types, some of them
|
||||
# not indexable (bool?) or not indexable by string (list?). The correctness of
|
||||
# types depends on correct model definitions. Hence multiple ignore statements below.
|
||||
discriminator_value = props[discriminator]["default"] # type: ignore[index,call-overload]
|
||||
mapping[discriminator_value] = self.type_to_schema(union_type)["$ref"] # type: ignore[index]
|
||||
|
||||
ret["discriminator"] = {
|
||||
"propertyName": discriminator,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue