changeset 49648:9be765b82a90

typing: minor tweaks to allow updating to pytype 2022.11.18
author Matt Harbison <matt_harbison@yahoo.com>
date Wed, 23 Nov 2022 11:22:22 -0500
parents 2a70d1fc70c4
children df5d3b0d6472
files mercurial/bundle2.py mercurial/bundlecaches.py mercurial/utils/stringutil.py
diffstat 3 files changed, 14 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/bundle2.py	Sun Nov 20 22:54:43 2022 -0500
+++ b/mercurial/bundle2.py	Wed Nov 23 11:22:22 2022 -0500
@@ -1938,7 +1938,12 @@
             raise error.Abort(
                 _(b'old bundle types only supports v1 changegroups')
             )
+
+        # HG20 is the case without 2 values to unpack, but is handled above.
+        # pytype: disable=bad-unpacking
         header, comp = bundletypes[bundletype]
+        # pytype: enable=bad-unpacking
+
         if comp not in util.compengines.supportedbundletypes:
             raise error.Abort(_(b'unknown stream compression type: %s') % comp)
         compengine = util.compengines.forbundletype(comp)
--- a/mercurial/bundlecaches.py	Sun Nov 20 22:54:43 2022 -0500
+++ b/mercurial/bundlecaches.py	Wed Nov 23 11:22:22 2022 -0500
@@ -5,6 +5,10 @@
 
 import collections
 
+from typing import (
+    cast,
+)
+
 from .i18n import _
 
 from .thirdparty import attr
@@ -247,7 +251,7 @@
     # required to apply it. If we see this metadata, compare against what the
     # repo supports and error if the bundle isn't compatible.
     if version == b'packed1' and b'requirements' in params:
-        requirements = set(params[b'requirements'].split(b','))
+        requirements = set(cast(bytes, params[b'requirements']).split(b','))
         missingreqs = requirements - requirementsmod.STREAM_FIXED_REQUIREMENTS
         if missingreqs:
             raise error.UnsupportedBundleSpecification(
--- a/mercurial/utils/stringutil.py	Sun Nov 20 22:54:43 2022 -0500
+++ b/mercurial/utils/stringutil.py	Wed Nov 23 11:22:22 2022 -0500
@@ -723,11 +723,15 @@
         s = bytes(s)
     # call underlying function of s.encode('string_escape') directly for
     # Python 3 compatibility
+    # pytype: disable=bad-return-type
     return codecs.escape_encode(s)[0]  # pytype: disable=module-attr
+    # pytype: enable=bad-return-type
 
 
 def unescapestr(s: bytes) -> bytes:
+    # pytype: disable=bad-return-type
     return codecs.escape_decode(s)[0]  # pytype: disable=module-attr
+    # pytype: enable=bad-return-type
 
 
 def forcebytestr(obj):