Skip to content

Commit 58f5ad6

Browse files
python:ndr: improve type annotation and docs for pack/unpack
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz> Autobuild-User(master): Douglas Bagnall <dbagnall@samba.org> Autobuild-Date(master): Fri Aug 8 00:29:00 UTC 2025 on atb-devel-224
1 parent 49e7f2e commit 58f5ad6

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

python/samba/ndr.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,19 @@
2121
"""Network Data Representation (NDR) marshalling and unmarshalling."""
2222

2323

24-
def ndr_pack(object):
24+
def ndr_pack(object) -> bytes:
2525
"""Pack a NDR object.
2626
2727
:param object: Object to pack
28-
:return: String object with marshalled object.
28+
:return: bytes object with marshalled object.
2929
"""
3030
ndr_pack = getattr(object, "__ndr_pack__", None)
3131
if ndr_pack is None:
3232
raise TypeError("%r is not a NDR object" % object)
3333
return ndr_pack()
3434

3535

36-
def ndr_unpack(cls, data, allow_remaining=False):
36+
def ndr_unpack(cls, data:bytes, allow_remaining=False):
3737
"""NDR unpack an object.
3838
3939
:param cls: Class of the object to unpack
@@ -75,21 +75,25 @@ def ndr_deepcopy(object):
7575
return copy
7676

7777

78-
def ndr_pack_in(object, bigendian=False, ndr64=False):
78+
def ndr_pack_in(object, bigendian=False, ndr64=False) -> bytes:
7979
"""Pack the input of an NDR function object.
8080
8181
:param object: Object to pack
8282
:param bigendian: use LIBNDR_FLAG_BIGENDIAN (default=False)
8383
:param ndr64: use LIBNDR_FLAG_NDR64 (default=False)
84-
:return: String object with marshalled object.
84+
:return: bytes object with marshalled object.
8585
"""
8686
ndr_pack_in_fn = getattr(object, "__ndr_pack_in__", None)
8787
if ndr_pack_in_fn is None:
8888
raise TypeError("%r is not a NDR function object" % object)
8989
return ndr_pack_in_fn(bigendian=bigendian, ndr64=ndr64)
9090

9191

92-
def ndr_unpack_in(object, data, bigendian=False, ndr64=False, allow_remaining=False):
92+
def ndr_unpack_in(object,
93+
data: bytes,
94+
bigendian=False,
95+
ndr64=False,
96+
allow_remaining=False):
9397
"""Unpack the input of an NDR function object.
9498
9599
:param cls: Class of the object to unpack

0 commit comments

Comments
 (0)