Mercurial > public > mercurial-scm > hg-stable
changeset 52520:c855943e334b
git: fix `repository.imanifestdict` implementation flaws detected by pytype
The next logical step is to align the signatures on `repository.imanifestdict`
and the logical subclasses. But that requires this small detour, as doing that
caused these errors:
File "/mnt/c/Users/Matt/hg/hgext/git/manifest.py", line 247, in items:
bad return type [bad-return-type]
Expected: Tuple[bytes, bytes]
Actually returned: bytes
File "/mnt/c/Users/Matt/hg/hgext/git/manifest.py", line 255, in iterentries:
bad return type [bad-return-type]
Expected: Tuple[bytes, bytes, bytes]
Actually returned: Tuple[Any, bytes]
The type annotation added to `_resolve_entry()` here to help clarify things then
caused PyCharm to flag `gittreemanifestctx.find()` for a bad return type, also
fixed here.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Thu, 24 Oct 2024 22:24:46 -0400 |
parents | ef119f914fc1 |
children | 48cdbd4d5443 |
files | hgext/git/manifest.py |
diffstat | 1 files changed, 4 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/git/manifest.py Wed Oct 23 15:13:40 2024 -0400 +++ b/hgext/git/manifest.py Thu Oct 24 22:24:46 2024 -0400 @@ -42,7 +42,7 @@ # dict of path: Optional[Tuple(node, flags)] self._pending_changes = pending_changes - def _resolve_entry(self, path): + def _resolve_entry(self, path) -> tuple[bytes, bytes]: """Given a path, load its node and flags, or raise KeyError if missing. This takes into account any pending writes in the builder. @@ -224,7 +224,7 @@ def items(self): for f in self: # TODO: build a proper iterator version of this - yield self[f] + yield f, self[f] def iteritems(self): return self.items() @@ -232,7 +232,7 @@ def iterentries(self): for f in self: # TODO: build a proper iterator version of this - yield self._resolve_entry(f) + yield f, *self._resolve_entry(f) def text(self): assert False # TODO can this method move out of the manifest iface? @@ -276,7 +276,7 @@ return memgittreemanifestctx(self._repo, self._tree) def find(self, path: bytes) -> tuple[bytes, bytes]: - return self.read()[path] + return self.read().find(path) class memgittreemanifestctx(repository.imanifestrevisionwritable):