Skip to content
This repository was archived by the owner on Sep 9, 2026. It is now read-only.

fix: wip add default value to TextDoc - #1798

Closed
samsja wants to merge 5 commits into
mainfrom
fix-default-val
Closed

samsja wants to merge 5 commits into
mainfrom
fix-default-val

Conversation

@samsja

@samsja samsja commented Sep 19, 2023

Copy link
Copy Markdown
Member

Context

Allow in pydantic v2 to do

 class MyDocument(BaseDoc):
        caption: TextDoc
MyDocument(caption='A tiger in the jungle')

or to do

TextDoc('hello')

should fix : #1787

Signed-off-by: samsja <sami.jaghouar@hotmail.fr>
Signed-off-by: samsja <sami.jaghouar@hotmail.fr>
@codecov

codecov Bot commented Sep 19, 2023 •

Copy link
Copy Markdown

Codecov Report

Patch coverage: 88.09% and project coverage change: -21.34% ⚠️

Comparison is base (8f32866) 84.24% compared to head (3c75994) 62.90%.
Report is 3 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main    #1798       +/-   ##
===========================================
- Coverage   84.24%   62.90%   -21.34%     
===========================================
  Files         135      136        +1     
  Lines        8899     8935       +36     
===========================================
- Hits         7497     5621     -1876     
- Misses       1402     3314     +1912     
Flag Coverage Δ
docarray 62.90% <88.09%> (-21.34%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
docarray/documents/text.py 72.22% <82.35%> (-24.45%) ⬇️
docarray/documents/base_predefined_doc.py 92.00% <92.00%> (ø)

... and 70 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: samsja <sami.jaghouar@hotmail.fr>
Signed-off-by: samsja <sami.jaghouar@hotmail.fr>
if not cls.__pydantic_generic_metadata__['origin']:
schema = cls.__pydantic_core_schema__

schema = handler(source)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

doesn't this make all the previous code useless?

Signed-off-by: samsja <sami.jaghouar@hotmail.fr>
@github-actions

Copy link
Copy Markdown

📝 Docs are deployed on https://ft-fix-default-val--jina-docs.netlify.app 🎉

@samsja samsja closed this Sep 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[pydantic v2] Validation with default value is not working

2 participants