Patchwork D7674: typing: add a couple of assertions to lrucachedict to help pytype

login
register
mail settings
Submitter phabricator
Date Dec. 16, 2019, 4:13 a.m.
Message ID <differential-rev-PHID-DREV-zvf3pwfd5n44nowmqjxd-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/43848/
State Superseded
Headers show

Comments

phabricator - Dec. 16, 2019, 4:13 a.m.
mharbison72 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Fixes the following warnings:
  
    line 1488, in pop: No attribute 'markempty' on None [attribute-error]
         In Optional[Union[Any, _lrucachenode, nothing]]
    line 1578, in popoldest: No attribute 'markempty' on None [attribute-error]
         In Optional[Union[Any, _lrucachenode, nothing]]

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/util.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -1480,6 +1480,8 @@ 
             if default is _notset:
                 raise
             return default
+
+        assert node is not None  # help pytype
         value = node.value
         self.totalcost -= node.cost
         node.markempty()
@@ -1567,6 +1569,8 @@ 
         while n.key is _notset:
             n = n.prev
 
+        assert n is not None  # help pytype
+
         key, value = n.key, n.value
 
         # And remove it from the cache and mark it as empty.