Patchwork D12337: worker: silence type error when calling pickle

login
register
mail settings
Submitter phabricator
Date March 4, 2022, 1:39 a.m.
Message ID <differential-rev-PHID-DREV-fxeqck5vqitwwi4t2xzk-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50678/
State New
Headers show

Comments

phabricator - March 4, 2022, 1:39 a.m.
indygreg created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  pytype is complaining that the argument to `pickle.load()` is not an
  `IO`. pytype isn't wrong: `_blockingreader` doesn't implement
  `io.RawIOBase`, only `read()` and `readline()`. But it appears this is
  enough for pickle. So we silence the false positive.
  
  This fixes a regression introduced by D12304 <https://phab.mercurial-scm.org/D12304> /
  cc0e059d2af8 <https://phab.mercurial-scm.org/rHGcc0e059d2af84427abe1d58bc79eb4d71ec6f26d>: worker: remove Python 2 support code.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12337

AFFECTED FILES
  mercurial/worker.py

CHANGE DETAILS




To: indygreg, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/worker.py b/mercurial/worker.py
--- a/mercurial/worker.py
+++ b/mercurial/worker.py
@@ -279,7 +279,11 @@ 
         while openpipes > 0:
             for key, events in selector.select():
                 try:
+                    # The pytype error likely goes away on a modern version of
+                    # pytype having a modern typeshed snapshot.
+                    # pytype: disable=wrong-arg-types
                     res = pickle.load(_blockingreader(key.fileobj))
+                    # pytype: enable=wrong-arg-types
                     if hasretval and res[0]:
                         retval.update(res[1])
                     else: