Mercurial > hg
comparison mercurial/utils/procutil.py @ 48487:333a2656e981
pytype: stop excluding procutil.py
This avoids these false warnings:
File "/mnt/c/Users/Matt/hg/mercurial/utils/procutil.py", line 78, in <module>:
No attribute 'register' on Type[io.BufferedIOBase] [attribute-error]
File "/mnt/c/Users/Matt/hg/mercurial/utils/procutil.py", line 117, in <module>:
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
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Tue, 14 Dec 2021 17:25:46 -0500 |
parents | 8759e22f1649 |
children | f8540fe4be0f |
comparison
equal
deleted
inserted
replaced
48486:7caaefa48794 | 48487:333a2656e981 |
---|---|
73 if s.endswith(b'\n'): | 73 if s.endswith(b'\n'): |
74 orig.flush() | 74 orig.flush() |
75 return res | 75 return res |
76 | 76 |
77 | 77 |
78 # pytype: disable=attribute-error | |
78 io.BufferedIOBase.register(LineBufferedWrapper) | 79 io.BufferedIOBase.register(LineBufferedWrapper) |
80 # pytype: enable=attribute-error | |
79 | 81 |
80 | 82 |
81 def make_line_buffered(stream): | 83 def make_line_buffered(stream): |
82 if pycompat.ispy3 and not isinstance(stream, io.BufferedIOBase): | 84 if pycompat.ispy3 and not isinstance(stream, io.BufferedIOBase): |
83 # On Python 3, buffered streams can be expected to subclass | 85 # On Python 3, buffered streams can be expected to subclass |
112 while total_written < total_to_write: | 114 while total_written < total_to_write: |
113 total_written += write1(m[total_written:]) | 115 total_written += write1(m[total_written:]) |
114 return total_written | 116 return total_written |
115 | 117 |
116 | 118 |
119 # pytype: disable=attribute-error | |
117 io.IOBase.register(WriteAllWrapper) | 120 io.IOBase.register(WriteAllWrapper) |
121 # pytype: enable=attribute-error | |
118 | 122 |
119 | 123 |
120 def _make_write_all(stream): | 124 def _make_write_all(stream): |
121 assert pycompat.ispy3 | 125 assert pycompat.ispy3 |
122 if isinstance(stream, WriteAllWrapper): | 126 if isinstance(stream, WriteAllWrapper): |
765 if record_wait is not None: | 769 if record_wait is not None: |
766 record_wait(255) | 770 record_wait(255) |
767 raise | 771 raise |
768 finally: | 772 finally: |
769 if stdin_bytes is not None: | 773 if stdin_bytes is not None: |
774 assert not isinstance(stdin, int) | |
770 stdin.close() | 775 stdin.close() |
771 if not ensurestart: | 776 if not ensurestart: |
772 # Even though we're not waiting on the child process, | 777 # Even though we're not waiting on the child process, |
773 # we still must call waitpid() on it at some point so | 778 # we still must call waitpid() on it at some point so |
774 # it's not a zombie/defunct. This is especially relevant for | 779 # it's not a zombie/defunct. This is especially relevant for |