Exemplo n.º 1
0
 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)
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
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")