# HG changeset patch # User Pierre-Yves David # Date 1703067789 -3600 # Node ID 8b2ea2246a5f790da4ccbdfb56f3e3b5bde53625 # Parent f15cb5111a1e4f7eb2e4c42e22ce0aad306884e2 pytype: convert type comment for inline variable too Same logic as for the previous changeset, but for "type comment" annotating variables, not function/method. As for the previous changeset, we had to adjust for of the types to actually match what was happening. diff -r f15cb5111a1e -r 8b2ea2246a5f mercurial/chgserver.py --- a/mercurial/chgserver.py Tue Dec 19 21:29:34 2023 +0100 +++ b/mercurial/chgserver.py Wed Dec 20 11:23:09 2023 +0100 @@ -48,6 +48,10 @@ import struct import time +from typing import ( + Optional, +) + from .i18n import _ from .node import hex @@ -628,14 +632,16 @@ pollinterval = 1 # [sec] + _hashstate: Optional[hashstate] + _baseaddress: Optional[bytes] + _realaddress: Optional[bytes] + 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._hashstate = None + self._baseaddress = None + self._realaddress = None self._idletimeout = ui.configint(b'chgserver', b'idletimeout') self._lastactive = time.time() diff -r f15cb5111a1e -r 8b2ea2246a5f mercurial/error.py --- a/mercurial/error.py Tue Dec 19 21:29:34 2023 +0100 +++ b/mercurial/error.py Wed Dec 20 11:23:09 2023 +0100 @@ -57,7 +57,7 @@ """ def __init__(self, *args, **kw): - self.hint = kw.pop('hint', None) # type: Optional[bytes] + self.hint: Optional[bytes] = kw.pop('hint', None) super(Hint, self).__init__(*args, **kw) diff -r f15cb5111a1e -r 8b2ea2246a5f mercurial/i18n.py --- a/mercurial/i18n.py Tue Dec 19 21:29:34 2023 +0100 +++ b/mercurial/i18n.py Wed Dec 20 11:23:09 2023 +0100 @@ -89,7 +89,7 @@ if message not in cache: if type(message) is str: # goofy unicode docstrings in test - paragraphs = message.split(u'\n\n') # type: List[str] + paragraphs: List[str] = message.split(u'\n\n') else: # should be ascii, but we have unicode docstrings in test, which # are converted to utf-8 bytes on Python 3. diff -r f15cb5111a1e -r 8b2ea2246a5f mercurial/pathutil.py --- a/mercurial/pathutil.py Tue Dec 19 21:29:34 2023 +0100 +++ b/mercurial/pathutil.py Wed Dec 20 11:23:09 2023 +0100 @@ -392,4 +392,4 @@ # rather not let our internals know that we're thinking in posix terms # - instead we'll let them be oblivious. join = posixpath.join -dirname = posixpath.dirname # type: Callable[[bytes], bytes] +dirname: Callable[[bytes], bytes] = posixpath.dirname diff -r f15cb5111a1e -r 8b2ea2246a5f mercurial/phases.py --- a/mercurial/phases.py Tue Dec 19 21:29:34 2023 +0100 +++ b/mercurial/phases.py Wed Dec 20 11:23:09 2023 +0100 @@ -163,7 +163,9 @@ _fphasesentry = struct.Struct(b'>i20s') # record phase index -public, draft, secret = range(3) # type: int +public: int = 0 +draft: int = 1 +secret: int = 2 archived = 32 # non-continuous for compatibility internal = 96 # non-continuous for compatibility allphases = (public, draft, secret, archived, internal) diff -r f15cb5111a1e -r 8b2ea2246a5f mercurial/upgrade_utils/actions.py --- a/mercurial/upgrade_utils/actions.py Tue Dec 19 21:29:34 2023 +0100 +++ b/mercurial/upgrade_utils/actions.py Wed Dec 20 11:23:09 2023 +0100 @@ -108,7 +108,7 @@ compatible_with_share = False -allformatvariant = [] # type: List[Type['formatvariant']] +allformatvariant: List[Type['formatvariant']] = [] def registerformatvariant(cls):