fix(jambo): Fix allOf, anyOf, null and array type parsing #33
Reference in New Issue
Block a user
Delete Branch "main"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fix parser, such that:
gives the same result for null, allOf, anyOf, oneOf, string and array types.
I used the null parser from https://github.com/HideyoshiNakazone/jambo/pull/32
Hey, when can we expect this PR to be merged?
Sorry for the wait, i'll take a look into the PR
Hey, thanks for working on this PR!
I noticed that it’s quite large, and it would be much easier to review if it were split into smaller, focused PRs.
I also saw that some of the
typing_extensionsimports were changed totyping. That was intentional in the codebase to maintain compatibility with Python 3.10, so we should avoid changing those for now.This PR also tries to solve multiple issues at once, but some of those have already been addressed by previous smaller PRs. Because of the size and scope, this one will take significantly longer to review.
This change will make that the smallest value between
old_valueandnew_valuewill became the new max value, this change is faulty.This change will make that the largest value between
old_valueandnew_valuewill became the new min value, this change is faulty.@@ -5,3 +3,3 @@from typing_extensions import Unpackfrom typing import Any, Unpacktyping_extensionsis prefered for Python3.10 compatibility@@ -3,3 +2,3 @@from pydantic import Field, TypeAdapterfrom typing_extensions import Annotated, Any, ClassVar, Generic, Self, TypeVar, Unpackfrom typing import Annotated, Any, Generic, Self, TypeVar, Unpacktyping_extensionsis prefered for Python3.10 compatibility@@ -67,3 +57,4 @@cls, name: str, properties: dict[str, Any], **kwargs: Unpack[TypeParserOptions]) -> tuple[type, dict]:"""Factory method to fetch the appropriate type parser based on propertieschanged for what reason?
@@ -5,2 +4,3 @@from pydantic import Fieldfrom typing_extensions import Annotated, Union, Unpackfrom typing import Annotated, Unpackfrom types import UnionTypetyping_extensionsis prefered for Python3.10 compatibility@@ -3,3 +2,3 @@from jambo.types.type_parser_options import TypeParserOptionsfrom typing_extensions import Unpackfrom typing import Unpacktyping_extensionsis prefered for Python3.10 compatibility@@ -5,3 +4,3 @@from pydantic import AfterValidatorfrom typing_extensions import Annotated, Any, Literal, Unpackfrom typing import Annotated, Any, Literal, Unpacktyping_extensionsis prefered for Python3.10 compatibilityThis is a good idea and implementation, but would have to be merged in a separate PR.
@@ -5,2 +3,3 @@from jambo.types.type_parser_options import TypeParserOptionsfrom typing_extensions import Unpackfrom typing import Unpacktyping_extensionsis prefered for Python3.10 compatibility@@ -2,3 +2,3 @@from jambo.types.type_parser_options import TypeParserOptionsfrom typing_extensions import Unpackfrom typing import Unpacktyping_extensionsis prefered for Python3.10 compatibility@@ -2,3 +2,3 @@from jambo.types.type_parser_options import TypeParserOptionsfrom typing_extensions import Unpackfrom typing import Unpacktyping_extensionsis prefered for Python3.10 compatibilityThis function shouldn't be a staticmethod, it's to simple and does to little. Make this simple check inside the function body since it is used only two times, or transform this into a utility function in a utils folder.
@@ -9,2 +6,2 @@Annotation = Annotated[Any, ...]from pydantic import Field, BeforeValidator, TypeAdapter, ValidationErrorfrom typing import Annotated, Unpack, Anytyping_extensionsis prefered for Python3.10 compatibilityThis entire feature should be in a separate PR
@@ -8,3 +5,1 @@from typing_extensions import Unpackimport warningsfrom typing import Any, Unpacktyping_extensionsis prefered for Python3.10 compatibilityAlready implemented in a previous PR that was merged, sorry
@@ -5,3 +2,3 @@from jambo.types.type_parser_options import TypeParserOptionsfrom typing_extensions import ForwardRef, Literal, Union, Unpackfrom typing import Any, ForwardRef, Literal, TypeVar, Unpacktyping_extensionsis prefered for Python3.10 compatibility@@ -5,2 +4,2 @@from pydantic import AnyUrl, EmailStr, TypeAdapter, ValidationErrorfrom typing_extensions import Unpackfrom pydantic import EmailStr, HttpUrl, IPvAnyAddress, FilePathfrom typing import Unpacktyping_extensionsis prefered for Python3.10 compatibilityA large change with little impact, is there a necessity for this change?
@@ -4,3 +3,1 @@RefCacheDict = MutableMapping[str, ForwardRef | type | None]from typing import TypedDicttyping_extensionsis prefered for Python3.10 compatibilityBasically, for the AllOf be valid for both values the largest interval must be used, otherwise the AllOf requirement will break.
Basically, for the AllOf be valid for both values the largest interval must be used, otherwise the AllOf requirement will break
After reviewing this PR, I’ve decided not to merge it as it currently stands.
The improvements in
ConstParserand theOneOfimplementation are valuable, but they should each be proposed in separate, focused PRs.For this branch in its current form, neither change will be merged.
Thanks @thommann for the PR! If you’d still like to contribute, I’ll be looking forward to PRs focused on
ConstParserand on theOneOfimplementation.Just to address this initial issue @thommann :
From the current state of the main branch
As you can see, the generated JSON schema is not significantly different.
I don’t think this is an issue as-is.
If you can share the specific class that caused problems in your case, we can try to reproduce it and find a solution tailored to your test case.
Pull request closed