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

[WIP] [Test] [BUG] Unit tests for dataclass in union with more than two non-None variants #2952

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

mao3267
Copy link
Contributor

@mao3267 mao3267 commented Nov 25, 2024

Tracking issue

Related to flyteorg/flyte#5986

Why are the changes needed?

After mashumaro release version 3.15, it supports messagepack robust decoding with the correct type in Union. Therefore, we would like to add a unit test to show it works. Also, we should fix errors to support changes in mashumaro to version 3.15.

What changes were proposed in this pull request?

  1. Update the unit test for dataclass in Union to include more than two non-None variants.
  2. Fix bugs while generating attribute list from dataclass_json in generate_attribute_list_from_dataclass_json function.
    • Initially, we thought we should use additionalProperties to generate dataclass properties. However, both dataclass and dictionary type can have an additionalProperties field. This mismatch causes the bug of generating an incorrect attribute list for dictionaries.

How was this patch tested?

  1. Passing existing and modified unit tests.

Setup process

git clone https://github.com/flytorg/flytekit.git
gh pr checkout 2952
pip install -e .

Screenshots

None

Check all the applicable boxes

  • I updated the documentation accordingly.
  • All new and existing tests passed.
  • All commits are signed-off.

Related PRs

#2859
Fatal1ty/mashumaro#256

Docs link

None

Note

  1. We can not distinguish between dict and dataclass with json schema. So the current implementation will fail to handle dataclass with additionalProperties.

Copy link

codecov bot commented Nov 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 51.43%. Comparing base (6f8b9a0) to head (820b531).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2952      +/-   ##
==========================================
+ Coverage   46.86%   51.43%   +4.57%     
==========================================
  Files         200      200              
  Lines       20901    20900       -1     
  Branches     2689     2689              
==========================================
+ Hits         9795    10750     +955     
+ Misses      10628     9550    -1078     
- Partials      478      600     +122     

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


🚨 Try these New Features:

@mao3267 mao3267 changed the title [WIP] [Test] [BUG] Unit tests for dataclass in union with more than two non-None variants [Test] [BUG] Unit tests for dataclass in union with more than two non-None variants Nov 26, 2024
@mao3267 mao3267 marked this pull request as ready for review November 26, 2024 02:08
@mao3267 mao3267 changed the title [Test] [BUG] Unit tests for dataclass in union with more than two non-None variants [WIP] [Test] [BUG] Unit tests for dataclass in union with more than two non-None variants Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In progress
Development

Successfully merging this pull request may close these issues.

1 participant