# HG changeset patch # User Pierre-Yves David # Date 1703114359 -3600 # Node ID c8a2fdf5ca3735efe0db3ade54f722f2fc34058d # Parent 4d12ffde8377c892ec0e2baf55ed900352385252 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. diff -r 4d12ffde8377 -r c8a2fdf5ca37 mercurial/util.py --- 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.