Patchwork D11206: typing: convert an annotation to an assertion in commands.py

login
register
mail settings
Submitter phabricator
Date July 21, 2021, 8:07 p.m.
Message ID <differential-rev-PHID-DREV-22nvcefnzqruinjtt74i-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49521/
State Superseded
Headers show

Comments

phabricator - July 21, 2021, 8:07 p.m.
mharbison72 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Pytype was happy with the annotation at one point, but 2021.04.15 now complains.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/commands.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3341,7 +3341,8 @@ 
                 )
             # checking that newnodes exist because old state files won't have it
             elif statedata.get(b'newnodes') is not None:
-                nn = statedata[b'newnodes']  # type: List[bytes]
+                nn = statedata[b'newnodes']
+                assert isinstance(nn, list)  # list of bytes
                 nn.append(node)
 
     # remove state when we complete successfully