From 6b4f755c2878bce0e435b0b0112d4d5d0ad12ea1 Mon Sep 17 00:00:00 2001 From: Bartek Ogryczak Date: Fri, 30 Sep 2016 17:52:04 -0700 Subject: [PATCH] a __validated__ marker to easily verify if function was decorated with validator --- conformity/validator.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/conformity/validator.py b/conformity/validator.py index 3e99d0b..ea5b8cd 100644 --- a/conformity/validator.py +++ b/conformity/validator.py @@ -40,5 +40,9 @@ def inner(*passed_args, **passed_kwargs): # Validate return value validate(returns, return_value, "return value") return return_value + inner.__wrapped__ = func + # caveat: checking for f.__validated__ will only work if + # @validate_call is the outermost decorator + inner.__validated__ = True return inner return decorator