def _typecheck(self, attr, value): expected_type = typecheck.get_arg_type_from_constructor_annotation( type(self), attr ) if expected_type is None: return # no type info :( typecheck.check_type(attr, value, expected_type)
def _typecheck(self, attr, value): expected_type = typecheck.get_arg_type_from_constructor_annotation( type(self), attr ) if expected_type is None: return # no type info :( typecheck.check_type(attr, value, expected_type)
def test_get_arg_type_from_constructor_annotation(): assert typecheck.get_arg_type_from_constructor_annotation(T, "foo") == str assert typecheck.get_arg_type_from_constructor_annotation(T, "bar") == int assert not typecheck.get_arg_type_from_constructor_annotation(T, "baz")