##// END OF EJS Templates
typing: make minor adjustments to mercurial/util.py to pass pytype checking...
Matt Harbison -
r47663:51841b23 default
parent child Browse files
Show More
@@ -1265,7 +1265,8 b' class cow(object):'
1265 """call this before writes, return self or a copied new object"""
1265 """call this before writes, return self or a copied new object"""
1266 if getattr(self, '_copied', 0):
1266 if getattr(self, '_copied', 0):
1267 self._copied -= 1
1267 self._copied -= 1
1268 return self.__class__(self)
1268 # Function cow.__init__ expects 1 arg(s), got 2 [wrong-arg-count]
1269 return self.__class__(self) # pytype: disable=wrong-arg-count
1269 return self
1270 return self
1270
1271
1271 def copy(self):
1272 def copy(self):
@@ -1408,8 +1409,8 b' class _lrucachenode(object):'
1408 __slots__ = ('next', 'prev', 'key', 'value', 'cost')
1409 __slots__ = ('next', 'prev', 'key', 'value', 'cost')
1409
1410
1410 def __init__(self):
1411 def __init__(self):
1411 self.next = None
1412 self.next = self
1412 self.prev = None
1413 self.prev = self
1413
1414
1414 self.key = _notset
1415 self.key = _notset
1415 self.value = None
1416 self.value = None
@@ -1448,9 +1449,7 b' class lrucachedict(object):'
1448 def __init__(self, max, maxcost=0):
1449 def __init__(self, max, maxcost=0):
1449 self._cache = {}
1450 self._cache = {}
1450
1451
1451 self._head = head = _lrucachenode()
1452 self._head = _lrucachenode()
1452 head.prev = head
1453 head.next = head
1454 self._size = 1
1453 self._size = 1
1455 self.capacity = max
1454 self.capacity = max
1456 self.totalcost = 0
1455 self.totalcost = 0
@@ -1555,6 +1554,7 b' class lrucachedict(object):'
1555 """
1554 """
1556 try:
1555 try:
1557 node = self._cache[k]
1556 node = self._cache[k]
1557 assert node is not None # help pytype
1558 return node.value
1558 return node.value
1559 except KeyError:
1559 except KeyError:
1560 if default is _notset:
1560 if default is _notset:
@@ -1612,6 +1612,9 b' class lrucachedict(object):'
1612 # Walk the linked list backwards starting at tail node until we hit
1612 # Walk the linked list backwards starting at tail node until we hit
1613 # a non-empty node.
1613 # a non-empty node.
1614 n = self._head.prev
1614 n = self._head.prev
1615
1616 assert n is not None # help pytype
1617
1615 while n.key is _notset:
1618 while n.key is _notset:
1616 n = n.prev
1619 n = n.prev
1617
1620
@@ -89,7 +89,6 b' development, but may be a hinderance for'
89 > -x mercurial/ui.py \
89 > -x mercurial/ui.py \
90 > -x mercurial/unionrepo.py \
90 > -x mercurial/unionrepo.py \
91 > -x mercurial/upgrade.py \
91 > -x mercurial/upgrade.py \
92 > -x mercurial/util.py \
93 > -x mercurial/utils/procutil.py \
92 > -x mercurial/utils/procutil.py \
94 > -x mercurial/utils/stringutil.py \
93 > -x mercurial/utils/stringutil.py \
95 > -x mercurial/utils/memorytop.py \
94 > -x mercurial/utils/memorytop.py \
General Comments 0
You need to be logged in to leave comments. Login now