qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 7/8] qapi/error: Add type hints


From: Markus Armbruster
Subject: Re: [PATCH v2 7/8] qapi/error: Add type hints
Date: Thu, 15 Apr 2021 09:15:52 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)

John Snow <jsnow@redhat.com> writes:

> 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],

The Optional is a bit surprising.  Mind pointing to the / a reason in
the commit message?

> +                 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:




reply via email to

[Prev in Thread] Current Thread [Next in Thread]