Mercurial > hg-stable
changeset 43530:fc19f8ab8199
vfs: suppress some pytype errors around us using a private attribute
Looking at threading._MainThread seems like we're probably a little
unsupported, but since this code appears to work on both Python 2 and
3 I'm not going to sweat this for now.
Differential Revision: https://phab.mercurial-scm.org/D7282
author | Augie Fackler <augie@google.com> |
---|---|
date | Wed, 06 Nov 2019 15:29:08 -0500 |
parents | f5fcf7123a92 |
children | f2f460cdb4f5 |
files | mercurial/vfs.py |
diffstat | 1 files changed, 12 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/vfs.py Wed Nov 06 15:24:44 2019 -0500 +++ b/mercurial/vfs.py Wed Nov 06 15:29:08 2019 -0500 @@ -307,7 +307,10 @@ # Sharing backgroundfilecloser between threads is complex and using # multiple instances puts us at risk of running out of file descriptors # only allow to use backgroundfilecloser when in main thread. - if not isinstance(threading.currentThread(), threading._MainThread): + if not isinstance( + threading.currentThread(), + threading._MainThread, # pytype: disable=module-attr + ): yield return vfs = getattr(self, 'vfs', self) @@ -318,10 +321,14 @@ with backgroundfilecloser(ui, expectedcount=expectedcount) as bfc: try: - vfs._backgroundfilecloser = bfc + vfs._backgroundfilecloser = ( + bfc # pytype: disable=attribute-error + ) yield bfc finally: - vfs._backgroundfilecloser = None + vfs._backgroundfilecloser = ( + None # pytype: disable=attribute-error + ) class vfs(abstractvfs): @@ -477,7 +484,8 @@ fp = checkambigatclosing(fp) if backgroundclose and isinstance( - threading.currentThread(), threading._MainThread + threading.currentThread(), + threading._MainThread, # pytype: disable=module-attr ): if not self._backgroundfilecloser: raise error.Abort(