Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What should dec_hook raise if the type is unsupported? #774

Open
lunik1 opened this issue Nov 20, 2024 · 1 comment
Open

What should dec_hook raise if the type is unsupported? #774

lunik1 opened this issue Nov 20, 2024 · 1 comment

Comments

@lunik1
Copy link

lunik1 commented Nov 20, 2024

Question

There seems to be a (deliberate?) inconsistency in the docs regarding what exception dec_hook should raise if the expected message type is unsupported.

json.decode states that TypeError should be raised.
All other instances state that NotImplementedError should be raised.

Can you clarify which is correct?

  • dec_hook should raise TypeError for unsupported types
  • dec_hook should raise NotImplementedError for unsupported types
  • dec_hook should raise NotImplementedError for unsupported types, unless it is being passed to msgspec.json.decode when it should raise TypeError.
  • other?
@jcrist
Copy link
Owner

jcrist commented Nov 20, 2024

Oops, the TypeError there is incorrect (will fix). You should raise a NotImplementedError if the type is unsupported, and raise a TypeError/ValueError if the value doesn't match that type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants