sob/model.py
def detect_format(
    data: Optional[Union[str, bytes, abc.Readable]]
) -> Tuple[Any, str]:
    """
    This function accepts a string or file-like object and returns a tuple
    containing the deserialized information and a string indicating the format
    of that information.

    Parameters:

    - data (str|abc.Readable): A string or file-like object containing
      JSON or YAML serialized data.

    This function returns a `tuple` of two items:

    - (str|dict|list|int|float|bool): The deserialized (but not un-marshalled)
      data.
    - (str): Either "json" or "yaml".
    """
    data_read: Union[str, bytes]
    if isinstance(data, str):
        data_read = data
    elif isinstance(data, bytes):
        data_read = str(data, encoding="utf-8")
    else:
        assert_is_instance("data", data, abc.Readable)
        assert isinstance(data, abc.Readable)
        data_read = read(data)
    formats: Tuple[str, str] = ("json", "yaml")
    format_: Optional[str] = None
    deserialized_data: Any = data_read
    formats_error_messages: List[Tuple[str, str]] = []
    for potential_format in formats:
        try:
            deserialized_data = deserialize(data_read, potential_format)
            format_ = potential_format
            break
        except (ValueError, yaml.YAMLError):
            formats_error_messages.append(
                (potential_format, get_exception_text())
            )
    if format_ is None:
        assert isinstance(data, str)
        raise DeserializeError(
            data=data,
            message="\n\n".join(
                f"{format_}:\n{error_message}"
                for format_, error_message in formats_error_messages
            ),
        )
    return deserialized_data, format_

    This function accepts a string or file-like object and returns a tuple
    containing the deserialized information and a string indicating the format
    of that information.

    Parameters:

    - data (str|abc.Readable): A string or file-like object containing
      JSON or YAML serialized data.

    This function returns a `tuple` of two items:

    - (str|dict|list|int|float|bool): The deserialized (but not un-marshalled)
      data.
    - (str): Either "json" or "yaml".
    
This function accepts a string or file-like object and returns a tuple
containing the deserialized information and a string indicating the format
of that information.



data (str|abc.Readable): A string or file-like object containing
JSON or YAML serialized data.

This function returns a `tuple` of two items.


This function accepts a string or file - like object and returns a tuple containing the deserialized information and a string indicating the format of that information . data ( str|abc . Readable ) : A string or file - like object containing JSON or YAML serialized data . This function returns a ` tuple ` of two items .
def detect_format(
    data: Optional[Union[str, bytes, abc.Readable]]
) -> Tuple[Any, str]:
    data_read: Union[str, bytes]
    if isinstance(data, str):
        data_read = data
    elif isinstance(data, bytes):
        data_read = str(data, encoding="utf-8")
    else:
        assert_is_instance("data", data, abc.Readable)
        assert isinstance(data, abc.Readable)
        data_read = read(data)
    formats: Tuple[str, str] = ("json", "yaml")
    format_: Optional[str] = None
    deserialized_data: Any = data_read
    formats_error_messages: List[Tuple[str, str]] = []
    for potential_format in formats:
        try:
            deserialized_data = deserialize(data_read, potential_format)
            format_ = potential_format
            break
        except (ValueError, yaml.YAMLError):
            formats_error_messages.append(
                (potential_format, get_exception_text())
            )
    if format_ is None:
        assert isinstance(data, str)
        raise DeserializeError(
            data=data,
            message="\n\n".join(
                f"{format_}:\n{error_message}"
                for format_, error_message in formats_error_messages
            ),
        )
    return deserialized_data, format_
def detect_format ( data : Optional [ Union [ str , bytes , abc . Readable ] ] ) -> Tuple [ Any , str ] : data_read : Union [ str , bytes ] if isinstance ( data , str ) : data_read = data elif isinstance ( data , bytes ) : data_read = str ( data , encoding = "utf-8" ) else : assert_is_instance ( "data" , data , abc . Readable ) assert isinstance ( data , abc . Readable ) data_read = read ( data ) formats : Tuple [ str , str ] = ( "json" , "yaml" ) format_ : Optional [ str ] = None deserialized_data : Any = data_read formats_error_messages : List [ Tuple [ str , str ] ] = [ ] for potential_format in formats : try : deserialized_data = deserialize ( data_read , potential_format ) format_ = potential_format break except ( ValueError , yaml . YAMLError ) : formats_error_messages . append ( ( potential_format , get_exception_text ( ) ) ) if format_ is None : assert isinstance ( data , str ) raise DeserializeError ( data = data , message = "\n\n" . join ( f"{format_}:\n{error_message}" for format_ , error_message in formats_error_messages ) , ) return deserialized_data , format_
This function accepts a string or file-like object and returns a tuple
containing the deserialized information and a string indicating the format
of that information.
This function accepts a string or file - like object and returns a tuple containing the deserialized information and a string indicating the format of that information .
"""
    This function accepts a string or file-like object and returns a tuple
    containing the deserialized information and a string indicating the format
    of that information.

    Parameters:

    - data (str|abc.Readable): A string or file-like object containing
      JSON or YAML serialized data.

    This function returns a `tuple` of two items:

    - (str|dict|list|int|float|bool): The deserialized (but not un-marshalled)
      data.
    - (str): Either "json" or "yaml".
    """
data
Optional[Union[str, bytes, abc.Readable]]