import keyword
import builtins


def isvalid(ident: str) -> bool:
    """Determines if string is valid Python identifier."""
    flag = True

    if not isinstance(ident, str):
        raise TypeError("expected str, but got {!r}".format(type(ident)))

    if not ident.isidentifier():
        flag = False

    if keyword.iskeyword(ident):
        flag = False

    if ident in dir(builtins):
        flag = False

    return flag