RestrictType

class ipkiss3.all.RestrictType

restrict the type or types the argument can have. Pass a type or tuple of types

Parameters:
allowed_types: list or tuple

A tuple or list of types, the value assigned to the property should be an instance of one of those types.

Examples

import ipkiss3.all as i3

class Example(i3.StrongPropertyInitializer):

    num_prop = i3.DefinitionProperty(restriction=i3.RestrictType((int, float)))

example1 = Example(num_prop=1.0) # this is ok
example2 = Example(num_prop=1) # this is ok as well
example3 = Example(num_prop="str") # this will fail
allowed_types