diff mercurial/revlog.py @ 51868:0338fb200a30

typing: lock in new pytype gains from making revlog related classes typeable These were pretty clean changes in the pyi files from earlier in this series, so add them to the code to make it more understandable. There's one more trivial hint that can be added to the return of `mercurial.revlogutils.rewrite._filelog_from_filename()`, however it needs to be imported from '..' under the conditional of `typing.TYPE_CHECKING`, and that seems to confuse the import checker- possibly because there's already an import block from that level. (I would have expected a message about multiple import statements in this case, but got one about higher level imports should come first, no matter where I put the import statement.)
author Matt Harbison <matt_harbison@yahoo.com>
date Wed, 21 Aug 2024 22:15:05 -0400
parents 766c55492258
children eb9dea148233
line wrap: on
line diff
--- a/mercurial/revlog.py	Tue Aug 20 00:07:05 2024 -0400
+++ b/mercurial/revlog.py	Wed Aug 21 22:15:05 2024 -0400
@@ -25,6 +25,8 @@
 import zlib
 
 from typing import (
+    Iterable,
+    Iterator,
     Optional,
     Tuple,
 )
@@ -1826,7 +1828,7 @@
     def __len__(self):
         return len(self.index)
 
-    def __iter__(self):
+    def __iter__(self) -> Iterator[int]:
         return iter(range(len(self)))
 
     def revs(self, start=0, stop=None):
@@ -3902,7 +3904,7 @@
         else:
             rewrite.v2_censor(self, tr, censor_nodes, tombstone)
 
-    def verifyintegrity(self, state):
+    def verifyintegrity(self, state) -> Iterable[RevLogProblem]:
         """Verifies the integrity of the revlog.
 
         Yields ``revlogproblem`` instances describing problems that are