-
I just came across CrossHair, and, I must, say, it seems like a really interesting tool! I have a use case that is related to the standard use case for CrossHair, but I am unsure if it actually is a good fit or not, and I hope someone can help me out in clearing it up. I've been using
This I call a "universal" contract because every Python object that has an Having been bit by this once, I am now asking myself: which other classes of object I use on a regular basis are breaking with fundamental assumptions like this? I'd really like a tool to figure this out for me. My questions are then as follows:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
This is a really interesting topic. First off, yes, CrossHair is a good tool for handling these kinds of problems. In particular, take a look at this example which uses a mixin to let classes opt-in to hash-eq consistency testing. Now that's not quite what you're looking for: you want a tool to automatically apply this requirement. One idea I've been toying with: an officially supported way to apply contracts to external classes that you don't control. With that kind of feature, you could apply a contract to Indeed, one could imagine a variety of other universal contracts; maybe stuff like this?:
|
Beta Was this translation helpful? Give feedback.
This is a really interesting topic.
First off, yes, CrossHair is a good tool for handling these kinds of problems. In particular, take a look at this example which uses a mixin to let classes opt-in to hash-eq consistency testing.
Now that's not quite what you're looking for: you want a tool to automatically apply this requirement.
One idea I've been toying with: an officially supported way to apply contracts to external classes that you don't control. With that kind of feature, you could apply a contract to
object
, I suppose, which would do what you want.Indeed, one could imagine a variety of other universal contracts; maybe stuff like this?:
__lt__
is irreflexive, antisymmetric, and t…