Skip to content

Type hints for msgpack #1089

Answered by srittau
dineshbvadhia asked this question in Q&A
Feb 20, 2022 · 1 comments · 3 replies
Discussion options

You must be logged in to vote

I'm not familiar with numpy or msgpack, but I'll try to answer your questions as well as I can.

The value arguments to msgpack_serialize() and msgpack_deserialize() are just passed on to msgpack.packb() and unpackb(), respectively. While msgpack has no type hints, at least unpackb() could probably simply be annotated using bytes: def msgpack_deserialize(value: bytes):. I couldn't find the definition of packb(), so I don't know how to best annotate it.

In the calls to somedb() you are trying to annotate the passed arguments. This doesn't work and is unnecessary. Just pass the value:

with somedb('mydb', 'w') as db:
    ...

As I assume that packb() returns bytes, you could annotate the retur…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@dineshbvadhia
Comment options

@srittau
Comment options

@dineshbvadhia
Comment options

Answer selected by dineshbvadhia
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants