-
Notifications
You must be signed in to change notification settings - Fork 41
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
Support for collections.abc #440
Comments
Hi @TommyDuc |
I feel it could be fairly easily implemented if you tweak Lines 685 to 701 in 76e919c
Lines 569 to 582 in 76e919c
|
I can look into it this week :) |
I began working on this issue and there will be a name conflict between the types from From example: import typing as t
import collections.abc as abc
@serde
class Foo:
mt: t.Mapping[int, int]
ma: abc.Mapping[int, int] Another option is to create a module to aliases each types (also non-trivial work): # types.py
from collections.abc import Mapping as AbcMapping
from typing import Mapping as TMapping
__all__ = (...) But personally I don't really like type aliases being used to create other types names. Yet another option that would be more generic but would require more work would be make use of Python's protocols paradigm. Looking forward for your input :) |
Hi @TommyDuc Do you mean a name conflict in generated code? Perhaps you could try absolute path e.g. |
Hi!
I was interested in using your library which simply a lot of our serialization, notably because we use frozen dataclasses extensively. We also use the abstract base classes from
collections.abc
so that the collections are also readonly from a typing perspective.However it doesn't seem that ABCs are supported. I also tried defining (de)serializer functions in both the
@serde
decorator and using thefield
function but I still get the same error. IMO ABCs should be work because they can be instantiated using builtin types and deserialized using the same methods as builtins.Here's a reference code:
The text was updated successfully, but these errors were encountered: