Patchwork D11235: typing: add several assertions to dirstatemap to appease pytype

login
register
mail settings
Submitter phabricator
Date July 30, 2021, 5:13 a.m.
Message ID <differential-rev-PHID-DREV-2dtubo7oqvhgcsumr72b-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49549/
State Superseded
Headers show

Comments

phabricator - July 30, 2021, 5:13 a.m.
mharbison72 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  I think it's been mentioned in IRC that these can't be None in this case.  This
  fixes:
  
    File "/mnt/c/Users/Matt/hg/mercurial/dirstatemap.py", line 213, in addfile: unsupported operand type(s) for &: 'None' and 'int' [unsupported-operands]
      No attribute '__and__' on None or '__rand__' on int
    Called from (traceback):
      line 290, in reset_state
    File "/mnt/c/Users/Matt/hg/mercurial/dirstatemap.py", line 214, in addfile: unsupported operand type(s) for &: 'None' and 'int' [unsupported-operands]
      No attribute '__and__' on None or '__rand__' on int
    Called from (traceback):
      line 290, in reset_state

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  mercurial/dirstatemap.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/dirstatemap.py b/mercurial/dirstatemap.py
--- a/mercurial/dirstatemap.py
+++ b/mercurial/dirstatemap.py
@@ -209,6 +209,9 @@ 
         else:
             assert size != FROM_P2
             assert size != NONNORMAL
+            assert size is not None
+            assert mtime is not None
+
             state = b'n'
             size = size & rangemask
             mtime = mtime & rangemask