Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix logic for merging object schemas within a property #1159

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

eli-bl
Copy link
Collaborator

@eli-bl eli-bl commented Nov 5, 2024

Fixes #1123.

Details are as described in the changeset.

This is a breaking change only in cases where the previous logic was producing an unambiguously wrong result. That is, in the example shown in the changeset, any code that had previously relied on ModelB.result being an instance of BaseResult rather than ExtendedResult would now fail.

@eli-bl eli-bl changed the title Issue1123 merge model fix logic for merging object schemas within a property Nov 5, 2024
@eli-bl eli-bl force-pushed the issue1123-merge-model branch from 10cae28 to e6cdf95 Compare November 5, 2024 20:29
prop1: Property,
prop2: Property,
parent_name: str,
config: Config,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need parent_name and config now because it might be necessary to generate a new inline schema.

optional_properties: list[Property] | None = None
additional_properties: Property | None = None
relative_imports: set[str] = field(factory=set)
lazy_imports: set[str] = field(factory=set)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is similar to the _PropertyData class that previously existed just to be a return type for _process_properties. Since they were so close already, and ModelProperty also had all of these properties, I figured it made sense to encapsulate them and have ModelProperty just own an instance of this class. I added accessor methods so that model.required_properties still works as an alias for model.details.required_properties.

@eli-bl eli-bl force-pushed the issue1123-merge-model branch from fccd382 to c363974 Compare November 5, 2024 21:17
@eli-bl eli-bl marked this pull request as ready for review November 5, 2024 21:22
@eli-bl eli-bl requested a review from dbanty November 5, 2024 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

overriding model property with more specific object type doesn't work
1 participant