Mercurial > public > mercurial-scm > hg-stable
diff mercurial/interfaces/types.py @ 52755:5c48fd4c0e68
typing: introduce a `types` module and a MatcherT alias
This is a proposal to formalise the way we do typing and do more of it.
The initial motivation to make progress is to help break the 100+ module
cycle that is slowing pytype a lot.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 30 Jan 2025 18:22:01 +0100 |
parents | |
children | fecda9f44e57 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial/interfaces/types.py Thu Jan 30 18:22:01 2025 +0100 @@ -0,0 +1,23 @@ +# 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 implement foobar: use IFoorbar from `mercurial.interface.foo_bar` + +from __future__ import annotations + +from . import ( + _basetypes, + matcher, +) + +MatcherT = matcher.IMatcher + +UserMsgT = _basetypes.UserMsgT +HgPathT = _basetypes.HgPathT +FsPathT = _basetypes.FsPathT