Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/merge.py @ 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 | e627cc25b6f3 |
children | f3762eafed66 |
comparison
equal
deleted
inserted
replaced
52709:279e217d6041 | 52710:45dc0f874b8c |
---|---|
9 | 9 |
10 import collections | 10 import collections |
11 import os | 11 import os |
12 import struct | 12 import struct |
13 import typing | 13 import typing |
14 from typing import Dict, Optional, Tuple | 14 from typing import Dict, Iterator, Optional, Tuple |
15 | 15 |
16 from .i18n import _ | 16 from .i18n import _ |
17 from .node import nullrev | 17 from .node import nullrev |
18 from .thirdparty import attr | 18 from .thirdparty import attr |
19 | 19 |
671 if actions is None: | 671 if actions is None: |
672 return len(self._filemapping) | 672 return len(self._filemapping) |
673 | 673 |
674 return sum(len(self._actionmapping[a]) for a in actions) | 674 return sum(len(self._actionmapping[a]) for a in actions) |
675 | 675 |
676 def filemap(self, sort=False): | 676 def filemap(self, sort=False) -> Iterator[tuple]: # TODO: fill out tuple |
677 if sort: | 677 if sort: |
678 yield from sorted(self._filemapping.items()) | 678 yield from sorted(self._filemapping.items()) |
679 else: | 679 else: |
680 yield from self._filemapping.items() | 680 yield from self._filemapping.items() |
681 | 681 |