pytype: add the couple annotations for pytype to understands the lrunode
After loosing 2d6 SAN, I eventually understood that pytype was confused by method
return type. Pytype is now happy.
--- a/mercurial/util.py Tue Dec 19 21:40:06 2023 +0100
+++ b/mercurial/util.py Thu Dec 21 00:19:19 2023 +0100
@@ -1527,7 +1527,6 @@
raise
return default
- assert node is not None # help pytype
value = node.value
self.totalcost -= node.cost
node.markempty()
@@ -1555,7 +1554,6 @@
"""
try:
node = self._cache[k]
- assert node is not None # help pytype
return node.value
except KeyError:
if default is _notset:
@@ -1614,13 +1612,9 @@
# a non-empty node.
n = self._head.prev
- assert n is not None # help pytype
-
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.
@@ -1630,7 +1624,7 @@
return key, value
- def _movetohead(self, node):
+ def _movetohead(self, node: _lrucachenode):
"""Mark a node as the newest, making it the new head.
When a node is accessed, it becomes the freshest entry in the LRU
@@ -1677,7 +1671,7 @@
self._head = node
- def _addcapacity(self):
+ def _addcapacity(self) -> _lrucachenode:
"""Add a node to the circular linked list.
The new node is inserted before the head node.