D11922: pytype: stop excluding patch.py
mharbison72 (Matt Harbison)
phabricator at mercurial-scm.org
Tue Dec 14 21:12:29 UTC 2021
mharbison72 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
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, ...)
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D11922
AFFECTED FILES
mercurial/patch.py
tests/test-check-pytype.t
CHANGE DETAILS
diff --git a/tests/test-check-pytype.t b/tests/test-check-pytype.t
--- a/tests/test-check-pytype.t
+++ b/tests/test-check-pytype.t
@@ -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 \
diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -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
To: mharbison72, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
More information about the Mercurial-devel
mailing list