D10276: typing: make minor adjustments to mercurial/util.py to pass pytype checking
mharbison72 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
I'm assuming the wrong-arg-count is a pytype bug, because this code is used by
the config object. Avoiding initializing `_lrucachenode` node points to None
eliminates a few `is not None` assertions, but apparently not all of them. I
can't figure out why it gets confused over the state where these new assertions
- self._head = head = _lrucachenode()
- head.prev = head
- head.next = head
+ self._head = _lrucachenode()
self._size = 1
self.capacity = max
self.totalcost = 0
@@ -1555,6 +1554,7 @@
node = self._cache[k]
+ assert node is not None # help pytype
if default is _notset:
@@ -1612,6 +1612,9 @@
# Walk the linked list backwards starting at tail node until we hit
# a non-empty node.
n = self._head.prev
+ assert n is not None # help pytype
while n.key is _notset:
n = n.prev