Skip to content

fix(pydantic): turn on pydantic smart union#73

Merged
hanxiao merged 3 commits intomainfrom
fix-pydantic-union
Jan 23, 2022
Merged

fix(pydantic): turn on pydantic smart union#73
hanxiao merged 3 commits intomainfrom
fix-pydantic-union

Conversation

@numb3r3
Copy link
Copy Markdown
Contributor

@numb3r3 numb3r3 commented Jan 21, 2022

attempt to address #72

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 21, 2022

Codecov Report

Merging #73 (359328c) into main (66ceeda) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main      #73   +/-   ##
=======================================
  Coverage   83.06%   83.07%           
=======================================
  Files          70       70           
  Lines        3402     3404    +2     
=======================================
+ Hits         2826     2828    +2     
  Misses        576      576           
Flag Coverage Δ
docarray 83.07% <100.00%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
docarray/__init__.py 100.00% <100.00%> (ø)
docarray/document/pydantic_model.py 95.74% <100.00%> (+0.18%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ecf89c4...359328c. Read the comment docs.

weight: Optional[float]
uri: Optional[str]
tags: Optional[Dict[str, '_StructValueType']]
tags: Optional[Dict[str, Any]]
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.

This however makes tags unschema

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.

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.

I think is right having tags unschema, it is the free part of Document

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.

but the "free-part" still have to be a valid JSON

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.

the right way is to turn on pydantic smart union, as in https://pydantic-docs.helpmanual.io/usage/model_config/#smart-union

@hanxiao hanxiao changed the title fix(pydantic): disable smart union fix(pydantic): turn on pydantic smart union Jan 23, 2022
@hanxiao
Copy link
Copy Markdown
Member

hanxiao commented Jan 23, 2022

the original title of the PR is misleading, the default behavior is not "smart union" according to https://pydantic-docs.helpmanual.io/usage/model_config/#smart-union

This PR in fact turns on the "smart union".

@hanxiao hanxiao merged commit 412930d into main Jan 23, 2022
@hanxiao hanxiao deleted the fix-pydantic-union branch January 23, 2022 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants