Construct-dataclasses

Latest version: v1.1.10

Safety actively analyzes 681812 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 1 of 2

1.1.9

This small patch includes a shortcut for enums within class definitions:

python
import enum
import construct as cs
import construct_dataclasses as csd

class Foo(enum.IntEnum):
A = 0
B = 0
C = 0

csd.dataclass_struct
class Bar:
magic: int = csd.csfield(cs.Int8ul)
foo_type: Foo = csd.csenum(Foo, cs.Int32ul) enum-type and subcon



**Full Changelog**: https://github.com/MatrixEditor/construct-dataclasses/compare/v1.1.8...v1.1.9

1.1.8

+ This release fixes support for union structures
+ Use `union=True` for default Union generation and `union=(1 or "foo")` to reference a context variable within the union ("parsefrom" parameter)
python
dataclass
class Blob:
width: int = csfield(Int8ub)
height: int = csfield(Int8ub)

dc = DataclassStruct(Blob, union=True)
blob = dc.parse(b"\x01\x02\x03\x03\x03")
print(blob) Blob(width=1, height=1)


**Full Changelog**: https://github.com/MatrixEditor/construct-dataclasses/compare/v1.1.7...v1.1.8

1.1.7

Use `container` to mimic a construct container instance if needed. That may be the case if you have to access
an already parsed object of a custom type:
python
container
dataclasses.dataclass
class ImageHeader:
length: int = csfield(Int32ub)

dataclasses.dataclass
class Image:
header: ImageHeader = csfield(ImageHeader)
data: bytes = csfield(Bytes(this.header.length))

The access to `header.length` would throw an exception without the container annotation.

What's Changed
* [FIX]: container-like behaviour by MatrixEditor in https://github.com/MatrixEditor/construct-dataclasses/pull/3


**Full Changelog**: https://github.com/MatrixEditor/construct-dataclasses/compare/v1.1.6...v1.1.7

1.1.6

This release includes a stub file generated from the original source code.

**Full Changelog**: https://github.com/MatrixEditor/construct-dataclasses/compare/v1.1.5...v1.1.6

1.1.4

In some situations, the method `to_object` may raise an exception if an already created dataclass object is passed as the container instance. For instance:

python
import dataclasses as dc
from construct_dataclasses import DataclassStruct, csfield

dc.dataclass
class foo_t:
magic: int = csfield(cs.Int32ul)

Foo = DataclassStruct(foo_t)

cd.dataclass
class bar_t:
to_object raised an exception here
foo: Foo = csfield(Foo)

1.1.3

This small patch fixes the full support of optional types as well as fixing the `dataclass_struct` decorator.

Page 1 of 2

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.