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

Literal (and Union[Literal]) support #170

Open
davetapley opened this issue Jun 7, 2022 · 1 comment
Open

Literal (and Union[Literal]) support #170

davetapley opened this issue Jun 7, 2022 · 1 comment
Labels
feature A new feature that awaits implementation

Comments

@davetapley
Copy link
Contributor

Feature request for:

@dataclass
class HasLiteral:
  foo: Literal["one"]

jsons.loads('{"foo": "one"}', HasLiteral)

Currently gives:

DeserializationError: No deserializer for type "typing.Literal"

And more realistic use case:

@dataclass
class HasLiteral:
  foo: Union[Literal["one"], Literal["two"]]

Currently gives:

DeserializationError: Could not match the object of type "str" to any type of the Union: Literal, Literal

I can have a go if a PR would be accepted?

@ramonhagenaars ramonhagenaars added the feature A new feature that awaits implementation label Jun 9, 2022
@ramonhagenaars
Copy link
Owner

Hi @davetapley. I think your feature request makes sense, I would gladly accept a PR on this 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new feature that awaits implementation
Projects
None yet
Development

No branches or pull requests

2 participants