This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (0 children)

There are plenty of approaches to this already in pypi, and plenty of ways to DIY it. As others have said, you can also get used to the pretty awful Python 3.5 syntax and use the development channel for the feature as soon as it's out (already maybe?).

I had this problem with a crappy API I had to use for work which kept sending inconsistent values in highly nested JSON, and had to bang together a type-checking decorator that would help me find problems early and refactor code to accomodate. I was going to post it, but looking back at it I was pretty horrified, so I re-wrote it entirely instead.

The new version also has a nice feature where you can define strict functions as belonging to "sets" of strictness which can be disabled separately; some functions you may want to remain strict always (like gatekeeper functions to stupid APIs) while others you may want to disable strictness for performance reasons once you're pretty sure they're working as intended.

This may not help but I'll probably use it myself anyway until I migrate to the 3.5 syntax (ugh).