I am currently using msgspec for deserializing data queried from external REST APIs. Constraints are great for this purpose, because it provides some documentation within the code about the format of the data that we retrieve, and it ensures that we really receive what we expect.
However, once the end-to-end tests for my API client pass, well we are pretty sure that any other request that we may perform in a near future will also return some valid data as expected. Or at least it would be the case for APIs that are stable enough.
This means that all the tests that may be performed at runtime once in production will be nearly redundant, however they could introduce some overhead depending on the size of the data and on the performance that is required.
Therefore I am suggesting to add an enforce_constraints flag (or whatever name fits best) for the Decoders and the decode functions, which could be set to False for disabling these checks.
Description
Hi @jcrist!
I am currently using msgspec for deserializing data queried from external REST APIs. Constraints are great for this purpose, because it provides some documentation within the code about the format of the data that we retrieve, and it ensures that we really receive what we expect.
However, once the end-to-end tests for my API client pass, well we are pretty sure that any other request that we may perform in a near future will also return some valid data as expected. Or at least it would be the case for APIs that are stable enough.
This means that all the tests that may be performed at runtime once in production will be nearly redundant, however they could introduce some overhead depending on the size of the data and on the performance that is required.
Therefore I am suggesting to add an
enforce_constraints
flag (or whatever name fits best) for theDecoder
s and thedecode
functions, which could be set toFalse
for disabling these checks.