Skip to content

Commit 4758081

Browse files
committed
Added type hints to struct
1 parent 45b6e01 commit 4758081

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

shared-bindings/struct/__init__.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ STATIC mp_obj_t struct_calcsize(mp_obj_t fmt_in) {
6262
}
6363
MP_DEFINE_CONST_FUN_OBJ_1(struct_calcsize_obj, struct_calcsize);
6464

65-
//| def pack(fmt: Any, *values: Any) -> Any:
65+
//| def pack(fmt: string, *values: ReadableBuffer) -> bytes:
6666
//| """Pack the values according to the format string fmt.
6767
//| The return value is a bytes object encoding the values."""
6868
//| ...
@@ -80,7 +80,7 @@ STATIC mp_obj_t struct_pack(size_t n_args, const mp_obj_t *args) {
8080
}
8181
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(struct_pack_obj, 1, MP_OBJ_FUN_ARGS_MAX, struct_pack);
8282

83-
//| def pack_into(fmt: Any, buffer: Any, offset: Any, *values: Any) -> Any:
83+
//| def pack_into(fmt: string, buffer: WriteableBuffer, offset: int, *values: readableBuffer) -> None:
8484
//| """Pack the values according to the format string fmt into a buffer
8585
//| starting at offset. offset may be negative to count from the end of buffer."""
8686
//| ...
@@ -106,7 +106,7 @@ STATIC mp_obj_t struct_pack_into(size_t n_args, const mp_obj_t *args) {
106106
}
107107
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(struct_pack_into_obj, 3, MP_OBJ_FUN_ARGS_MAX, struct_pack_into);
108108

109-
//| def unpack(fmt: Any, data: Any) -> Any:
109+
//| def unpack(fmt: string, data: ReadableBuffer) -> tuple:
110110
//| """Unpack from the data according to the format string fmt. The return value
111111
//| is a tuple of the unpacked values. The buffer size must match the size
112112
//| required by the format."""
@@ -124,7 +124,7 @@ STATIC mp_obj_t struct_unpack(size_t n_args, const mp_obj_t *args) {
124124
}
125125
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(struct_unpack_obj, 2, 3, struct_unpack);
126126

127-
//| def unpack_from(fmt: Any, data: Any, offset: Any = 0) -> Any:
127+
//| def unpack_from(fmt: string, data: ReadableBuffer, offset: int = 0) -> tuple:
128128
//| """Unpack from the data starting at offset according to the format string fmt.
129129
//| offset may be negative to count from the end of buffer. The return value is
130130
//| a tuple of the unpacked values. The buffer size must be at least as big

0 commit comments

Comments
 (0)