comparison mercurial/manifest.py @ 52474:048c11993d6a

typing: (mostly) align the signatures of `imanifestrevisionstored` overrides When we change the implementations to subclass this explicitly, pytype complains that the signatures mismatch for various methods. It seems hung up on ones in `mercurial.manifest` that have type hints on the return value, but lacked it in the Protocol class (which it thinks returns `None` if there's no annotation). The tricky part is that a lot of the return types in the `mercurial.manifest` module are custom types specific to that module (e.g. `'manifestctx' | 'treemanifestctx'`). Those should probably be replaced with Protocol classes. I was going to avoid making a long series longer by disabling that check for now by putting `Any` as the return type on the Protocol class methods, and then realized the problem is the class isn't marked as a Protocol (that property isn't inherited). For now, lock in the synchronized signatures.
author Matt Harbison <matt_harbison@yahoo.com>
date Wed, 23 Oct 2024 12:44:09 -0400
parents 0851d94bfdaa
children d37d8dfe65bd
comparison
equal deleted inserted replaced
52473:a1dd484bf33b 52474:048c11993d6a
2330 continue 2330 continue
2331 if new_node is not None: 2331 if new_node is not None:
2332 md.set(f, new_node, new_flag) 2332 md.set(f, new_node, new_flag)
2333 return md 2333 return md
2334 2334
2335 def read_delta_new_entries(self, *, shallow=False) -> manifestdict: 2335 def read_delta_new_entries(self, *, shallow: bool = False) -> manifestdict:
2336 """see `interface.imanifestrevisionbase` documentations""" 2336 """see `interface.imanifestrevisionbase` documentations"""
2337 # If we are using narrow, returning a delta against an arbitrary 2337 # If we are using narrow, returning a delta against an arbitrary
2338 # changeset might return file outside the narrowspec. This can create 2338 # changeset might return file outside the narrowspec. This can create
2339 # issue when running validation server side with strict security as 2339 # issue when running validation server side with strict security as
2340 # push from low priviledge usage might be seen as adding new revision 2340 # push from low priviledge usage might be seen as adding new revision
2619 store = self._storage() 2619 store = self._storage()
2620 r = store.rev(self._node) 2620 r = store.rev(self._node)
2621 bases = (store.deltaparent(r),) 2621 bases = (store.deltaparent(r),)
2622 return self.read_any_fast_delta(bases, shallow=shallow)[1] 2622 return self.read_any_fast_delta(bases, shallow=shallow)[1]
2623 2623
2624 def readfast(self, shallow=False) -> AnyManifestDict: 2624 def readfast(self, shallow: bool = False) -> AnyManifestDict:
2625 """Calls either readdelta or read, based on which would be less work. 2625 """Calls either readdelta or read, based on which would be less work.
2626 readdelta is called if the delta is against the p1, and therefore can be 2626 readdelta is called if the delta is against the p1, and therefore can be
2627 read quickly. 2627 read quickly.
2628 2628
2629 If `shallow` is True, it only returns the entries from this manifest, 2629 If `shallow` is True, it only returns the entries from this manifest,
2692 self._node = node 2692 self._node = node
2693 2693
2694 def read(self): 2694 def read(self):
2695 return excludeddir(self.nodeconstants, self._dir, self._node) 2695 return excludeddir(self.nodeconstants, self._dir, self._node)
2696 2696
2697 def readfast(self, shallow=False): 2697 def readfast(self, shallow: bool = False):
2698 # special version of readfast since we don't have underlying storage 2698 # special version of readfast since we don't have underlying storage
2699 return self.read() 2699 return self.read()
2700 2700
2701 def write(self, *args): 2701 def write(self, *args):
2702 raise error.ProgrammingError( 2702 raise error.ProgrammingError(