I got a chance to look at the fix (https://github.com/jcrist/msgspec/pull/602) and the corresponding tests. I copied your test below and made Custom inherit msgspec.Struct. Encoding still works but now decoding throws the following error
msgspec.ValidationError: Expected `object`, got `str` - at `key` in `$`
This is the code I used to generate the error (taken from your tests)
Is this expected behavior? Would it be difficult to support msgspec Structs as dictionary keys?
Another thing I found is using msgspec.*.decode(dec_hook=..., type=Dict[TypeVar('A') TypeVar('B')] did not work for me. Namely I wrote a stub dec_hook function that printed 'hello world' and it never triggered on decoding.
Maybe I was doing something wrong, but was wondering if this is supported at all.
Question
I made a comment on a closed issue (https://github.com/jcrist/msgspec/issues/568) and I'm not sure it got any visibility so I'm creating a new one instead.
Here's a copy-pasta of my comment:
I got a chance to look at the fix (https://github.com/jcrist/msgspec/pull/602) and the corresponding tests. I copied your test below and made Custom inherit
msgspec.Struct
. Encoding still works but now decoding throws the following errorThis is the code I used to generate the error (taken from your tests)
Is this expected behavior? Would it be difficult to support msgspec Structs as dictionary keys?
Another thing I found is using
msgspec.*.decode(dec_hook=..., type=Dict[TypeVar('A') TypeVar('B')]
did not work for me. Namely I wrote a stubdec_hook
function that printed 'hello world' and it never triggered on decoding.Maybe I was doing something wrong, but was wondering if this is supported at all.