# HG changeset patch # User Matt Harbison # Date 2021-12-14 22:25:46 # Node ID 333a2656e98143dd2e258deb7a66f0b978f8c09b # Parent 7caaefa487942a6baf940d4e3fddc1ae1614b404 pytype: stop excluding procutil.py This avoids these false warnings: File "/mnt/c/Users/Matt/hg/mercurial/utils/procutil.py", line 78, in : No attribute 'register' on Type[io.BufferedIOBase] [attribute-error] File "/mnt/c/Users/Matt/hg/mercurial/utils/procutil.py", line 117, in : No attribute 'register' on Type[io.IOBase] [attribute-error] File "/mnt/c/Users/Matt/hg/mercurial/utils/procutil.py", line 770, in runbgcommandpy3: No attribute 'close' on int [attribute-error] In Union[IO[Union[bytes, str]], int] Differential Revision: https://phab.mercurial-scm.org/D11927 diff --git a/mercurial/utils/procutil.py b/mercurial/utils/procutil.py --- a/mercurial/utils/procutil.py +++ b/mercurial/utils/procutil.py @@ -75,7 +75,9 @@ class LineBufferedWrapper(object): return res +# pytype: disable=attribute-error io.BufferedIOBase.register(LineBufferedWrapper) +# pytype: enable=attribute-error def make_line_buffered(stream): @@ -114,7 +116,9 @@ class WriteAllWrapper(object): return total_written +# pytype: disable=attribute-error io.IOBase.register(WriteAllWrapper) +# pytype: enable=attribute-error def _make_write_all(stream): @@ -767,6 +771,7 @@ else: raise finally: if stdin_bytes is not None: + assert not isinstance(stdin, int) stdin.close() if not ensurestart: # Even though we're not waiting on the child process, 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 @@ -32,7 +32,6 @@ mercurial/sslutil.py # [attribu mercurial/testing/storage.py # tons of [attribute-error] mercurial/ui.py # [attribute-error], [wrong-arg-types] mercurial/unionrepo.py # ui, svfs, unfiltered [attribute-error] -mercurial/utils/procutil.py # [attribute-error], [module-attr], [bad-return-type] mercurial/utils/memorytop.py # not 3.6 compatible mercurial/win32.py # [not-callable] mercurial/wireprotoframing.py # [unsupported-operands], [attribute-error], [import-error] @@ -68,7 +67,6 @@ development, but may be a hinderance for > -x mercurial/thirdparty \ > -x mercurial/ui.py \ > -x mercurial/unionrepo.py \ - > -x mercurial/utils/procutil.py \ > -x mercurial/utils/memorytop.py \ > -x mercurial/win32.py \ > -x mercurial/wireprotoframing.py \