# HG changeset patch # User Matt Harbison # Date 1729914305 14400 # Node ID 8b791764fc52bff3acfdbf26b634e833679260bd # Parent ff13068e9b1cd7d5c6ed1f20dde6800ee799c0a7 typing: suppress bogus pytype errors in `mercurial/wireprotov1peer.py` Fixes: File "/mnt/c/Users/Matt/hg/mercurial/wireprotov1peer.py", line 100, in result: No attribute '_peerexecutor' on unsentfuture [attribute-error] File "/mnt/c/Users/Matt/hg/mercurial/wireprotov1peer.py", line 278, in close: No attribute 'shutdown' on None [attribute-error] Called from (traceback): line 123, in __exit__ File "/mnt/c/Users/Matt/hg/mercurial/wireprotov1peer.py", line 278, in close: No attribute 'shutdown' on None [attribute-error] In Optional[concurrent.futures.thread.ThreadPoolExecutor] We drop the zope decorator on `peerexecutor`, because otherwise it triggers this error: File "/tmp/mercurial-ci/mercurial/wireprotov1peer.py", line 111, in : Invalid type annotation [invalid-annotation] Must be constant Not sure why, because the decorated classes usually get typed as `Any`, which would also be fine here. diff -r ff13068e9b1c -r 8b791764fc52 mercurial/wireprotov1peer.py --- a/mercurial/wireprotov1peer.py Fri Oct 25 23:09:10 2024 -0400 +++ b/mercurial/wireprotov1peer.py Fri Oct 25 23:45:05 2024 -0400 @@ -93,6 +93,8 @@ call ``sendcommands()``. """ + _peerexecutor: "peerexecutor" + def result(self, timeout=None): if self.done(): return futures.Future.result(self, timeout) @@ -105,7 +107,7 @@ return self.result(timeout) -@interfaceutil.implementer(repository.ipeercommandexecutor) +# @interfaceutil.implementer(repository.ipeercommandexecutor) class peerexecutor: def __init__(self, peer): self._peer = peer @@ -275,6 +277,9 @@ try: self._responsef.result() finally: + # Help pytype- this is initialized by self.sendcommands(), called + # above. + assert self._responseexecutor is not None self._responseexecutor.shutdown(wait=True) self._responsef = None self._responseexecutor = None