Closed Bernardstanislas closed 6 years ago
Works for me. Merged...and fixed to only deal with class methods and work on both Python 2 and 3. :)
@Bernardstanislas Please check the latest master and see if it works for you. Thanks.
@deadpixi it does not work, I think you made a mistake refactoring the check
function:
https://github.com/deadpixi/contracts/commit/e38ea7b2e1c7abe53de63301df3a6d4689e352d4#diff-29bd5250e9cbe38f796792663ea86090R499
if ismethod(f):
return True # Python 2
should be
if ismethod(f):
return False # Python 2
since you don't want to check class methods
@Bernardstanislas Try it now, please. Should work much better, and should be easier to read.
The problem is that "ismethod" is defined differently in Python 2 and 3.
Context
I have classes with
classmethod
methods, using invariants on such classes fails since it cannot get a properself
instance.Suggestion
I suggest such class methods are bypassed by the invariant conditions.
@deadpixi what do you think? :)