from typing import Callable
import inspect


def get_function_context(f: Callable) -> str:
    """
    Returns the function's context, containing:
    * its name
    * the location of its code
    * the first line of its code (if exists)

    :param f: the function
    :return: the context
    :raises: TypeError: if the function is a builtin function or method

    :Example:

    >>> def f(a: int, b: int) -> int:
    >>>     return a + b
    >>> get_function_context(f)
    "<stdin>:1:f"
    """
    name = f.__qualname__

    file = inspect.getsourcefile(f)
    try:
        lineno = inspect.getsourcelines(f)[1]
    except OSError:
        lineno = "<SourceCodeCannotBeRetrieved>"

    return "%s:%d:%s" % (file, lineno, name)