From patchwork Wed Dec 15 20:47:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D11926: pytype: stop excluding chgserver.py From: phabricator X-Patchwork-Id: 50252 Message-Id: To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Wed, 15 Dec 2021 20:47:40 +0000 mharbison72 created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY This teaches pytype about some lazy initialization, and avoids the following: File "/mnt/c/Users/Matt/hg/mercurial/chgserver.py", line 666, in _checkextensions: No attribute '_hashstate' on chgunixservicehandler [attribute-error] File "/mnt/c/Users/Matt/hg/mercurial/chgserver.py", line 672, in _checkextensions: No attribute '_hashstate' on chgunixservicehandler [attribute-error] File "/mnt/c/Users/Matt/hg/mercurial/chgserver.py", line 677, in _bind: No attribute '_realaddress' on chgunixservicehandler [attribute-error] File "/mnt/c/Users/Matt/hg/mercurial/chgserver.py", line 683, in _bind: No attribute '_realaddress' on chgunixservicehandler [attribute-error] File "/mnt/c/Users/Matt/hg/mercurial/chgserver.py", line 686, in _createsymlink: No attribute '_baseaddress' on chgunixservicehandler [attribute-error] File "/mnt/c/Users/Matt/hg/mercurial/chgserver.py", line 686, in _createsymlink: No attribute '_realaddress' on chgunixservicehandler [attribute-error] File "/mnt/c/Users/Matt/hg/mercurial/chgserver.py", line 688, in _createsymlink: No attribute '_baseaddress' on chgunixservicehandler [attribute-error] File "/mnt/c/Users/Matt/hg/mercurial/chgserver.py", line 689, in _createsymlink: No attribute '_realaddress' on chgunixservicehandler [attribute-error] File "/mnt/c/Users/Matt/hg/mercurial/chgserver.py", line 690, in _createsymlink: No attribute '_baseaddress' on chgunixservicehandler [attribute-error] REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D11926 AFFECTED FILES mercurial/chgserver.py tests/test-check-pytype.t CHANGE DETAILS To: mharbison72, #hg-reviewers Cc: mercurial-patches, mercurial-devel diff --git a/tests/test-check-pytype.t b/tests/test-check-pytype.t --- a/tests/test-check-pytype.t +++ b/tests/test-check-pytype.t @@ -10,7 +10,6 @@ probably hiding real problems. mercurial/bundlerepo.py # no vfs and ui attrs on bundlerepo -mercurial/chgserver.py # [attribute-error] mercurial/context.py # many [attribute-error] mercurial/crecord.py # tons of [attribute-error], [module-attr] mercurial/debugcommands.py # [wrong-arg-types] @@ -46,7 +45,6 @@ $ pytype -V 3.6 --keep-going --jobs auto mercurial \ > -x mercurial/bundlerepo.py \ - > -x mercurial/chgserver.py \ > -x mercurial/context.py \ > -x mercurial/crecord.py \ > -x mercurial/debugcommands.py \ diff --git a/mercurial/chgserver.py b/mercurial/chgserver.py --- a/mercurial/chgserver.py +++ b/mercurial/chgserver.py @@ -643,6 +643,13 @@ def __init__(self, ui): self.ui = ui + + # TODO: use PEP 526 syntax (`_hashstate: hashstate` at the class level) + # when 3.5 support is dropped. + self._hashstate = None # type: hashstate + self._baseaddress = None # type: bytes + self._realaddress = None # type: bytes + self._idletimeout = ui.configint(b'chgserver', b'idletimeout') self._lastactive = time.time()