Patchwork D10166: typing: ensure that error.Abort is given bytes

login
register
mail settings
Submitter phabricator
Date March 12, 2021, 6:08 p.m.
Message ID <differential-rev-PHID-DREV-jwozzzxkkjfzle7jov3s-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48481/
State Superseded
Headers show

Comments

phabricator - March 12, 2021, 6:08 p.m.
mharbison72 created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  mercurial/error.py

CHANGE DETAILS




To: mharbison72, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/error.py b/mercurial/error.py
--- a/mercurial/error.py
+++ b/mercurial/error.py
@@ -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