Support for mixed List
See original GitHub issueDacite supports well unions on list when all the items in the list are of the same class. However it does not seem to support unions on lists that have different types of classes.
Example of a test case that fails right now:
@dataclass
class X:
i: int
@dataclass
class Y:
s: str
@dataclass
class Z:
x_or_y: List[Union[X,Y]]
result = from_dict(Z, {'x_or_y': [{'s': 'test'}, {'i': 1}]})
assert result == Z(x_or_y=[Y(s='test'), X(i=1)])
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Am I safe mixing types in a Python list? - Stack Overflow
I'm using this code to randomly set several related parameters within a function, but even though Python supports it, I'm wary of mixing...
Read more >Mixed lists (nesting numbered list inside bullet list) does not ...
Mixed lists (nesting numbered list inside bullet list) does not work as described in Notation Guide | Confluence Server and Data Center.
Read more >Mixed List Definition | GIS Dictionary - Esri Support
The mixed list has a mixed set of rows that might have, for instance, survey points, coordinate geometry measurements, and a mix of...
Read more >Help:List - Wikipedia
In order to be a list, each line must begin the same way. This holds true for mixed lists. # If you start...
Read more >5.35. Functions and Loops Mixed-Up Code Questions
Use a for loop to create and return a list with numbers up to y by skip counting by x . For example,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@oTree-org thank you 😃 I will fix it soon 💪
+1, I ran into the exact same issue. Thanks for the great library!