Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@icontract.pre(lambda b: b > 3)
def some_function(a: int) -> None: # pylint: disable=unused-variable
pass
@icontract.pre(lambda x: x > 3, enabled=False)
def pow_with_pre(x: int, y: int) -> int:
return x**y
@icontract.pre(lambda self: self._some_prop > 0)
def some_prop(self) -> int:
return self._some_prop
@icontract.pre(lambda x: x > 3, repr_args=lambda z: "z was {:X}".format(z))
def some_func(x: int, y: int = 5) -> None:
pass
except ValueError as err:
@icontract.pre(lambda x: x > 3)
def some_method(self, x: int) -> int:
return self.y
@icontract.pre(lambda self: self.y > 10, repr_args=lambda self: "self.y was {}".format(self.y))
def some_method_with_self(self) -> None:
pass
@icontract.pre(lambda x: x > 3, "x must not be small")
def some_func(x: int, y: int = 5) -> None:
pass
@icontract.pre(lambda x: x > 3)
def pow_with_pre(x: int, y: int) -> int:
return x**y
@icontract.pre(lambda x: x % 2 == 0)
def func(self, x: int) -> None:
pass
@icontract.pre(lambda x: x > 0, error=lambda x, y: ValueError("x is {}, y is {}".format(x, y)))
def some_func(x: int, y: int) -> int:
return 0