Mercurial > public > mercurial-scm > hg-stable
changeset 52710:45dc0f874b8c
typing: lock in the type annotations that were lost with the pyupgrade changes
For some reason, these reverted from a specific type to something less useful
after the changes that culminated in 70a75d379daf. (e.g. the `remotefilectx`
method went from `Generator[remotefilectx, Any, None]` to
`Generator[nothing, Any, None]`.) The previous typing for `merge.filemap` was
`Generator[Tuple[Any, Tuple[Any, Any, Any]], Any, None]`, and decayed to
`Generator[nothing, Any, None]`. I don't feel like unravelling the specific
types here, so restore the equivalent of that.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sun, 12 Jan 2025 21:35:30 -0500 |
parents | 279e217d6041 |
children | 5e09c6b5b795 |
files | hgext/remotefilelog/remotefilectx.py mercurial/merge.py mercurial/store.py |
diffstat | 3 files changed, 11 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/remotefilelog/remotefilectx.py Mon Jan 06 20:02:17 2025 -0500 +++ b/hgext/remotefilelog/remotefilectx.py Sun Jan 12 21:35:30 2025 -0500 @@ -9,6 +9,7 @@ import collections import time +import typing from mercurial.node import bin, hex, nullrev from mercurial import ( @@ -20,6 +21,11 @@ ) from . import shallowutil +if typing.TYPE_CHECKING: + from typing import ( + Iterator, + ) + propertycache = util.propertycache FASTLOG_TIMEOUT_IN_SECS = 0.5 @@ -379,7 +385,7 @@ # the correct linknode. return False - def ancestors(self, followfirst=False): + def ancestors(self, followfirst=False) -> Iterator[remotefilectx]: ancestors = [] queue = collections.deque((self,)) seen = set()
--- a/mercurial/merge.py Mon Jan 06 20:02:17 2025 -0500 +++ b/mercurial/merge.py Sun Jan 12 21:35:30 2025 -0500 @@ -11,7 +11,7 @@ import os import struct import typing -from typing import Dict, Optional, Tuple +from typing import Dict, Iterator, Optional, Tuple from .i18n import _ from .node import nullrev @@ -673,7 +673,7 @@ return sum(len(self._actionmapping[a]) for a in actions) - def filemap(self, sort=False): + def filemap(self, sort=False) -> Iterator[tuple]: # TODO: fill out tuple if sort: yield from sorted(self._filemapping.items()) else:
--- a/mercurial/store.py Mon Jan 06 20:02:17 2025 -0500 +++ b/mercurial/store.py Sun Jan 12 21:35:30 2025 -0500 @@ -16,6 +16,7 @@ from typing import ( Generator, + Iterator, List, Optional, ) @@ -116,7 +117,7 @@ ) -def _reserved(): +def _reserved() -> Iterator[int]: """characters that are problematic for filesystems * ascii escapes (0..31)