1
1
Changelog
2
2
=========
3
3
4
+ 0.12.0
5
+ ------
6
+
7
+ Released 2024-09-09
8
+
9
+ New Features
10
+ ~~~~~~~~~~~~
11
+
12
+ Type Checking Compatibility
13
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^
14
+
15
+ Type checker-compatible annotations are finally here! The old dataclass annotation way
16
+ would cause type checkers to report errors when you try assigning an ``int `` to a field
17
+ marked as ``UInt8 ``. You can now get around this by using ``typing.Annotated ``.
18
+
19
+ The old way:
20
+
21
+ .. code-block :: python
22
+
23
+ @binobj.dataclass
24
+ class MyStruct (binobj .Struct ):
25
+ foo: UInt16
26
+ bar: StringZ = " "
27
+ sub_struct: MyOtherStruct
28
+ baz: Timestamp64(signed = False )
29
+
30
+ To save you headaches with MyPy, the same struct can be declared like so:
31
+
32
+ .. code-block :: python
33
+
34
+ @binobj.dataclass
35
+ class MyStruct (binobj .Struct ):
36
+ foo: Annotated[int , UInt16]
37
+ bar: Annotated[str , StringZ] = " "
38
+ sub_struct: MyOtherStruct # Note no change necessary here
39
+ baz: Annotated[datetime, Timestamp64(signed = False )]
40
+
41
+ Full Mapping-like Behavior
42
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^
43
+
44
+ Two new struct wrappers, ``StructMappingProxy `` and ``MutableStructMappingProxy ``, allow
45
+ you to use a ``Struct `` exactly as you would a ``Mapping `` or ``MutableMapping ``:
46
+
47
+ .. code-block :: python
48
+
49
+ ro_proxy = binobj.StructMappingProxy(struct_instance)
50
+ assert ro_proxy.struct is struct_instance # Original struct still available
51
+
52
+ for key, value in ro_proxy.items():
53
+ print (f " { k!r } = { v!r } " )
54
+
55
+ cm = collections.ChainMap({}, binobj.MutableStructMappingProxy(struct_instance))
56
+
57
+ These are typed as ``Mapping[str, Any] `` and ``MutableMapping[str, Any] ``, respectively.
58
+
59
+ Other New Features
60
+ ^^^^^^^^^^^^^^^^^^
61
+
62
+ Now testing on Python 3.13-rc1.
63
+
64
+ .. _PEP 593 : https://peps.python.org/pep-0593/
65
+
66
+ Deprecations
67
+ ~~~~~~~~~~~~
68
+
69
+ * Support for Python 3.9 will be removed in the next backwards-incompatible release.
70
+ * Using ``Field `` instances as bare annotations is deprecated; use ``typing.Annotated ``
71
+ instead.
72
+
73
+ Bugfixes
74
+ ~~~~~~~~
75
+
76
+ * On Python ≤ 3.10, using ``Field `` instances as type annotations completely broke if
77
+ deferred annotation evaluation was enabled with ``from __future__ import annotations ``.
78
+ This can now be worked around by using ``Annotated ``, or with normal field assignment.
79
+ * When reading fixed data, if ``exact `` was true the error message would be one byte off
80
+ when saying how much it expected to read.
81
+ * Better type annotations for containers.
82
+ * Error messages now use ``__qualname__ `` for classes, instead of ``__name__ ``. This
83
+ will only change the output of nested classes.
84
+
85
+ Breaking Changes
86
+ ~~~~~~~~~~~~~~~~
87
+
88
+ Dropped support for EOL Python 3.7 and 3.8.
89
+
90
+ Other Changes
91
+ ~~~~~~~~~~~~~
92
+
93
+ * Refactored ``Struct `` class initialization and pushed it into a factory method on
94
+ ``StructMetadata ``. The eventual goal is to completely eliminate the need for
95
+ inheriting ``Struct ``.
96
+ * Switched from Black to Ruff.
97
+ * Minimum version of ``typing_extensions `` is now 4.4.
98
+ * Upgraded test dependencies.
99
+
4
100
0.11.4
5
101
------
6
102
103
+ Released 2024-03-13
104
+
7
105
Bugfixes
8
106
~~~~~~~~
9
107
@@ -28,6 +126,8 @@ Other Changes
28
126
0.11.3
29
127
------
30
128
129
+ Released 2023-11-10
130
+
31
131
Bugfixes
32
132
~~~~~~~~
33
133
@@ -37,6 +137,8 @@ in 3.10. We now handle that case in the annotation detection.
37
137
0.11.2
38
138
------
39
139
140
+ (YANKED)
141
+
40
142
Bugfixes
41
143
~~~~~~~~
42
144
@@ -57,6 +159,8 @@ Other Changes
57
159
0.11.1
58
160
------
59
161
162
+ Released 2023-09-16
163
+
60
164
Bugfixes
61
165
~~~~~~~~
62
166
@@ -91,6 +195,8 @@ behaves the same.
91
195
0.11.0
92
196
------
93
197
198
+ Released 2023-02-14
199
+
94
200
New Features
95
201
~~~~~~~~~~~~
96
202
0 commit comments