code: def _check_type(value, expected_type):
      
      if not isinstance(value, expected_type):
          raise TypeError("Value {value!r} has unexpected type {actual_type!r}, expected {expected_type!r}".format(
              value=value,
              expected_type=expected_type,
              actual_type=type(value),
          ))
      return value
docs: Perform type checking on the provided value
  
      This is a helper that will raise ``TypeError`` if the provided value is
      not an instance of the provided type.  This method should be used sparingly
      but can be good for preventing problems earlier when you want to restrict
      duck typing to make the types of fields more obvious.
  
      If the value passed the type check it will be returned from the call.