# HG changeset patch # User Matt Harbison # Date 1639444749 18000 # Node ID 290f9c150f701ff6bde11623896f4de60256b913 # Parent d2fff292c265b8f09e70fb50b0719e8bbf37df6a pytype: stop excluding patch.py The underlying `email.generator.BytesGenerator` is documented as requiring an `fp` that accepts bytes, so I'm not sure why pytype is getting confused: File "/mnt/c/Users/Matt/hg/mercurial/patch.py", line 112, in msgfp: Function Generator.__init__ was called with the wrong arguments [wrong-arg-types] Expected: (self, outfp: TextIO, ...) Actually passed: (self, outfp: io.BytesIO, ...) Differential Revision: https://phab.mercurial-scm.org/D11922 diff -r d2fff292c265 -r 290f9c150f70 mercurial/patch.py --- a/mercurial/patch.py Mon Dec 13 19:34:06 2021 -0500 +++ b/mercurial/patch.py Mon Dec 13 20:19:09 2021 -0500 @@ -109,7 +109,9 @@ def mimesplit(stream, cur): def msgfp(m): fp = stringio() + # pytype: disable=wrong-arg-types g = mail.Generator(fp, mangle_from_=False) + # pytype: enable=wrong-arg-types g.flatten(m) fp.seek(0) return fp diff -r d2fff292c265 -r 290f9c150f70 tests/test-check-pytype.t --- a/tests/test-check-pytype.t Mon Dec 13 19:34:06 2021 -0500 +++ b/tests/test-check-pytype.t Mon Dec 13 20:19:09 2021 -0500 @@ -26,7 +26,6 @@ mercurial/localrepo.py # [attribute-error] mercurial/manifest.py # [unsupported-operands], [wrong-arg-types] mercurial/minirst.py # [unsupported-operands], [attribute-error] -mercurial/patch.py # [wrong-arg-types] mercurial/pure/osutil.py # [invalid-typevar], [not-callable] mercurial/pure/parsers.py # [attribute-error] mercurial/pycompat.py # bytes vs str issues @@ -65,7 +64,6 @@ > -x mercurial/localrepo.py \ > -x mercurial/manifest.py \ > -x mercurial/minirst.py \ - > -x mercurial/patch.py \ > -x mercurial/pure/osutil.py \ > -x mercurial/pure/parsers.py \ > -x mercurial/pycompat.py \