-
Notifications
You must be signed in to change notification settings - Fork 39
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: improve doc item typing #105
Conversation
Signed-off-by: Panos Vagenas <[email protected]>
Signed-off-by: Panos Vagenas <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you forgot the FormItem in the ContentItem
Signed-off-by: Panos Vagenas <[email protected]>
label: typing.Literal[DocItemLabel.SECTION_HEADER] = ( | ||
DocItemLabel.SECTION_HEADER # type: ignore[assignment] | ||
) | ||
level: LevelNumber = 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume the reason this works with serialization and deserialization, despite setting a level default, is becuase the label is now non-overlapping to the label literals in TextItem? If yes, that's great.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, label
is now non-overlapping — and is actually used as the discriminator field in ContentItem
further below.
docling_core/types/doc/document.py
Outdated
label: typing.Literal[DocItemLabel.KEY_VALUE_REGION] = DocItemLabel.KEY_VALUE_REGION | ||
|
||
|
||
class FormItem(DocItem): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure we need a FormItem
at this point. We can delay putting this in up until we will use it.
The changes for the layout processing in docling-project/docling#530 currently put simply a GroupItem
for Forms and Key-Value-Regions, which act purely as groups without special semantics.
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🟢 Enforce conventional commitWonderful, this rule succeeded.Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
🟢 Require two reviewer for test updatesWonderful, this rule succeeded.When test data is updated, we require two reviewers
|
Signed-off-by: Panos Vagenas <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we easily enforce the type also in the add_text()
method?
Technically it will now be "enforced" when the If you mean in terms of reflecting it to the typing of the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, let's get it merged!
Signed-off-by: Panos Vagenas <[email protected]>
No description provided.