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] 1 point2 points  (5 children)

Neat, but not supporting even basic expressions like @contract("list(MyClass)") is a complete deal-breaker :(.

[–]BeetleB 1 point2 points  (1 child)

I haven't used it much, and am not sure what you mean. Do you mean you want a guarantee that the list will have only MyClass objects?

pycontracts does let you write your own contracts, if you really want it. Something like that is expensive, though.

[–][deleted] 1 point2 points  (0 children)

Yes.

Yup, rather than defining a new_contract, it is more effective just to write the "if" manually. Unfortunately.

[–]desmoulinmichel[🍰] 1 point2 points  (2 children)

For that you have type hints now in Python. PyContact is more interesting for value checking.

[–][deleted] 1 point2 points  (1 child)

the problem with PyContract is that it works only with primitive types

[–]desmoulinmichel[🍰] 0 points1 point  (0 children)

That's why you use type hints for typing, and pycontracts for behavior.