Mercurial > hg
diff mercurial/filelog.py @ 51826: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 | e78b75f3cea9 |
children | f4733654f144 |
line wrap: on
line diff
--- a/mercurial/filelog.py Tue Aug 20 00:07:05 2024 -0400 +++ b/mercurial/filelog.py Wed Aug 21 22:15:05 2024 -0400 @@ -8,6 +8,11 @@ import typing +from typing import ( + Iterable, + Iterator, +) + from .i18n import _ from .node import nullrev from . import ( @@ -26,6 +31,10 @@ class FileLog: + _revlog: revlog.revlog + nullid: bytes + _fix_issue6528: bool + def __init__(self, opener, path, try_split=False): self._revlog = revlog.revlog( opener, @@ -43,7 +52,7 @@ opts = opener.options self._fix_issue6528 = opts.get(b'issue6528.fix-incoming', True) - def get_revlog(self): + def get_revlog(self) -> revlog.revlog: """return an actual revlog instance if any This exist because a lot of code leverage the fact the underlying @@ -52,10 +61,10 @@ """ return self._revlog - def __len__(self): + def __len__(self) -> int: return len(self._revlog) - def __iter__(self): + def __iter__(self) -> Iterator[int]: return self._revlog.__iter__() def hasnode(self, node): @@ -234,7 +243,7 @@ """ return not storageutil.filedataequivalent(self, node, text) - def verifyintegrity(self, state): + def verifyintegrity(self, state) -> Iterable[revlog.RevLogProblem]: return self._revlog.verifyintegrity(state) def storageinfo(