[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 7/8] qapi/error: Add type hints
From: |
John Snow |
Subject: |
[PATCH v2 7/8] qapi/error: Add type hints |
Date: |
Tue, 30 Mar 2021 13:18:43 -0400 |
No functional change.
Signed-off-by: John Snow <jsnow@redhat.com>
---
scripts/qapi/error.py | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/scripts/qapi/error.py b/scripts/qapi/error.py
index 2183b8c6b7..6ba54821c9 100644
--- a/scripts/qapi/error.py
+++ b/scripts/qapi/error.py
@@ -11,6 +11,10 @@
# This work is licensed under the terms of the GNU GPL, version 2.
# See the COPYING file in the top-level directory.
+from typing import Optional
+
+from .source import QAPISourceInfo
+
class QAPIError(Exception):
"""Base class for all exceptions from the QAPI package."""
@@ -18,13 +22,16 @@ class QAPIError(Exception):
class QAPISourceError(QAPIError):
"""Error class for all exceptions identifying a source location."""
- def __init__(self, info, msg, col=None):
+ def __init__(self,
+ info: Optional[QAPISourceInfo],
+ msg: str,
+ col: Optional[int] = None):
super().__init__()
self.info = info
self.msg = msg
self.col = col
- def __str__(self):
+ def __str__(self) -> str:
assert self.info is not None
loc = str(self.info)
if self.col is not None:
--
2.30.2
- [PATCH v2 0/8] qapi: static typing conversion, pt4, John Snow, 2021/03/30
- [PATCH v2 4/8] qapi/error: Change assertion, John Snow, 2021/03/30
- [PATCH v2 2/8] qapi/error: Use Python3-style super(), John Snow, 2021/03/30
- [PATCH v2 7/8] qapi/error: Add type hints,
John Snow <=
- [PATCH v2 1/8] qapi/error: Repurpose QAPIError as a generic exception base class, John Snow, 2021/03/30
- [PATCH v2 6/8] qapi/error.py: enable pylint checks, John Snow, 2021/03/30
- [PATCH v2 3/8] qapi/error: Make QAPISourceError 'col' parameter optional, John Snow, 2021/03/30
- [PATCH v2 8/8] qapi/error.py: enable mypy checks, John Snow, 2021/03/30
- [PATCH v2 5/8] qapi/error.py: move QAPIParseError to parser.py, John Snow, 2021/03/30