Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
x: frozenset
@dataclass
class DataClassWithGenericFrozenSet(DataClassDictMixin):
x: FrozenSet[int]
@dataclass
class DataClassWithCustomSerializableFrozenSet(DataClassDictMixin):
x: CustomSerializableFrozenSet
# ChainMap
@dataclass
class DataClassWithChainMap(DataClassDictMixin):
x: collections.ChainMap
@dataclass
class DataClassWithGenericChainMap(DataClassDictMixin):
x: ChainMap[int, int]
@dataclass
class DataClassWithCustomSerializableChainMap(DataClassDictMixin):
x: CustomSerializableChainMap
# dict
@dataclass
class DataClassWithDict(DataClassDictMixin):
# str
@dataclass
class DataClassWithStr(DataClassDictMixin):
x: str
# sequence
@dataclass
class DataClassWithCustomSerializableSequence(DataClassDictMixin):
x: CustomSerializableSequence
@dataclass
class DataClassWithCustomSerializableMutableSequence(DataClassDictMixin):
x: CustomSerializableMutableSequence
@dataclass
class DataClassWithAbstractSequence(DataClassDictMixin):
x: AbstractSequence
@dataclass
class DataClassWithAbstractMutableSequence(DataClassDictMixin):
x: AbstractMutableSequence
@dataclass
class DataClassWithEnum(DataClassDictMixin):
x: MyEnum
x: CustomSerializableSet
@dataclass
class DataClassWithAbstractSet(DataClassDictMixin):
x: AbstractSet
@dataclass
class DataClassWithAbstractMutableSet(DataClassDictMixin):
x: AbstractMutableSet
# frozenset
@dataclass
class DataClassWithFrozenSet(DataClassDictMixin):
x: frozenset
@dataclass
class DataClassWithGenericFrozenSet(DataClassDictMixin):
x: FrozenSet[int]
@dataclass
class DataClassWithCustomSerializableFrozenSet(DataClassDictMixin):
x: CustomSerializableFrozenSet
# ChainMap
@dataclass
class DataClassWithChainMap(DataClassDictMixin):
def test_derived_dataclass_with_ancestors_defaults():
@dataclass
class A:
x: int
y: int = 1
@dataclass
class B(A, DataClassDictMixin):
z: int = 3
@dataclass
class C(B, DataClassDictMixin):
y: int = 4
@dataclass
class D(C):
pass
assert B.from_dict({'x': 0}) == B(x=0, y=1, z=3)
assert C.from_dict({'x': 0}) == C(x=0, y=4, z=3)
assert D.from_dict({'x': 0}) == D(x=0, y=4, z=3)
x: FrozenSet[int]
@dataclass
class DataClassWithCustomSerializableFrozenSet(DataClassDictMixin):
x: CustomSerializableFrozenSet
# ChainMap
@dataclass
class DataClassWithChainMap(DataClassDictMixin):
x: collections.ChainMap
@dataclass
class DataClassWithGenericChainMap(DataClassDictMixin):
x: ChainMap[int, int]
@dataclass
class DataClassWithCustomSerializableChainMap(DataClassDictMixin):
x: CustomSerializableChainMap
# dict
@dataclass
class DataClassWithDict(DataClassDictMixin):
x: dict
@dataclass
class DataClassWithGenericDict(DataClassDictMixin):
class DataClassWithCustomSerializableMutableSequence(DataClassDictMixin):
x: CustomSerializableMutableSequence
@dataclass
class DataClassWithAbstractSequence(DataClassDictMixin):
x: AbstractSequence
@dataclass
class DataClassWithAbstractMutableSequence(DataClassDictMixin):
x: AbstractMutableSequence
@dataclass
class DataClassWithEnum(DataClassDictMixin):
x: MyEnum
@dataclass
class DataClassWithIntEnum(DataClassDictMixin):
x: MyIntEnum
@dataclass
class DataClassWithFlag(DataClassDictMixin):
x: MyFlag
@dataclass
class DataClassWithIntFlag(DataClassDictMixin):
x: MyIntFlag
class DataClassWithAbstractMutableSequence(DataClassDictMixin):
x: AbstractMutableSequence
@dataclass
class DataClassWithEnum(DataClassDictMixin):
x: MyEnum
@dataclass
class DataClassWithIntEnum(DataClassDictMixin):
x: MyIntEnum
@dataclass
class DataClassWithFlag(DataClassDictMixin):
x: MyFlag
@dataclass
class DataClassWithIntFlag(DataClassDictMixin):
x: MyIntFlag
x: CustomSerializableDeque
# tuple
@dataclass
class DataClassWithTuple(DataClassDictMixin):
x: tuple
@dataclass
class DataClassWithGenericTuple(DataClassDictMixin):
x: Tuple[int]
@dataclass
class DataClassWithCustomSerializableTuple(DataClassDictMixin):
x: CustomSerializableTuple
# set
@dataclass
class DataClassWithSet(DataClassDictMixin):
x: set
@dataclass
class DataClassWithGenericSet(DataClassDictMixin):
x: Set[int]
@dataclass
class DataClassWithCustomSerializableSet(DataClassDictMixin):
a = 1
b = 2
class MyFlag(Flag):
a = 1
b = 2
class MyIntFlag(IntFlag):
a = 1
b = 2
@dataclass
class MyDataClass(DataClassDictMixin):
a: int
b: int
class MutableString(SerializableType):
def __init__(self, value: str):
self.characters = [c for c in value]
def _serialize(self) -> str:
return str(self)
@classmethod
def _deserialize(cls, value: str) -> 'MutableString':
return MutableString(value)
def __str__(self):
x: CustomSerializableList
# deque
@dataclass
class DataClassWithDeque(DataClassDictMixin):
x: collections.deque
@dataclass
class DataClassWithGenericDeque(DataClassDictMixin):
x: Deque[int]
@dataclass
class DataClassWithCustomSerializableDeque(DataClassDictMixin):
x: CustomSerializableDeque
# tuple
@dataclass
class DataClassWithTuple(DataClassDictMixin):
x: tuple
@dataclass
class DataClassWithGenericTuple(DataClassDictMixin):
x: Tuple[int]
@dataclass
class DataClassWithCustomSerializableTuple(DataClassDictMixin):