changeset 53235:6dc09399a91d

typing: re-parameterize `util.sortdict` usage This backs out b8da7eed1657, now that the class is generic again.
author Matt Harbison <matt_harbison@yahoo.com>
date Tue, 29 Apr 2025 12:17:42 -0400
parents 717053ba35d7
children 5392f4fd6764
files hgext/phabricator.py mercurial/bundle2.py mercurial/hgweb/webutil.py
diffstat 3 files changed, 15 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/phabricator.py	Tue Apr 29 12:13:30 2025 -0400
+++ b/hgext/phabricator.py	Tue Apr 29 12:17:42 2025 -0400
@@ -1691,7 +1691,7 @@
 
 # Map from "hg:meta" keys to header understood by "hg import". The order is
 # consistent with "hg export" output.
-_metanamemap = util.sortdict(
+_metanamemap: util.sortdict[bytes, bytes] = util.sortdict(
     [
         (b'user', b'User'),
         (b'date', b'Date'),
--- a/mercurial/bundle2.py	Tue Apr 29 12:13:30 2025 -0400
+++ b/mercurial/bundle2.py	Tue Apr 29 12:17:42 2025 -0400
@@ -869,7 +869,9 @@
             params = self._processallparams(params)
         return params
 
-    def _processallparams(self, paramsblock):
+    def _processallparams(
+        self, paramsblock: bytes
+    ) -> util.sortdict[bytes, bytes]:
         """ """
         params = util.sortdict()
         for p in paramsblock.split(b' '):
--- a/mercurial/hgweb/webutil.py	Tue Apr 29 12:13:30 2025 -0400
+++ b/mercurial/hgweb/webutil.py	Tue Apr 29 12:17:42 2025 -0400
@@ -12,6 +12,7 @@
 import difflib
 import os
 import re
+import typing
 
 from ..i18n import _
 from ..node import hex, short
@@ -43,7 +44,16 @@
 
 from ..utils import stringutil
 
-archivespecs = util.sortdict(
+if typing.TYPE_CHECKING:
+    from typing import (
+        Optional,
+    )
+
+    ArchiveSpecT = tuple[bytes, bytes, bytes, Optional[bytes]]
+    """Tuple of (mime-type, archive-type, file extension, encoding)"""
+
+
+archivespecs: util.sortdict[bytes, ArchiveSpecT] = util.sortdict(
     (
         (b'zip', (b'application/zip', b'zip', b'.zip', None)),
         (b'gz', (b'application/x-gzip', b'tgz', b'.tar.gz', None)),