diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2019-12-25 05:41:54 +0300 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2019-12-25 05:41:54 +0300 |
commit | d717f5ae31d17533a5a20b581f571eb4a95b1b30 (patch) | |
tree | 65bb3a38edc57d2b5e70b19ca8996ccebd1e3951 /sphinx/errors.py | |
parent | d82e7c12a177a6a547ba1e72540f079f64590f8a (diff) | |
parent | 869ba4f67947b97af90dc706fb7e6ed17946ccd3 (diff) |
Merge branch '2.0'
Diffstat (limited to 'sphinx/errors.py')
-rw-r--r-- | sphinx/errors.py | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/sphinx/errors.py b/sphinx/errors.py index 64036721f..d67d6d1f7 100644 --- a/sphinx/errors.py +++ b/sphinx/errors.py @@ -9,9 +9,7 @@ :license: BSD, see LICENSE for details. """ -if False: - # For type annotation - from typing import Any # NOQA +from typing import Any class SphinxError(Exception): @@ -51,21 +49,18 @@ class ExtensionError(SphinxError): """Extension error.""" category = 'Extension error' - def __init__(self, message, orig_exc=None): - # type: (str, Exception) -> None + def __init__(self, message: str, orig_exc: Exception = None) -> None: super().__init__(message) self.message = message self.orig_exc = orig_exc - def __repr__(self): - # type: () -> str + def __repr__(self) -> str: if self.orig_exc: return '%s(%r, %r)' % (self.__class__.__name__, self.message, self.orig_exc) return '%s(%r)' % (self.__class__.__name__, self.message) - def __str__(self): - # type: () -> str + def __str__(self) -> str: parent_str = super().__str__() if self.orig_exc: return '%s (exception: %s)' % (parent_str, self.orig_exc) @@ -102,21 +97,18 @@ class SphinxParallelError(SphinxError): category = 'Sphinx parallel build error' - def __init__(self, message, traceback): - # type: (str, Any) -> None + def __init__(self, message: str, traceback: Any) -> None: self.message = message self.traceback = traceback - def __str__(self): - # type: () -> str + def __str__(self) -> str: return self.message class PycodeError(Exception): """Pycode Python source code analyser error.""" - def __str__(self): - # type: () -> str + def __str__(self) -> str: res = self.args[0] if len(self.args) > 1: res += ' (exception was: %r)' % self.args[1] |