Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [Unreleased]
**Fixes:**
- Fixed return type of `Construct._build()`: `int` was wrong and worked only in specific cases.

## [0.8.1] - 2026-07-23
**New features:**
- Added `Subconstruct`, `SymmetricAdapter`, `Tunnel` and `Validator` to `construct_typed` as subscriptable types.
Expand All @@ -23,4 +27,4 @@
- Use PEP604 union syntax "X | Y" instead of "Union[X, Y]" and "X | None" instead of "Optional[X]" in type hints.

**Organizational changes:**
- Use `uv` as a project management tool and `poe` as a task runner.
- Use `uv` as a project management tool and `poe` as a task runner.
4 changes: 3 additions & 1 deletion construct-stubs/core.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,11 @@ class Construct(t.Generic[ParsedType, BuildTypes]):
def _parsereport(
self, stream: StreamType, context: Context, path: PathType
) -> ParsedType: ...
# In most implementations, `_build()` actually returns `ParsedType`, in some others it
# returns `BuildTypes` or something else entirely. `t.Any` seems a good compromise.
def _build(
self, obj: BuildTypes, stream: StreamType, context: Context, path: PathType
) -> int: ...
) -> t.Any: ...
def _sizeof(self, context: Context, path: PathType) -> int: ...

@t.type_check_only
Expand Down
10 changes: 10 additions & 0 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1781,6 +1781,16 @@ def __init__(
hashfunc: t.Callable[[bytes], BuildTypes],
bytesfunc: t.Callable[[Context], bytes],
) -> None: ...

def _parse(self, stream: t.IO[bytes], context: Context, path: str) -> ParsedType:
...

def _build(self, obj: BuildTypes, stream: t.IO[bytes], context: Context, path: str) -> t.Any:
...

def _sizeof(self, context: Context, path: str) -> int:
...

else:
import binascii

Expand Down
Loading