Mercurial > hg-stable
changeset 51305:8b2ea2246a5f
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.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Wed, 20 Dec 2023 11:23:09 +0100 |
parents | f15cb5111a1e |
children | 7bd7fcc711f2 |
files | mercurial/chgserver.py mercurial/error.py mercurial/i18n.py mercurial/pathutil.py mercurial/phases.py mercurial/upgrade_utils/actions.py |
diffstat | 6 files changed, 18 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- 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()
--- 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)
--- 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.
--- 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
--- 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)
--- 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):