diff --git a/satella/coding/typecheck.py b/satella/coding/typecheck.py index f3d89e58f33c7f645ea97c918e8a8a62fb071a71..6db2e52cc124b17b88065e8b2b492788e0afcfb5 100644 --- a/satella/coding/typecheck.py +++ b/satella/coding/typecheck.py @@ -265,6 +265,7 @@ def typed(*t_args, **t_kwargs): :param t_args: :param t_kwargs: """ + t_args = [(__typeinfo_to_tuple_of_types(x) if x is not None else None) for x in t_args] t_retarg = t_kwargs.get('returns', None) diff --git a/tests/test_coding/test_debug.py b/tests/test_coding/test_debug.py index 486d0cad4a9fa5ccc408de22067bcd9a03868f30..26d678c9b1b2b8ee58f6427a28e97bb6a0f2d4dc 100644 --- a/tests/test_coding/test_debug.py +++ b/tests/test_coding/test_debug.py @@ -6,6 +6,25 @@ from satella.coding import typed, CallSignature class TestTypecheck(unittest.TestCase): + def test_cls(self): + # if we don't care about apps + class Lol(object): + @typed(returns=int) + def zomg(self, a): + return a + + Lol().zomg(2) + self.assertRaises(TypeError, lambda: Lol().zomg('a')) + + def test_cls_test(self): + + class Lol(object): + # this should fail, since the first argument the decorator gets is "self", because decorators always get FUNCTION objects! + @typed(int, returns=int) + def zomg(self, a): + return a + + self.assertRaises(TypeError, lambda: Lol().zomg(2)) def test_ta(self):