question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for mixed List

See original GitHub issue

Dacite 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:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
konradhalascommented, Jan 25, 2019

@oTree-org thank you 😃 I will fix it soon 💪

1reaction
oTree-orgcommented, Jan 25, 2019

+1, I ran into the exact same issue. Thanks for the great library!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found