[Updated] D11719: typing: add more type hints to the errors module

mharbison72 (Matt Harbison) phabricator at mercurial-scm.org
Tue Oct 26 09:02:32 UTC 2021


Closed by commit rHG9de0823705b4: typing: add more type hints to the errors module (authored by mharbison72).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D11719?vs=30980&id=30987

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D11719/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D11719

AFFECTED FILES
  mercurial/error.py

CHANGE DETAILS

diff --git a/mercurial/error.py b/mercurial/error.py
--- a/mercurial/error.py
+++ b/mercurial/error.py
@@ -31,6 +31,7 @@
 
 
 def _tobytes(exc):
+    # type: (...) -> bytes
     """Byte-stringify exception in the same way as BaseException_str()"""
     if not exc.args:
         return b''
@@ -47,7 +48,7 @@
     """
 
     def __init__(self, *args, **kw):
-        self.hint = kw.pop('hint', None)
+        self.hint = kw.pop('hint', None)  # type: Optional[bytes]
         super(Hint, self).__init__(*args, **kw)
 
 
@@ -71,6 +72,7 @@
     if pycompat.ispy3:
 
         def __str__(self):
+            # type: () -> str
             # the output would be unreadable if the message was translated,
             # but do not replace it with encoding.strfromlocal(), which
             # may raise another exception.
@@ -105,6 +107,7 @@
 
 class SidedataHashError(RevlogError):
     def __init__(self, key, expected, got):
+        # type: (int, bytes, bytes) -> None
         self.hint = None
         self.sidedatakey = key
         self.expecteddigest = expected
@@ -117,6 +120,7 @@
 
 class LookupError(RevlogError, KeyError):
     def __init__(self, name, index, message):
+        # type: (bytes, bytes, bytes) -> None
         self.name = name
         self.index = index
         # this can't be called 'message' because at least some installs of
@@ -343,6 +347,7 @@
     """Exception raised when a remote repo reports failure"""
 
     def __init__(self, message=None, hint=None):
+        # type: (Optional[bytes], Optional[bytes]) -> None
         from .i18n import _
 
         if message:



To: mharbison72, #hg-reviewers, Alphare
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20211026/94856f1e/attachment-0002.html>


More information about the Mercurial-patches mailing list