qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH 04/37] qapi: move generator entrypoint into module


From: Markus Armbruster
Subject: Re: [PATCH 04/37] qapi: move generator entrypoint into module
Date: Wed, 16 Sep 2020 13:54:44 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)

John Snow <jsnow@redhat.com> writes:

> As part of delinting and adding type hints to the QAPI generator, it's
> helpful for the entrypoint to be part of the module, only leaving a very
> tiny entrypoint shim outside of the module.
>
> As a result, all of the include statements are reworked to be module-aware,
> as explicit relative imports.

Should this be split into two commits, one for each of the paragraphs
above?

PEP 8 recommends absolute imports, with one exception:

    However, explicit relative imports are an acceptable alternative to
    absolute imports, especially when dealing with complex package
    layouts where using absolute imports would be unnecessarily verbose:

        from . import sibling
        from .sibling import example

    Standard library code should avoid complex package layouts and
    always use absolute imports.

Do you think it covers your use of relative imports?

> This is done primarily for the benefit of python tooling (pylint, mypy,
> flake8, et al) which otherwise has trouble consistently resolving
> "qapi.x" to mean "a sibling file in this folder."

Can you give me an example of some tool having troube?

> Signed-off-by: John Snow <jsnow@redhat.com>
> ---
>  scripts/qapi-gen.py        | 94 +++-----------------------------------
>  scripts/qapi/commands.py   |  4 +-
>  scripts/qapi/doc.py        |  2 +-
>  scripts/qapi/events.py     |  8 ++--
>  scripts/qapi/expr.py       |  4 +-
>  scripts/qapi/gen.py        |  4 +-
>  scripts/qapi/introspect.py |  8 ++--
>  scripts/qapi/parser.py     |  4 +-
>  scripts/qapi/schema.py     |  8 ++--
>  scripts/qapi/script.py     | 91 ++++++++++++++++++++++++++++++++++++
>  scripts/qapi/types.py      |  6 +--
>  scripts/qapi/visit.py      |  6 +--
>  12 files changed, 124 insertions(+), 115 deletions(-)
>  create mode 100644 scripts/qapi/script.py

Naming is hard...  main.py?

>
> diff --git a/scripts/qapi-gen.py b/scripts/qapi-gen.py
> index 59becba3e1..e649f8dd44 100644
> --- a/scripts/qapi-gen.py
> +++ b/scripts/qapi-gen.py
> @@ -1,97 +1,15 @@
>  #!/usr/bin/env python3
> -
> -# This work is licensed under the terms of the GNU GPL, version 2 or later.
> -# See the COPYING file in the top-level directory.
> -

Keep the license blurb.

[...]




reply via email to

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