3 ms·
You may also want to do sanity checks but, in those cases, I tend to deliberately abuse the inputs. Send a string, a byte string, some invalid UTF-8, an emoji,
by rbanffy 6y ago
You may also want to do sanity checks but, in those cases, I tend to deliberately abuse the inputs. Send a string, a byte string, some invalid UTF-8, an emoji, an invoice, and ensure that the thing can take more abuse than what the manual says.
If, however, the manual says “integer” then it should complain loudly the user is breaking the contract.
- StavrosK 6y ago> If, however, the manual says “integer” then it should complain loudly the user is breaking the contract. Yep, that's why I prefer mypy/typeguard and type annotations for those sorts of things over checking in the body. It's frequently much, much easier to read, and self-documenting, since most IDEs have support for that when calling the function nowadays.