def test_util_alias_access() -> None:
    """Accessing util in git works, warns, and mypy verifies it and its attributes."""
    # The attribute access should succeed.
    with pytest.deprecated_call() as ctx:
        util = git.util

    # There should be exactly one warning and it should have our util-specific message.
    (message,) = [str(entry.message) for entry in ctx]
    assert "git.util" in message
    assert "git.index.util" in message
    assert "should not be relied on" in message

    # We check access through the util alias to the TemporaryFileSwap member, since it
    # is slightly simpler to validate and reason about than the other public members,
    # which are functions (specifically, higher-order functions for use as decorators).
    from git.index.util import TemporaryFileSwap

    assert_type(util.TemporaryFileSwap, Type[TemporaryFileSwap])

    # This comes after the static assertion, just in case it would affect the inference.
    assert util.TemporaryFileSwap is TemporaryFileSwap
Accessing util in git works, warns, and mypy verifies it and its attributes.
test/deprecation/test_toplevel.py