Replies: 2 comments 2 replies
-
This is a great idea! I've done a tiny amount of thinking along these lines as well. There's a nice idea in there about what behaviors the library author is trying guarantee (and maybe what behaviors the author isn't). Perhaps we even recommend that contracts go directly into the pyi file, right along with the types! (I think all type checkers ignore the function bodies) In addition, I think it would be really interesting to think about how contracts could change the way we think about library versioning: CrossHair could theoretically tell you whether your contract changes are backwards-compatible (i.e. it's safe to weaken your preconditions, or strengthen your postconditions). |
Beta Was this translation helpful? Give feedback.
-
A note: @lmontand is actively working on something that is approaching this request: a programmatic way to attach contracts to existing functions. We'll update this thread when there is something more concrete to say! |
Beta Was this translation helpful? Give feedback.
-
By analogy to type stub files maybe we'd want to be able to write contract stub files for third party libraries. They wouldn't be checked, they'd just be there to tell CrossHair facts to make its job easier.
Beta Was this translation helpful? Give feedback.
All reactions