# HG changeset patch # User Matt Harbison # Date 2019-12-16 02:28:30 # Node ID b5655f337bd792e01d444724fe8ef7771530cb01 # Parent eff050dbb7037e323958a67f7f14effffd9d2ed8 typing: add a couple of assertions to lrucachedict to help pytype 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]] Differential Revision: https://phab.mercurial-scm.org/D7674 diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -1480,6 +1480,8 @@ class lrucachedict(object): 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 @@ class lrucachedict(object): 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.