# HG changeset patch # User Matt Harbison # Date 2022-11-23 16:22:22 # Node ID 9be765b82a90ab5ed7387a19d063d5addc3050b3 # Parent 2a70d1fc70c4fec6670d844577433bd9aca6abbd typing: minor tweaks to allow updating to pytype 2022.11.18 diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py --- a/mercurial/bundle2.py +++ b/mercurial/bundle2.py @@ -1938,7 +1938,12 @@ def writebundle( 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) diff --git a/mercurial/bundlecaches.py b/mercurial/bundlecaches.py --- a/mercurial/bundlecaches.py +++ b/mercurial/bundlecaches.py @@ -5,6 +5,10 @@ import collections +from typing import ( + cast, +) + from .i18n import _ from .thirdparty import attr @@ -247,7 +251,7 @@ def parsebundlespec(repo, spec, strict=T # 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( diff --git a/mercurial/utils/stringutil.py b/mercurial/utils/stringutil.py --- a/mercurial/utils/stringutil.py +++ b/mercurial/utils/stringutil.py @@ -723,11 +723,15 @@ def escapestr(s: bytes) -> bytes: 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):