from typing import Any


def isstring(var:Any, raise_error:bool=False) -> bool:
    """Check if var is a string

    Args:
        var (str): variable to check
        raise_error (bool, optional): TypeError raised if set to `True`. Defaults to `False`.

    Raises:
        TypeError: raised if var is not string

    Returns:
        bool: `True` if var is a string
    """    
    is_ =isinstance(var, str)
    if not is_ and raise_error:
        raise TypeError(f'String expected: {var=} is not a str')
    return is_