parameters: (arg_name, arg_value, valid_types)
docstring: Checks whether a value is instance of some types.
docstring_summary: Checks whether a value is instance of some types.
docstring_tokens: Checks whether a value is instance of some types .
function: def check_value_type(arg_name, arg_value, valid_types):
      """Checks whether a value is instance of some types."""
      valid_types = tuple(valid_types) if isinstance(valid_types, Iterable) else (valid_types,)
      is_valid = True
  
      # bool is subclass of int, so for a bool value, we need to extra check
      if isinstance(arg_value, int) and isinstance(arg_value, bool) and bool not in valid_types:
          is_valid = False
  
      if not isinstance(arg_value, valid_types):
          is_valid = False
  
      if not is_valid:
          raise TypeError(f'For `{arg_name}` the type should be a valid type of {[t.__name__ for t in valid_types]}, '
                          f'but got {type(arg_value).__name__}.')
function_tokens: def check_value_type ( arg_name , arg_value , valid_types ) : valid_types = tuple ( valid_types ) if isinstance ( valid_types , Iterable ) else ( valid_types , ) is_valid = True # bool is subclass of int, so for a bool value, we need to extra check if isinstance ( arg_value , int ) and isinstance ( arg_value , bool ) and bool not in valid_types : is_valid = False if not isinstance ( arg_value , valid_types ) : is_valid = False if not is_valid : raise TypeError ( f'For `{arg_name}` the type should be a valid type of {[t.__name__ for t in valid_types]}, ' f'but got {type(arg_value).__name__}.' )