typing: ensure that error.Abort is given bytes stable
authorMatt Harbison <matt_harbison@yahoo.com>
Thu, 11 Mar 2021 21:25:28 -0500
branchstable
changeset 46681 ae62ab82a345
parent 46680 6595e22048fe
child 46682 8f8fce2dd594
typing: ensure that error.Abort is given bytes There's a bunch more typing to be done here, but the list of things to fix is already long, and I know there are instances where this is being used incorrectly. Differential Revision: https://phab.mercurial-scm.org/D10166
mercurial/error.py
--- a/mercurial/error.py	Thu Mar 11 21:21:41 2021 -0500
+++ b/mercurial/error.py	Thu Mar 11 21:25:28 2021 -0500
@@ -18,6 +18,11 @@
 # Do not import anything but pycompat here, please
 from . import pycompat
 
+if pycompat.TYPE_CHECKING:
+    from typing import (
+        Optional,
+    )
+
 
 def _tobytes(exc):
     """Byte-stringify exception in the same way as BaseException_str()"""
@@ -169,6 +174,7 @@
     """Raised if a command needs to print an error and exit."""
 
     def __init__(self, message, hint=None):
+        # type: (bytes, Optional[bytes]) -> None
         self.message = message
         self.hint = hint
         # Pass the message into the Exception constructor to help extensions