diff mercurial/utils/urlutil.py @ 52908:180591a9a6a1

typing: add a protocol for `urlutil.path` That is the last external import for the repository interface module.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 10 Feb 2025 00:16:22 +0100
parents ba343f763595
children
line wrap: on
line diff
--- a/mercurial/utils/urlutil.py	Mon Feb 10 00:15:22 2025 +0100
+++ b/mercurial/utils/urlutil.py	Mon Feb 10 00:16:22 2025 +0100
@@ -14,6 +14,7 @@
 from typing import (
     Callable,
     Dict,
+    Optional,
     Tuple,
     Union,
 )
@@ -825,7 +826,7 @@
     return new_paths
 
 
-class path:
+class path(int_misc.IPath):
     """Represents an individual path and its configuration."""
 
     def __init__(
@@ -892,7 +893,7 @@
         self.rawloc = rawloc
         self.loc = b'%s' % u
 
-    def copy(self, new_raw_location=None):
+    def copy(self, new_raw_location: Optional[bytes] = None) -> path:
         """make a copy of this path object
 
         When `new_raw_location` is set, the new path will point to it.
@@ -909,11 +910,11 @@
         return new
 
     @property
-    def is_push_variant(self):
+    def is_push_variant(self) -> bool:
         """is this a path variant to be used for pushing"""
         return self.main_path is not None
 
-    def get_push_variant(self):
+    def get_push_variant(self) -> path:
         """get a "copy" of the path, but suitable for pushing
 
         This means using the value of the `pushurl` option (if any) as the url.
@@ -965,7 +966,7 @@
             return False
 
     @property
-    def suboptions(self):
+    def suboptions(self) -> Dict[bytes, bytes]:
         """Return sub-options and their values for this path.
 
         This is intended to be used for presentation purposes.