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 Literal?

See original GitHub issue

I’d like to be able to deserialize from_dict() a Union of overlapping types based on the Literal values. Is that possible?

    @dataclass
    class AType:
        # changing type to str doesn't help
        type: Literal['A'] = 'A'

    @dataclass
    class BType:
        type: Literal['B'] = 'B'

    @dataclass
    class AorB:
        u: Union[AType, BType]

        obj = dacite.from_dict(
            data_class=AorB,
            data=loaded_dict,
            config=dacite.Config(strict=False)
       )

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jbcpollakcommented, Oct 9, 2020

@Gideon-Felt in the meantime you can use this in your requirements.txt file:

git+https://github.com/Pickle-Robot/dacite/@master#egg=dacite

We are still stuck on 3.7.6 as well and this works for us.

1reaction
konradhalascommented, Mar 14, 2020

@jbcpollak Deployed to PyPI 🎉

Read more comments on GitHub >

github_iconTop Results From Across the Web

Literal Support Definition - patents - Law Stack Exchange
Literal support means that the words of the claim are identical to words in the description. It does not have any particular nuanced...
Read more >
ES6 Template Literals (Template Strings) - CanIUse
Template literals are string literals allowing embedded expressions using backtick characters (`). You can use multi-line strings and string interpolation ...
Read more >
Template literals (Template strings) - JavaScript | MDN
Template literals are literals delimited with backtick ( ` ) characters, allowing for multi-line strings, string interpolation with embedded ...
Read more >
Add support for literal-string type, to address Injection ... - GitHub
To help with adoption, literal-string values can be concatenated. This is often used by developers today, and because no user input is included, ......
Read more >
ARM Compiler v5.06 for uVision armcc User Guide
Compiler support for literal pools. Literal pools are areas of constant data in a code section. No single instruction can generate a 4...
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