changeset 52902:3e8a3db5f5e8

typing: introduce a few basic alias for common types These types are passed everywhere. We introduce basic alias to Any, to make it simpler to start annotating code prior to introducing proper protocol for them.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 07 Feb 2025 23:00:31 +0100
parents 6ee3c401882b
children 53ae4495e5f0
files mercurial/interfaces/_basetypes.py mercurial/interfaces/repository.py mercurial/interfaces/types.py
diffstat 3 files changed, 19 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/interfaces/_basetypes.py	Tue Feb 11 22:44:21 2025 -0500
+++ b/mercurial/interfaces/_basetypes.py	Fri Feb 07 23:00:31 2025 +0100
@@ -13,6 +13,8 @@
 
 from __future__ import annotations
 
+from typing import Any
+
 UserMsgT = bytes
 """Text (maybe) displayed to the user."""
 
@@ -22,6 +24,15 @@
 FsPathT = bytes
 """A path on disk (after vfs encoding)."""
 
+# TODO: create a Protocol class,
+RepoT = Any
+
+# TODO: create a Protocol class,
+UiT = Any
+
+# TODO: make a protocol class for this
+VfsT = Any
+
 VfsKeyT = bytes
 """Vfs identifier, typically used in a VfsMap."""
 
--- a/mercurial/interfaces/repository.py	Tue Feb 11 22:44:21 2025 -0500
+++ b/mercurial/interfaces/repository.py	Fri Feb 07 23:00:31 2025 +0100
@@ -30,6 +30,11 @@
         ByteString,  # TODO: change to Buffer for 3.14
     )
 
+    from ._basetypes import (
+        UiT as Ui,
+        VfsT as Vfs,
+    )
+
     from . import (
         dirstate as intdirstate,
         matcher,
@@ -39,12 +44,6 @@
     # TODO: make a protocol class for this
     NodeConstants = Any
 
-    # TODO: create a Protocol class, since importing uimod here causes a cycle
-    #  that confuses pytype.
-    Ui = Any
-
-    # TODO: make a protocol class for this
-    Vfs = Any
 
 # Local repository feature string.
 
--- a/mercurial/interfaces/types.py	Tue Feb 11 22:44:21 2025 -0500
+++ b/mercurial/interfaces/types.py	Fri Feb 07 23:00:31 2025 +0100
@@ -15,8 +15,11 @@
     CallbackCategoryT,
     FsPathT,
     HgPathT,
+    RepoT,
+    UiT,
     UserMsgT,
     VfsKeyT,
+    VfsT,
 )
 
 from . import (