changeset 48486:7caaefa48794

pytype: stop excluding chgserver.py 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] Differential Revision: https://phab.mercurial-scm.org/D11926
author Matt Harbison <matt_harbison@yahoo.com>
date Tue, 14 Dec 2021 17:06:32 -0500
parents ea13dabbe168
children 333a2656e981
files mercurial/chgserver.py tests/test-check-pytype.t
diffstat 2 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/chgserver.py	Mon Dec 13 22:46:43 2021 -0500
+++ b/mercurial/chgserver.py	Tue Dec 14 17:06:32 2021 -0500
@@ -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()
 
--- a/tests/test-check-pytype.t	Mon Dec 13 22:46:43 2021 -0500
+++ b/tests/test-check-pytype.t	Tue Dec 14 17:06:32 2021 -0500
@@ -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 \