view mercurial/interfaces/types.py @ 52768:a7dcb7c1ff5a

typing: add a transaction protocol This allow us to remove the "external" import from mercurial/interfaces/dirstate.py, cutting one of the circular import route.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 07 Feb 2025 13:48:50 +0100
parents ae2848198462
children 3e8a3db5f5e8
line wrap: on
line source

# mercurial/interfaces/types.py - type alias for interfaces
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
#
# This is the main entry point for Mercurial code writing type annotations.
#
# The general principle can be summarized when dealing with <FooBar> object:
# - to type your code: use FooBarT from `mercurial.interface.types`
# - to subclass <FooBar>: use IFooBar from `mercurial.interface.foo_bar`

from __future__ import annotations

from ._basetypes import (  # noqa: F401 (ignore imported but not used)
    CallbackCategoryT,
    FsPathT,
    HgPathT,
    UserMsgT,
    VfsKeyT,
)

from . import (
    matcher,
    transaction,
)

MatcherT = matcher.IMatcher
TransactionT = transaction.ITransaction