From 409e048769c5c3032ba3a1070b72e037cb71f3d5 Mon Sep 17 00:00:00 2001 From: Eugene Yurtsev Date: Wed, 19 Apr 2023 22:19:45 -0400 Subject: [PATCH] Fix examples bug for objects (#131) Pydantic auto coercision behaves incorrectly when using a list of dicts which contain exactly 2 items. In this case, the list of dicts gets incorrectly converted into a dictionary. Fix for: https://github.com/eyurtsev/kor/issues/130 --- kor/examples.py | 2 +- kor/nodes.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kor/examples.py b/kor/examples.py index bd58b06..0d072c4 100644 --- a/kor/examples.py +++ b/kor/examples.py @@ -22,7 +22,7 @@ class SimpleExampleAggregator(AbstractVisitor[List[Tuple[str, str]]]): - """Use to visit node and all of its descendents and aggregates all examples.""" + """Use to visit node and all of its descendants and aggregates all examples.""" def visit_option(self, node: "Option", **kwargs: Any) -> List[Tuple[str, str]]: """Should not visit Options directly.""" diff --git a/kor/nodes.py b/kor/nodes.py index 9496f47..8ab00d6 100644 --- a/kor/nodes.py +++ b/kor/nodes.py @@ -225,8 +225,8 @@ class Object(AbstractSchemaNode): Tuple[ str, Union[ - Mapping[str, Any], Sequence[Mapping[str, Any]], + Mapping[str, Any], ], ] ] = tuple()