You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Another problem with this approach: typedecorator by default raises TypeError (in any case, a single exception class), but with contracts it makes sense to return ValueError (or at least something different to TypeError) if contracts are violated.
This would mean we'd have to support raising various exceptions based on the type of type/constraint violation, which would make the code more convoluted.
Should we support contracts?
It would be straightforward to support contracts by supporting custom callables in type signatures. For example:
However, I find that syntax clunky (for contracts), compared to something like:
But this being typedecorator, not a full-blown contracts library, I'm hesitant to grow it in that direction (unless there's popular demand).
The text was updated successfully, but these errors were encountered: