[PATCH 1/3] python/aqmp: use absolute import statement

John Snow posted 3 patches 4 years ago
Maintainers: Cleber Rosa <crosa@redhat.com>, John Snow <jsnow@redhat.com>, Eduardo Habkost <eduardo@habkost.net>
[PATCH 1/3] python/aqmp: use absolute import statement
Posted by John Snow 4 years ago
pylint's dependency astroid appears to have bugs in 2.9.1 and 2.9.2 (Dec
31 and Jan 3) that appear to erroneously expect the qemu namespace to
have an __init__.py file. astroid 2.9.3 (Jan 9) avoids that problem, but
appears to not understand a relative import within a namespace package.

Update the relative import - it was worth changing anyway, because these
packages will eventually be packaged and distributed separately.

Signed-off-by: John Snow <jsnow@redhat.com>
---
 python/qemu/aqmp/aqmp_tui.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/python/qemu/aqmp/aqmp_tui.py b/python/qemu/aqmp/aqmp_tui.py
index a2929f771c..f1e926dd75 100644
--- a/python/qemu/aqmp/aqmp_tui.py
+++ b/python/qemu/aqmp/aqmp_tui.py
@@ -35,7 +35,8 @@
 import urwid
 import urwid_readline
 
-from ..qmp import QEMUMonitorProtocol, QMPBadPortError
+from qemu.qmp import QEMUMonitorProtocol, QMPBadPortError
+
 from .error import ProtocolError
 from .message import DeserializationError, Message, UnexpectedTypeError
 from .protocol import ConnectError, Runstate
-- 
2.31.1


Re: [PATCH 1/3] python/aqmp: use absolute import statement
Posted by Beraldo Leal 4 years ago
On Mon, Jan 10, 2022 at 02:13:47PM -0500, John Snow wrote:
> pylint's dependency astroid appears to have bugs in 2.9.1 and 2.9.2 (Dec
> 31 and Jan 3) that appear to erroneously expect the qemu namespace to
> have an __init__.py file. astroid 2.9.3 (Jan 9) avoids that problem, but
> appears to not understand a relative import within a namespace package.
> 
> Update the relative import - it was worth changing anyway, because these
> packages will eventually be packaged and distributed separately.
> 
> Signed-off-by: John Snow <jsnow@redhat.com>
> ---
>  python/qemu/aqmp/aqmp_tui.py | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/python/qemu/aqmp/aqmp_tui.py b/python/qemu/aqmp/aqmp_tui.py
> index a2929f771c..f1e926dd75 100644
> --- a/python/qemu/aqmp/aqmp_tui.py
> +++ b/python/qemu/aqmp/aqmp_tui.py
> @@ -35,7 +35,8 @@
>  import urwid
>  import urwid_readline
>  
> -from ..qmp import QEMUMonitorProtocol, QMPBadPortError
> +from qemu.qmp import QEMUMonitorProtocol, QMPBadPortError
> +
>  from .error import ProtocolError
>  from .message import DeserializationError, Message, UnexpectedTypeError
>  from .protocol import ConnectError, Runstate
> -- 
> 2.31.1
> 
>

Reviewed-by: Beraldo Leal <bleal@redhat.com>

--
Beraldo