##// END OF EJS Templates
pytype: add the couple annotations for pytype to understands the lrunode...
marmoute -
r52191:c8a2fdf5 default
parent child Browse files
Show More
@@ -1527,7 +1527,6 b' class lrucachedict:'
1527 raise
1527 raise
1528 return default
1528 return default
1529
1529
1530 assert node is not None # help pytype
1531 value = node.value
1530 value = node.value
1532 self.totalcost -= node.cost
1531 self.totalcost -= node.cost
1533 node.markempty()
1532 node.markempty()
@@ -1555,7 +1554,6 b' class lrucachedict:'
1555 """
1554 """
1556 try:
1555 try:
1557 node = self._cache[k]
1556 node = self._cache[k]
1558 assert node is not None # help pytype
1559 return node.value
1557 return node.value
1560 except KeyError:
1558 except KeyError:
1561 if default is _notset:
1559 if default is _notset:
@@ -1614,13 +1612,9 b' class lrucachedict:'
1614 # a non-empty node.
1612 # a non-empty node.
1615 n = self._head.prev
1613 n = self._head.prev
1616
1614
1617 assert n is not None # help pytype
1618
1619 while n.key is _notset:
1615 while n.key is _notset:
1620 n = n.prev
1616 n = n.prev
1621
1617
1622 assert n is not None # help pytype
1623
1624 key, value = n.key, n.value
1618 key, value = n.key, n.value
1625
1619
1626 # And remove it from the cache and mark it as empty.
1620 # And remove it from the cache and mark it as empty.
@@ -1630,7 +1624,7 b' class lrucachedict:'
1630
1624
1631 return key, value
1625 return key, value
1632
1626
1633 def _movetohead(self, node):
1627 def _movetohead(self, node: _lrucachenode):
1634 """Mark a node as the newest, making it the new head.
1628 """Mark a node as the newest, making it the new head.
1635
1629
1636 When a node is accessed, it becomes the freshest entry in the LRU
1630 When a node is accessed, it becomes the freshest entry in the LRU
@@ -1677,7 +1671,7 b' class lrucachedict:'
1677
1671
1678 self._head = node
1672 self._head = node
1679
1673
1680 def _addcapacity(self):
1674 def _addcapacity(self) -> _lrucachenode:
1681 """Add a node to the circular linked list.
1675 """Add a node to the circular linked list.
1682
1676
1683 The new node is inserted before the head node.
1677 The new node is inserted before the head node.
General Comments 0
You need to be logged in to leave comments. Login now