def pushd(directory: str) -> None:
    """
    Context manager: changes directory and preserves the original on exit.

    Example:

    .. code-block:: python

        with pushd(new_directory):
            # do things
    """
    previous_dir = os.getcwd()
    os.chdir(directory)
    yield
    os.chdir(previous_dir)
Context manager: changes directory and preserves the original on exit.

    Example:

    .. code-block:: python

        with pushd(new_directory):
            # do things