Patchwork D11718: typing: add a few assertions to revlog.py to help pytype

login
register
mail settings
Submitter phabricator
Date Oct. 23, 2021, 8:06 p.m.
Message ID <differential-rev-PHID-DREV-rrmsv2zqatfvagmwtkic-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50043/
State Superseded
Headers show

Comments

phabricator - Oct. 23, 2021, 8:06 p.m.
mharbison72 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  I've seen this before, but this was seen as potentially `None` with pytype
  2021.10.18.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/revlog.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -2581,10 +2581,15 @@ 
             self._enforceinlinesize(transaction)
         if self._docket is not None:
             # revlog-v2 always has 3 writing handles, help Pytype
-            assert self._writinghandles[2] is not None
-            self._docket.index_end = self._writinghandles[0].tell()
-            self._docket.data_end = self._writinghandles[1].tell()
-            self._docket.sidedata_end = self._writinghandles[2].tell()
+            wh1 = self._writinghandles[0]
+            wh2 = self._writinghandles[1]
+            wh3 = self._writinghandles[2]
+            assert wh1 is not None
+            assert wh2 is not None
+            assert wh3 is not None
+            self._docket.index_end = wh1.tell()
+            self._docket.data_end = wh2.tell()
+            self._docket.sidedata_end = wh3.tell()
 
         nodemaputil.setup_persistent_nodemap(transaction, self)