diff mercurial/util.py @ 52886:abcfb4ce132e

py-compat: backed out changeset 7ca9c05ec335 This currently fails on 3.8 with the following error:: fatal: fetching library from `hg` failed with 1: Traceback (most recent call last): File "/tmp/hgtests.hus0o5qa/install/bin/hg", line 61, in <module> dispatch.run() File "/opt/vendor/pyenv/pyenv-2.4.13/versions/3.8.19/lib/python3.8/importlib/util.py", line 245, in __getattribute__ self.__spec__.loader.exec_module(self) File "<frozen importlib._bootstrap_external>", line 843, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/tmp/hgtests.hus0o5qa/install/lib/python3.8/site-packages/mercurial/dispatch.py", line 758, in <module> class lazyaliasentry: File "/tmp/hgtests.hus0o5qa/install/lib/python3.8/site-packages/mercurial/dispatch.py", line 769, in lazyaliasentry @util.propertycache File "/opt/vendor/pyenv/pyenv-2.4.13/versions/3.8.19/lib/python3.8/importlib/util.py", line 245, in __getattribute__ self.__spec__.loader.exec_module(self) File "<frozen importlib._bootstrap_external>", line 843, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/tmp/hgtests.hus0o5qa/install/lib/python3.8/site-packages/mercurial/util.py", line 1360, in <module> class sortdict(collections.OrderedDict[_KT, _VT]): TypeError: 'type' object is not subscriptable
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sat, 15 Feb 2025 14:11:43 +0100
parents f4dd447e6efd
children acaf6bad6b89
line wrap: on
line diff
--- a/mercurial/util.py	Sat Feb 15 14:12:20 2025 +0100
+++ b/mercurial/util.py	Sat Feb 15 14:11:43 2025 +0100
@@ -95,12 +95,6 @@
 
     _Tcow = TypeVar('_Tcow', bound="cow")
 
-_KT = TypeVar("_KT")
-"""An unconstrained key type for container classes (see typing.KT)."""
-
-_VT = TypeVar("_VT")
-"""An unconstrained value type for container classes (see typing.VT)."""
-
 base85: intmod.Base85 = policy.importmod('base85')
 osutil = policy.importmod('osutil')
 
@@ -1357,7 +1351,7 @@
         return self
 
 
-class sortdict(collections.OrderedDict[_KT, _VT]):
+class sortdict(collections.OrderedDict):
     """a simple sorted dictionary
 
     >>> d1 = sortdict([(b'a', 0), (b'b', 1)])
@@ -1372,7 +1366,7 @@
     [('a', 0), ('a.5', 0.5), ('b', 1)]
     """
 
-    def __setitem__(self, key: _KT, value: _VT) -> None:
+    def __setitem__(self, key, value):
         if key in self:
             del self[key]
         super().__setitem__(key, value)
@@ -1387,7 +1381,7 @@
             for k in f:
                 self[k] = f[k]
 
-    def insert(self, position: int, key: _KT, value: _VT):
+    def insert(self, position, key, value):
         for i, (k, v) in enumerate(list(self.items())):
             if i == position:
                 self[key] = value