From nobody Wed May 15 22:57:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600994400; cv=none; d=zohomail.com; s=zohoarc; b=ILRI9JmzxR1IzmfT68HYY+ahcfOB64hbdXvWbBpks7+xbC94/5LXm5IHAPZJaS3sNxtv/reHP9UOaStWe4T50qEIlF9rB4SyurIIjyrSk7e9feOQRBt74WSDQeOYUkxdDq2EijxMGrS0RExy/3xcFVc2RkKUESJfj6k+OFTidi4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600994400; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=uNCEViIdoSebfjQl8s5yIziaxq9c3EXzZxhiW3EngQs=; b=cBAcwzjypZjkLuH4+AecIhTxYgDgJEtX9zBfco6RRJr/YkakkyzRu4zHCKKpP/m7LTA1V1mEjMoex4mxn1BsjwQsG9mInFKpSoREeEzwoETWXbN43+o/lmaXm/isHyQc/iAADmDzZwzzPTETTGGkULUksOLx/1pBzLu2hl/FGvo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16009944009496.854936983059588; Thu, 24 Sep 2020 17:40:00 -0700 (PDT) Received: from localhost ([::1]:57894 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLbmJ-0001eW-2O for importer@patchew.org; Thu, 24 Sep 2020 20:39:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51026) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLbbw-0000m2-5r for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:39648) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLbbp-00008Y-KN for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:15 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-140-td7EA4NFNparSDPPotjQcw-1; Thu, 24 Sep 2020 20:29:03 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 680DB188C125 for ; Fri, 25 Sep 2020 00:29:02 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9A1765D9F1; Fri, 25 Sep 2020 00:29:01 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600993748; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uNCEViIdoSebfjQl8s5yIziaxq9c3EXzZxhiW3EngQs=; b=a/HrFf90EqZ8CPZKXEvfI88wZg/s1CHfGcLAA8Dc4ugBqB6t3PEmX01IrATOMNPjdIBXJm iOsl/qxuVS8VWpO7HbSfupLbscOsXxsIlbdw21QeqYxQTiDRG5G8HKj0aiDwEUNkPFFWMq CK48reNBNrCGeQmndou321DMsBXCQc8= X-MC-Unique: td7EA4NFNparSDPPotjQcw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 01/47] [DO-NOT-MERGE] docs: replace single backtick (`) with double-backtick (``) Date: Thu, 24 Sep 2020 20:28:14 -0400 Message-Id: <20200925002900.465855-2-jsnow@redhat.com> In-Reply-To: <20200925002900.465855-1-jsnow@redhat.com> References: <20200925002900.465855-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/24 01:10:00 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_PDS_OTHER_BAD_TLD=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The single backtick in ReST is the "default role". Currently, Sphinx's default role is called "content". Sphinx suggests you can use the "Any" role instead to turn any single-backtick enclosed item into a cross-reference. Before we do that, though, we'll need to turn all existing usages of the "content" role to inline verbatim markup by using double backticks instead. Signed-off-by: John Snow Reviewed-by: Cleber Rosa --- docs/devel/build-system.rst | 118 ++++++++++++------------- docs/devel/migration.rst | 59 +++++++------ docs/devel/tcg-plugins.rst | 14 +-- docs/devel/testing.rst | 2 +- docs/interop/live-block-operations.rst | 4 +- docs/system/arm/cpu-features.rst | 110 +++++++++++------------ docs/system/arm/nuvoton.rst | 2 +- docs/system/s390x/protvirt.rst | 10 +-- 8 files changed, 161 insertions(+), 158 deletions(-) diff --git a/docs/devel/build-system.rst b/docs/devel/build-system.rst index 08e85c69e1..a4711cd4e1 100644 --- a/docs/devel/build-system.rst +++ b/docs/devel/build-system.rst @@ -53,14 +53,14 @@ following tasks: - Add a Meson build option to meson_options.txt. =20 - Add support to the command line arg parser to handle any new - `--enable-XXX`/`--disable-XXX` flags required by the feature. + ``--enable-XXX``/``--disable-XXX`` flags required by the feature. =20 - Add information to the help output message to report on the new feature flag. =20 - Add code to perform the actual feature check. =20 - - Add code to include the feature status in `config-host.h` + - Add code to include the feature status in ``config-host.h`` =20 - Add code to print out the feature status in the configure summary upon completion. @@ -116,51 +116,51 @@ Helper functions The configure script provides a variety of helper functions to assist developers in checking for system features: =20 -`do_cc $ARGS...` +``do_cc $ARGS...`` Attempt to run the system C compiler passing it $ARGS... =20 -`do_cxx $ARGS...` +``do_cxx $ARGS...`` Attempt to run the system C++ compiler passing it $ARGS... =20 -`compile_object $CFLAGS` +``compile_object $CFLAGS`` Attempt to compile a test program with the system C compiler using $CFLAGS. The test program must have been previously written to a file - called $TMPC. The replacement in Meson is the compiler object `cc`, - which has methods such as `cc.compiles()`, - `cc.check_header()`, `cc.has_function()`. + called $TMPC. The replacement in Meson is the compiler object ``cc``, + which has methods such as ``cc.compiles()``, + ``cc.check_header()``, ``cc.has_function()``. =20 -`compile_prog $CFLAGS $LDFLAGS` +``compile_prog $CFLAGS $LDFLAGS`` Attempt to compile a test program with the system C compiler using $CFLAGS and link it with the system linker using $LDFLAGS. The test program must have been previously written to a file called $TMPC. - The replacement in Meson is `cc.find_library()` and `cc.links()`. + The replacement in Meson is ``cc.find_library()`` and ``cc.links()``. =20 -`has $COMMAND` +``has $COMMAND`` Determine if $COMMAND exists in the current environment, either as a shell builtin, or executable binary, returning 0 on success. The - replacement in Meson is `find_program()`. + replacement in Meson is ``find_program()``. =20 -`check_define $NAME` +``check_define $NAME`` Determine if the macro $NAME is defined by the system C compiler =20 -`check_include $NAME` +``check_include $NAME`` Determine if the include $NAME file is available to the system C - compiler. The replacement in Meson is `cc.has_header()`. + compiler. The replacement in Meson is ``cc.has_header()``. =20 -`write_c_skeleton` +``write_c_skeleton`` Write a minimal C program main() function to the temporary file indicated by $TMPC =20 -`feature_not_found $NAME $REMEDY` +``feature_not_found $NAME $REMEDY`` Print a message to stderr that the feature $NAME was not available on the system, suggesting the user try $REMEDY to address the problem. =20 -`error_exit $MESSAGE $MORE...` +``error_exit $MESSAGE $MORE...`` Print $MESSAGE to stderr, followed by $MORE... and then exit from the configure script with non-zero status =20 -`query_pkg_config $ARGS...` +``query_pkg_config $ARGS...`` Run pkg-config passing it $ARGS. If QEMU is doing a static build, then --static will be automatically added to $ARGS =20 @@ -194,8 +194,8 @@ to list the files and their dependency on various confi= guration symbols. =20 Various subsystems that are common to both tools and emulators have -their own sourceset, for example `block_ss` for the block device subsystem, -`chardev_ss` for the character device subsystem, etc. These sourcesets +their own sourceset, for example ``block_ss`` for the block device subsyst= em, +``chardev_ss`` for the character device subsystem, etc. These sourcesets are then turned into static libraries as follows:: =20 libchardev =3D static_library('chardev', chardev_ss.sources(), @@ -204,8 +204,8 @@ are then turned into static libraries as follows:: =20 chardev =3D declare_dependency(link_whole: libchardev) =20 -As of Meson 0.55.1, the special `.fa` suffix should be used for everything -that is used with `link_whole`, to ensure that the link flags are placed +As of Meson 0.55.1, the special ``.fa`` suffix should be used for everythi= ng +that is used with ``link_whole``, to ensure that the link flags are placed correctly in the command line. =20 Files linked into emulator targets there can be split into two distinct gr= oups @@ -216,25 +216,25 @@ In the target-independent set lives various general p= urpose helper code, such as error handling infrastructure, standard data structures, platform portability wrapper functions, etc. This code can be compiled once only and the .o files linked into all output binaries. -Target-independent code lives in the `common_ss`, `softmmu_ss` and -`user_ss` sourcesets. `common_ss` is linked into all emulators, `softmmu_= ss` -only in system emulators, `user_ss` only in user-mode emulators. +Target-independent code lives in the ``common_ss``, ``softmmu_ss`` and +``user_ss`` sourcesets. ``common_ss`` is linked into all emulators, ``sof= tmmu_ss`` +only in system emulators, ``user_ss`` only in user-mode emulators. =20 In the target-dependent set lives CPU emulation, device emulation and much glue code. This sometimes also has to be compiled multiple times, once for each target being built. Target-dependent files are included -in the `specific_ss` sourceset. +in the ``specific_ss`` sourceset. =20 -All binaries link with a static library `libqemuutil.a`, which is then -linked to all the binaries. `libqemuutil.a` is built from several +All binaries link with a static library ``libqemuutil.a``, which is then +linked to all the binaries. ``libqemuutil.a`` is built from several sourcesets; most of them however host generated code, and the only two -of general interest are `util_ss` and `stub_ss`. +of general interest are ``util_ss`` and ``stub_ss``. =20 The separation between these two is purely for documentation purposes. -`util_ss` contains generic utility files. Even though this code is only +``util_ss`` contains generic utility files. Even though this code is only linked in some binaries, sometimes it requires hooks only in some of these and depend on other functions that are not fully implemented by -all QEMU binaries. `stub_ss` links dummy stubs that will only be linked +all QEMU binaries. ``stub_ss`` links dummy stubs that will only be linked into the binary if the real implementation is not present. In a way, the stubs can be thought of as a portable implementation of the weak symbols concept. @@ -242,7 +242,7 @@ symbols concept. The following files concur in the definition of which files are linked into each emulator: =20 -`default-configs/*.mak` +``default-configs/*.mak`` The files under default-configs/ control what emulated hardware is built into each QEMU system and userspace emulator targets. They merely contain a list of config variable definitions like the machines that should be @@ -252,8 +252,8 @@ into each emulator: CONFIG_XLNX_ZYNQMP_ARM=3Dy CONFIG_XLNX_VERSAL=3Dy =20 -`*/Kconfig` - These files are processed together with `default-configs/*.mak` and +``*/Kconfig`` + These files are processed together with ``default-configs/*.mak`` and describe the dependencies between various features, subsystems and device models. They are described in kconfig.rst. =20 @@ -265,19 +265,19 @@ Support scripts --------------- =20 Meson has a special convention for invoking Python scripts: if their -first line is `#! /usr/bin/env python3` and the file is *not* executable, +first line is ``#! /usr/bin/env python3`` and the file is *not* executable, find_program() arranges to invoke the script under the same Python interpreter that was used to invoke Meson. This is the most common and preferred way to invoke support scripts from Meson build files, because it automatically uses the value of configure's --python=3D option. =20 -In case the script is not written in Python, use a `#! /usr/bin/env ...` +In case the script is not written in Python, use a ``#! /usr/bin/env ...`` line and make the script executable. =20 Scripts written in Python, where it is desirable to make the script executable (for example for test scripts that developers may want to invoke from the command line, such as tests/qapi-schema/test-qapi.py), -should be invoked through the `python` variable in meson.build. For +should be invoked through the ``python`` variable in meson.build. For example:: =20 test('QAPI schema regression tests', python, @@ -301,10 +301,10 @@ rules and wraps them so that e.g. submodules are buil= t before QEMU. The resulting build system is largely non-recursive in nature, in contrast to common practices seen with automake. =20 -Tests are also ran by the Makefile with the traditional `make check` -phony target, while benchmarks are run with `make bench`. Meson test -suites such as `unit` can be ran with `make check-unit` too. It is also -possible to run tests defined in meson.build with `meson test`. +Tests are also ran by the Makefile with the traditional ``make check`` +phony target, while benchmarks are run with ``make bench``. Meson test +suites such as ``unit`` can be ran with ``make check-unit`` too. It is al= so +possible to run tests defined in meson.build with ``meson test``. =20 Important files for the build system =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D @@ -316,28 +316,28 @@ The following key files are statically defined in the= source tree, with the rules needed to build QEMU. Their behaviour is influenced by a number of dynamically created files listed later. =20 -`Makefile` +``Makefile`` The main entry point used when invoking make to build all the components of QEMU. The default 'all' target will naturally result in the build of every component. Makefile takes care of recursively building submodules directly via a non-recursive set of rules. =20 -`*/meson.build` +``*/meson.build`` The meson.build file in the root directory is the main entry point for t= he Meson build system, and it coordinates the configuration and build of all executables. Build rules for various subdirectories are included in other meson.build files spread throughout the QEMU source tree. =20 -`tests/Makefile.include` +``tests/Makefile.include`` Rules for external test harnesses. These include the TCG tests, - `qemu-iotests` and the Avocado-based acceptance tests. + ``qemu-iotests`` and the Avocado-based acceptance tests. =20 -`tests/docker/Makefile.include` +``tests/docker/Makefile.include`` Rules for Docker tests. Like tests/Makefile, this file is included directly by the top level Makefile, anything defined in this file will influence the entire build system. =20 -`tests/vm/Makefile.include` +``tests/vm/Makefile.include`` Rules for VM-based tests. Like tests/Makefile, this file is included directly by the top level Makefile, anything defined in this file will influence the entire build system. @@ -353,11 +353,11 @@ Makefile. =20 Built by configure: =20 -`config-host.mak` +``config-host.mak`` When configure has determined the characteristics of the build host it will write a long list of variables to config-host.mak file. This provides the various install directories, compiler / linker flags and a - variety of `CONFIG_*` variables related to optionally enabled features. + variety of ``CONFIG_*`` variables related to optionally enabled features. This is imported by the top level Makefile and meson.build in order to tailor the build output. =20 @@ -369,7 +369,7 @@ Built by configure: build outputs. Variables which are potentially different for each emulator target are defined by the next file... =20 -`$TARGET-NAME/config-target.mak` +``$TARGET-NAME/config-target.mak`` TARGET-NAME is the name of a system or userspace emulator, for example, x86_64-softmmu denotes the system emulator for the x86_64 architecture. This file contains the variables which need to vary on a per-target @@ -380,31 +380,31 @@ Built by configure: =20 Built by Meson: =20 -`${TARGET-NAME}-config-devices.mak` +``${TARGET-NAME}-config-devices.mak`` TARGET-NAME is again the name of a system or userspace emulator. The config-devices.mak file is automatically generated by make using the scripts/make_device_config.sh program, feeding it the default-configs/$TARGET-NAME file as input. =20 -`config-host.h`, `$TARGET-NAME/config-target.h`, `$TARGET-NAME/config-devi= ces.h` +``config-host.h``, ``$TARGET-NAME/config-target.h``, ``$TARGET-NAME/config= -devices.h`` These files are used by source code to determine what features are enabled. They are generated from the contents of the corresponding - `*.h` files using the scripts/create_config program. This extracts + ``*.h`` files using the scripts/create_config program. This extracts relevant variables and formats them as C preprocessor macros. =20 -`build.ninja` +``build.ninja`` The build rules. =20 =20 Built by Makefile: =20 -`Makefile.ninja` +``Makefile.ninja`` A Makefile conversion of the build rules in build.ninja. The conversion is straightforward and, were it necessary to debug the rules produced by Meson, it should be enough to look at build.ninja. The conversion is performed by scripts/ninjatool.py. =20 -`Makefile.mtest` +``Makefile.mtest`` The Makefile definitions that let "make check" run tests defined in meson.build. The rules are produced from Meson's JSON description of tests (obtained with "meson introspect --tests") through the script @@ -414,9 +414,9 @@ Built by Makefile: Useful make targets ------------------- =20 -`help` +``help`` Print a help message for the most common build targets. =20 -`print-VAR` +``print-VAR`` Print the value of the variable VAR. Useful for debugging the build system. diff --git a/docs/devel/migration.rst b/docs/devel/migration.rst index 49112bb27a..f50e125035 100644 --- a/docs/devel/migration.rst +++ b/docs/devel/migration.rst @@ -53,7 +53,7 @@ savevm/loadvm functionality. Debugging =3D=3D=3D=3D=3D=3D=3D=3D=3D =20 -The migration stream can be analyzed thanks to `scripts/analyze_migration.= py`. +The migration stream can be analyzed thanks to ``scripts/analyze_migration= .py``. =20 Example usage: =20 @@ -74,8 +74,8 @@ Common infrastructure =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 The files, sockets or fd's that carry the migration stream are abstracted = by -the ``QEMUFile`` type (see `migration/qemu-file.h`). In most cases this -is connected to a subtype of ``QIOChannel`` (see `io/`). +the ``QEMUFile`` type (see ``migration/qemu-file.h``). In most cases this +is connected to a subtype of ``QIOChannel`` (see ``io/``). =20 =20 Saving the state of one device @@ -165,14 +165,14 @@ An example (from hw/input/pckbd.c) }; =20 We are declaring the state with name "pckbd". -The `version_id` is 3, and the fields are 4 uint8_t in a KBDState structur= e. +The ``version_id`` is 3, and the fields are 4 uint8_t in a KBDState struct= ure. We registered this with: =20 .. code:: c =20 vmstate_register(NULL, 0, &vmstate_kbd, s); =20 -For devices that are `qdev` based, we can register the device in the class +For devices that are ``qdev`` based, we can register the device in the cla= ss init function: =20 .. code:: c @@ -209,9 +209,9 @@ another to load the state back. SaveVMHandlers *ops, void *opaque); =20 -Two functions in the ``ops`` structure are the `save_state` -and `load_state` functions. Notice that `load_state` receives a version_id -parameter to know what state format is receiving. `save_state` doesn't +Two functions in the ``ops`` structure are the ``save_state`` +and ``load_state`` functions. Notice that ``load_state`` receives a versi= on_id +parameter to know what state format is receiving. ``save_state`` doesn't have a version_id parameter because it always uses the latest version. =20 Note that because the VMState macros still save the data in a raw @@ -384,26 +384,28 @@ migration of a device, and using them breaks backward= -migration compatibility; in general most changes can be made by adding Subsections (see above) or _TEST macros (see above) which won't break compatibility. =20 -Each version is associated with a series of fields saved. The `save_state= ` always saves -the state as the newer version. But `load_state` sometimes is able to -load state from an older version. +Each version is associated with a series of fields saved. The +``save_state`` always saves the state as the newer version. But +``load_state`` sometimes is able to load state from an older version. =20 You can see that there are several version fields: =20 -- `version_id`: the maximum version_id supported by VMState for that devic= e. -- `minimum_version_id`: the minimum version_id that VMState is able to und= erstand - for that device. -- `minimum_version_id_old`: For devices that were not able to port to vmst= ate, we can - assign a function that knows how to read this old state. This field is - ignored if there is no `load_state_old` handler. +- ``version_id``: the maximum version_id supported by VMState for that + device. +- ``minimum_version_id``: the minimum version_id that VMState is able to + understand for that device. +- ``minimum_version_id_old``: For devices that were not able to port to + vmstate, we can assign a function that knows how to read this old + state. This field is ignored if there is no ``load_state_old`` + handler. =20 VMState is able to read versions from minimum_version_id to version_id. And the function ``load_state_old()`` (if present) is able to load state from minimum_version_id_old to minimum_version_id. This function is deprecated and will be removed when no more users are left. =20 -There are *_V* forms of many ``VMSTATE_`` macros to load fields for versio= n dependent fields, -e.g. +There are *_V* forms of many ``VMSTATE_`` macros to load fields for +version dependent fields, e.g. =20 .. code:: c =20 @@ -453,7 +455,7 @@ data and then transferred to the main structure. =20 If you use memory API functions that update memory layout outside initialization (i.e., in response to a guest action), this is a strong -indication that you need to call these functions in a `post_load` callback. +indication that you need to call these functions in a ``post_load`` callba= ck. Examples of such memory API functions are: =20 - memory_region_add_subregion() @@ -818,17 +820,18 @@ Postcopy now works with hugetlbfs backed memory: Postcopy with shared memory --------------------------- =20 -Postcopy migration with shared memory needs explicit support from the other -processes that share memory and from QEMU. There are restrictions on the t= ype of -memory that userfault can support shared. +Postcopy migration with shared memory needs explicit support from the +other processes that share memory and from QEMU. There are restrictions +on the type of memory that userfault can support shared. =20 -The Linux kernel userfault support works on `/dev/shm` memory and on `huge= tlbfs` -(although the kernel doesn't provide an equivalent to `madvise(MADV_DONTNE= ED)` -for hugetlbfs which may be a problem in some configurations). +The Linux kernel userfault support works on ``/dev/shm`` memory and on +``hugetlbfs`` (although the kernel doesn't provide an equivalent to +``madvise(MADV_DONTNEED)`` for hugetlbfs which may be a problem in some +configurations). =20 The vhost-user code in QEMU supports clients that have Postcopy support, -and the `vhost-user-bridge` (in `tests/`) and the DPDK package have changes -to support postcopy. +and the ``vhost-user-bridge`` (in ``tests/``) and the DPDK package have +changes to support postcopy. =20 The client needs to open a userfaultfd and register the areas of memory that it maps with userfault. The client must then pass the diff --git a/docs/devel/tcg-plugins.rst b/docs/devel/tcg-plugins.rst index 0568dfa6a4..5057b6e1b2 100644 --- a/docs/devel/tcg-plugins.rst +++ b/docs/devel/tcg-plugins.rst @@ -34,11 +34,11 @@ version they were built against. This can be done simpl= y by:: QEMU_PLUGIN_EXPORT int qemu_plugin_version =3D QEMU_PLUGIN_VERSION; =20 The core code will refuse to load a plugin that doesn't export a -`qemu_plugin_version` symbol or if plugin version is outside of QEMU's +``qemu_plugin_version`` symbol or if plugin version is outside of QEMU's supported range of API versions. =20 -Additionally the `qemu_info_t` structure which is passed to the -`qemu_plugin_install` method of a plugin will detail the minimum and +Additionally the ``qemu_info_t`` structure which is passed to the +``qemu_plugin_install`` method of a plugin will detail the minimum and current API versions supported by QEMU. The API version will be incremented if new APIs are added. The minimum API version will be incremented if existing APIs are changed or removed. @@ -140,12 +140,12 @@ Example Plugins =20 There are a number of plugins included with QEMU and you are encouraged to contribute your own plugins plugins upstream. There is a -`contrib/plugins` directory where they can go. +``contrib/plugins`` directory where they can go. =20 - tests/plugins =20 These are some basic plugins that are used to test and exercise the -API during the `make check-tcg` target. +API during the ``make check-tcg`` target. =20 - contrib/plugins/hotblocks.c =20 @@ -157,7 +157,7 @@ with linux-user execution as system emulation tends to = generate re-translations as blocks from different programs get swapped in and out of system memory. =20 -If your program is single-threaded you can use the `inline` option for +If your program is single-threaded you can use the ``inline`` option for slightly faster (but not thread safe) counters. =20 Example:: @@ -245,7 +245,7 @@ which will lead to a sorted list after the class breakd= own:: ... =20 To find the argument shorthand for the class you need to examine the -source code of the plugin at the moment, specifically the `*opt` +source code of the plugin at the moment, specifically the ``*opt`` argument in the InsnClassExecCount tables. =20 - contrib/plugins/lockstep.c diff --git a/docs/devel/testing.rst b/docs/devel/testing.rst index bd64c1bdcd..666c4d7240 100644 --- a/docs/devel/testing.rst +++ b/docs/devel/testing.rst @@ -749,7 +749,7 @@ The base test class has also support for tests with mor= e than one QEMUMachine. The way to get machines is through the ``self.get_vm()`` method which will return a QEMUMachine instance. The ``self.get_vm()`` method accepts arguments that will be passed to the QEMUMachine creation -and also an optional `name` attribute so you can identify a specific +and also an optional ``name`` attribute so you can identify a specific machine and get it more than once through the tests methods. A simple and hypothetical example follows: =20 diff --git a/docs/interop/live-block-operations.rst b/docs/interop/live-blo= ck-operations.rst index e13f5a21f8..5a3f045827 100644 --- a/docs/interop/live-block-operations.rst +++ b/docs/interop/live-block-operations.rst @@ -638,7 +638,7 @@ at this point: (QEMU) block-job-complete device=3Djob0 =20 In either of the above cases, if you once again run the -`query-block-jobs` command, there should not be any active block +``query-block-jobs`` command, there should not be any active block operation. =20 Comparing 'commit' and 'mirror': In both then cases, the overlay images @@ -777,7 +777,7 @@ the content of image [D]. } =20 (6) [On *destination* QEMU] Finally, resume the guest vCPUs by issuing the - QMP command `cont`:: + QMP command ``cont``:: =20 (QEMU) cont { diff --git a/docs/system/arm/cpu-features.rst b/docs/system/arm/cpu-feature= s.rst index 2d5c06cd01..640ee09f88 100644 --- a/docs/system/arm/cpu-features.rst +++ b/docs/system/arm/cpu-features.rst @@ -10,22 +10,22 @@ is the Performance Monitoring Unit (PMU). CPU types su= ch as the Cortex-A15 and the Cortex-A57, which respectively implement Arm architecture reference manuals ARMv7-A and ARMv8-A, may both optionally implement PMUs. For example, if a user wants to use a Cortex-A15 without -a PMU, then the `-cpu` parameter should contain `pmu=3Doff` on the QEMU -command line, i.e. `-cpu cortex-a15,pmu=3Doff`. +a PMU, then the ``-cpu`` parameter should contain ``pmu=3Doff`` on the QEMU +command line, i.e. ``-cpu cortex-a15,pmu=3Doff``. =20 As not all CPU types support all optional CPU features, then whether or not a CPU property exists depends on the CPU type. For example, CPUs that implement the ARMv8-A architecture reference manual may optionally support the AArch32 CPU feature, which may be enabled by disabling the -`aarch64` CPU property. A CPU type such as the Cortex-A15, which does -not implement ARMv8-A, will not have the `aarch64` CPU property. +``aarch64`` CPU property. A CPU type such as the Cortex-A15, which does +not implement ARMv8-A, will not have the ``aarch64`` CPU property. =20 QEMU's support may be limited for some CPU features, only partially supporting the feature or only supporting the feature under certain -configurations. For example, the `aarch64` CPU feature, which, when +configurations. For example, the ``aarch64`` CPU feature, which, when disabled, enables the optional AArch32 CPU feature, is only supported when using the KVM accelerator and when running on a host CPU type that -supports the feature. While `aarch64` currently only works with KVM, +supports the feature. While ``aarch64`` currently only works with KVM, it could work with TCG. CPU features that are specific to KVM are prefixed with "kvm-" and are described in "KVM VCPU Features". =20 @@ -33,12 +33,12 @@ CPU Feature Probing =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 Determining which CPU features are available and functional for a given -CPU type is possible with the `query-cpu-model-expansion` QMP command. -Below are some examples where `scripts/qmp/qmp-shell` (see the top comment +CPU type is possible with the ``query-cpu-model-expansion`` QMP command. +Below are some examples where ``scripts/qmp/qmp-shell`` (see the top comme= nt block in the script for usage) is used to issue the QMP commands. =20 -1. Determine which CPU features are available for the `max` CPU type - (Note, we started QEMU with qemu-system-aarch64, so `max` is +1. Determine which CPU features are available for the ``max`` CPU type + (Note, we started QEMU with qemu-system-aarch64, so ``max`` is implementing the ARMv8-A reference manual in this case):: =20 (QEMU) query-cpu-model-expansion type=3Dfull model=3D{"name":"max"} @@ -51,9 +51,9 @@ block in the script for usage) is used to issue the QMP c= ommands. "sve896": true, "sve1280": true, "sve2048": true }}}} =20 -We see that the `max` CPU type has the `pmu`, `aarch64`, `sve`, and many -`sve` CPU features. We also see that all the CPU features are -enabled, as they are all `true`. (The `sve` CPU features are all +We see that the ``max`` CPU type has the ``pmu``, ``aarch64``, ``sve``, an= d many +``sve`` CPU features. We also see that all the CPU features are +enabled, as they are all ``true``. (The ``sve`` CPU features are all optional SVE vector lengths (see "SVE CPU Properties"). While with TCG all SVE vector lengths can be supported, when KVM is in use it's more likely that only a few lengths will be supported, if SVE is supported at @@ -71,9 +71,9 @@ all.) "sve896": true, "sve1280": true, "sve2048": true }}}} =20 -We see it worked, as `pmu` is now `false`. +We see it worked, as ``pmu`` is now ``false``. =20 -(3) Let's try to disable `aarch64`, which enables the AArch32 CPU feature:: +(3) Let's try to disable ``aarch64``, which enables the AArch32 CPU featur= e:: =20 (QEMU) query-cpu-model-expansion type=3Dfull model=3D{"name":"max","= props":{"aarch64":false}} {"error": { @@ -84,7 +84,7 @@ We see it worked, as `pmu` is now `false`. It looks like this feature is limited to a configuration we do not currently have. =20 -(4) Let's disable `sve` and see what happens to all the optional SVE +(4) Let's disable ``sve`` and see what happens to all the optional SVE vector lengths:: =20 (QEMU) query-cpu-model-expansion type=3Dfull model=3D{"name":"max","= props":{"sve":false}} @@ -97,14 +97,14 @@ currently have. "sve896": false, "sve1280": false, "sve2048": false }}}} =20 -As expected they are now all `false`. +As expected they are now all ``false``. =20 (5) Let's try probing CPU features for the Cortex-A15 CPU type:: =20 (QEMU) query-cpu-model-expansion type=3Dfull model=3D{"name":"cortex= -a15"} {"return": {"model": {"name": "cortex-a15", "props": {"pmu": true}}}} =20 -Only the `pmu` CPU feature is available. +Only the ``pmu`` CPU feature is available. =20 A note about CPU feature dependencies ------------------------------------- @@ -123,29 +123,29 @@ A note about CPU models and KVM ------------------------------- =20 Named CPU models generally do not work with KVM. There are a few cases -that do work, e.g. using the named CPU model `cortex-a57` with KVM on a -seattle host, but mostly if KVM is enabled the `host` CPU type must be +that do work, e.g. using the named CPU model ``cortex-a57`` with KVM on a +seattle host, but mostly if KVM is enabled the ``host`` CPU type must be used. This means the guest is provided all the same CPU features as the -host CPU type has. And, for this reason, the `host` CPU type should +host CPU type has. And, for this reason, the ``host`` CPU type should enable all CPU features that the host has by default. Indeed it's even a bit strange to allow disabling CPU features that the host has when using -the `host` CPU type, but in the absence of CPU models it's the best we can +the ``host`` CPU type, but in the absence of CPU models it's the best we c= an do if we want to launch guests without all the host's CPU features enabled. =20 -Enabling KVM also affects the `query-cpu-model-expansion` QMP command. The +Enabling KVM also affects the ``query-cpu-model-expansion`` QMP command. = The affect is not only limited to specific features, as pointed out in example (3) of "CPU Feature Probing", but also to which CPU types may be expanded. -When KVM is enabled, only the `max`, `host`, and current CPU type may be +When KVM is enabled, only the ``max``, ``host``, and current CPU type may = be expanded. This restriction is necessary as it's not possible to know all CPU types that may work with KVM, but it does impose a small risk of users experiencing unexpected errors. For example on a seattle, as mentioned -above, the `cortex-a57` CPU type is also valid when KVM is enabled. -Therefore a user could use the `host` CPU type for the current type, but -then attempt to query `cortex-a57`, however that query will fail with our +above, the ``cortex-a57`` CPU type is also valid when KVM is enabled. +Therefore a user could use the ``host`` CPU type for the current type, but +then attempt to query ``cortex-a57``, however that query will fail with our restrictions. This shouldn't be an issue though as management layers and -users have been preferring the `host` CPU type for use with KVM for quite +users have been preferring the ``host`` CPU type for use with KVM for quite some time. Additionally, if the KVM-enabled QEMU instance running on a -seattle host is using the `cortex-a57` CPU type, then querying `cortex-a57` +seattle host is using the ``cortex-a57`` CPU type, then querying ``cortex-= a57`` will work. =20 Using CPU Features @@ -158,12 +158,12 @@ QEMU command line with that CPU type:: $ qemu-system-aarch64 -M virt -cpu max,pmu=3Doff,sve=3Don,sve128=3Don,sv= e256=3Don =20 The example above disables the PMU and enables the first two SVE vector -lengths for the `max` CPU type. Note, the `sve=3Don` isn't actually -necessary, because, as we observed above with our probe of the `max` CPU -type, `sve` is already on by default. Also, based on our probe of +lengths for the ``max`` CPU type. Note, the ``sve=3Don`` isn't actually +necessary, because, as we observed above with our probe of the ``max`` CPU +type, ``sve`` is already on by default. Also, based on our probe of defaults, it would seem we need to disable many SVE vector lengths, rather than only enabling the two we want. This isn't the case, because, as -disabling many SVE vector lengths would be quite verbose, the `sve` CPU +disabling many SVE vector lengths would be quite verbose, the ``sve`` C= PU properties have special semantics (see "SVE CPU Property Parsing Semantics"). =20 @@ -203,49 +203,49 @@ the list of KVM VCPU features and their descriptions. SVE CPU Properties =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 -There are two types of SVE CPU properties: `sve` and `sve`. The first -is used to enable or disable the entire SVE feature, just as the `pmu` +There are two types of SVE CPU properties: ``sve`` and ``sve``. The fi= rst +is used to enable or disable the entire SVE feature, just as the ``pmu`` CPU property completely enables or disables the PMU. The second type -is used to enable or disable specific vector lengths, where `N` is the -number of bits of the length. The `sve` CPU properties have special +is used to enable or disable specific vector lengths, where ``N`` is the +number of bits of the length. The ``sve`` CPU properties have special dependencies and constraints, see "SVE CPU Property Dependencies and Constraints" below. Additionally, as we want all supported vector lengths to be enabled by default, then, in order to avoid overly verbose command -lines (command lines full of `sve=3Doff`, for all `N` not wanted), we +lines (command lines full of ``sve=3Doff``, for all ``N`` not wanted), = we provide the parsing semantics listed in "SVE CPU Property Parsing Semantics". =20 SVE CPU Property Dependencies and Constraints --------------------------------------------- =20 - 1) At least one vector length must be enabled when `sve` is enabled. + 1) At least one vector length must be enabled when ``sve`` is enabled. =20 - 2) If a vector length `N` is enabled, then, when KVM is enabled, all + 2) If a vector length ``N`` is enabled, then, when KVM is enabled, all smaller, host supported vector lengths must also be enabled. If KVM is not enabled, then only all the smaller, power-of-two vector lengths must be enabled. E.g. with KVM if the host supports all - vector lengths up to 512-bits (128, 256, 384, 512), then if `sve512` + vector lengths up to 512-bits (128, 256, 384, 512), then if ``sve512`` is enabled, the 128-bit vector length, 256-bit vector length, and 384-bit vector length must also be enabled. Without KVM, the 384-bit vector length would not be required. =20 3) If KVM is enabled then only vector lengths that the host CPU type support may be enabled. If SVE is not supported by the host, then - no `sve*` properties may be enabled. + no ``sve*`` properties may be enabled. =20 SVE CPU Property Parsing Semantics ---------------------------------- =20 - 1) If SVE is disabled (`sve=3Doff`), then which SVE vector lengths + 1) If SVE is disabled (``sve=3Doff``), then which SVE vector lengths are enabled or disabled is irrelevant to the guest, as the entire SVE feature is disabled and that disables all vector lengths for - the guest. However QEMU will still track any `sve` CPU - properties provided by the user. If later an `sve=3Don` is provided, - then the guest will get only the enabled lengths. If no `sve=3Don` + the guest. However QEMU will still track any ``sve`` CPU + properties provided by the user. If later an ``sve=3Don`` is provide= d, + then the guest will get only the enabled lengths. If no ``sve=3Don`` is provided and there are explicitly enabled vector lengths, then an error is generated. =20 - 2) If SVE is enabled (`sve=3Don`), but no `sve` CPU properties are + 2) If SVE is enabled (``sve=3Don``), but no ``sve`` CPU properties are provided, then all supported vector lengths are enabled, which when KVM is not in use means including the non-power-of-two lengths, and, when KVM is in use, it means all vector lengths supported by the host @@ -261,7 +261,7 @@ SVE CPU Property Parsing Semantics constraint (2) of "SVE CPU Property Dependencies and Constraints"). =20 5) When KVM is enabled, if the host does not support SVE, then an error - is generated when attempting to enable any `sve*` properties (see + is generated when attempting to enable any ``sve*`` properties (see constraint (3) of "SVE CPU Property Dependencies and Constraints"). =20 6) When KVM is enabled, if the host does support SVE, then an error is @@ -269,8 +269,8 @@ SVE CPU Property Parsing Semantics by the host (see constraint (3) of "SVE CPU Property Dependencies and Constraints"). =20 - 7) If one or more `sve` CPU properties are set `off`, but no `sve`, - CPU properties are set `on`, then the specified vector lengths are + 7) If one or more ``sve`` CPU properties are set ``off``, but no ``sv= e``, + CPU properties are set ``on``, then the specified vector lengths are disabled but the default for any unspecified lengths remains enabled. When KVM is not enabled, disabling a power-of-two vector length also disables all vector lengths larger than the power-of-two length. @@ -278,15 +278,15 @@ SVE CPU Property Parsing Semantics disables all larger vector lengths (see constraint (2) of "SVE CPU Property Dependencies and Constraints"). =20 - 8) If one or more `sve` CPU properties are set to `on`, then they + 8) If one or more ``sve`` CPU properties are set to ``on``, then they are enabled and all unspecified lengths default to disabled, except for the required lengths per constraint (2) of "SVE CPU Property Dependencies and Constraints", which will even be auto-enabled if they were not explicitly enabled. =20 - 9) If SVE was disabled (`sve=3Doff`), allowing all vector lengths to be + 9) If SVE was disabled (``sve=3Doff``), allowing all vector lengths to be explicitly disabled (i.e. avoiding the error specified in (3) of - "SVE CPU Property Parsing Semantics"), then if later an `sve=3Don` is + "SVE CPU Property Parsing Semantics"), then if later an ``sve=3Don`` = is provided an error will be generated. To avoid this error, one must enable at least one vector length prior to enabling SVE. =20 @@ -297,12 +297,12 @@ SVE CPU Property Examples =20 $ qemu-system-aarch64 -M virt -cpu max,sve=3Doff =20 - 2) Implicitly enable all vector lengths for the `max` CPU type:: + 2) Implicitly enable all vector lengths for the ``max`` CPU type:: =20 $ qemu-system-aarch64 -M virt -cpu max =20 3) When KVM is enabled, implicitly enable all host CPU supported vector - lengths with the `host` CPU type:: + lengths with the ``host`` CPU type:: =20 $ qemu-system-aarch64 -M virt,accel=3Dkvm -cpu host =20 diff --git a/docs/system/arm/nuvoton.rst b/docs/system/arm/nuvoton.rst index e3e1a3a3a7..b0a35b54bd 100644 --- a/docs/system/arm/nuvoton.rst +++ b/docs/system/arm/nuvoton.rst @@ -77,7 +77,7 @@ Boot options ------------ =20 The Nuvoton machines can boot from an OpenBMC firmware image, or directly = into -a kernel using the ``-kernel`` option. OpenBMC images for `quanta-gsj` and +a kernel using the ``-kernel`` option. OpenBMC images for ``quanta-gsj`` a= nd possibly others can be downloaded from the OpenPOWER jenkins : =20 https://openpower.xyz/ diff --git a/docs/system/s390x/protvirt.rst b/docs/system/s390x/protvirt.rst index 712974ad87..d208c12a96 100644 --- a/docs/system/s390x/protvirt.rst +++ b/docs/system/s390x/protvirt.rst @@ -14,11 +14,11 @@ Prerequisites To run PVMs, a machine with the Protected Virtualization feature, as indicated by the Ultravisor Call facility (stfle bit 158), is required. The Ultravisor needs to be initialized at boot by setting -`prot_virt=3D1` on the host's kernel command line. +``prot_virt=3D1`` on the host's kernel command line. =20 Running PVMs requires using the KVM hypervisor. =20 -If those requirements are met, the capability `KVM_CAP_S390_PROTECTED` +If those requirements are met, the capability ``KVM_CAP_S390_PROTECTED`` will indicate that KVM can support PVMs on that LPAR. =20 =20 @@ -26,8 +26,8 @@ QEMU Settings ------------- =20 To indicate to the VM that it can transition into protected mode, the -`Unpack facility` (stfle bit 161 represented by the feature -`unpack`/`S390_FEAT_UNPACK`) needs to be part of the cpu model of +``Unpack facility`` (stfle bit 161 represented by the feature +``unpack``/``S390_FEAT_UNPACK``) needs to be part of the cpu model of the VM. =20 All I/O devices need to use the IOMMU. @@ -56,5 +56,5 @@ from the disk boot. This memory layout includes the encry= pted components (kernel, initrd, cmdline), the stage3a loader and metadata. In case this boot method is used, the command line options -initrd and -cmdline are ineffective. The preparation of a PVM -image is done via the `genprotimg` tool from the s390-tools +image is done via the ``genprotimg`` tool from the s390-tools collection. --=20 2.26.2 From nobody Wed May 15 22:57:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600993998; cv=none; d=zohomail.com; s=zohoarc; b=kwx90X86UniC1NGq5mcZR2zSsu1Xfxj0IlcH2CoYTUkuX/Tb2azYh/xPI6bEA3agV0A1lXb1QXMhrjfwmU0NI+3d4wBlwDfUrJgqgHrg4/URvN1Bqce6H8JKt9TrCpZVCDclt9u4dyzb6uPOWA9TMXD226pZ+SG56HSO6S45vjA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600993998; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=JAuWcurd2bQlFa76ujgiI/gh0ag/aedHuk6D4YKnRc0=; b=lawc8OckyQvjoyYxe8LcrllzRuACrpKqrgXKU2q8lvKQw0Dy4kWc4+2e1RpALlNAhifLIUbDUrgJmyDG8dP5z+ZH7xYVqLXIAljolwPICd7UWVTA7ZfwruXwuaz6fGGWZeNLjFQfrq10gHtFfhI8OXfGJXJwMsU8HzETIanqCuw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600993998432132.44124103987667; Thu, 24 Sep 2020 17:33:18 -0700 (PDT) Received: from localhost ([::1]:40688 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLbfo-0002rL-Lr for importer@patchew.org; Thu, 24 Sep 2020 20:33:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50956) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLbbq-0000kO-LM for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:55266) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLbbn-000087-6y for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:10 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-346-Sp_cuZqfOEKX3dhAhDfWug-1; Thu, 24 Sep 2020 20:29:04 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 32736801AAB for ; Fri, 25 Sep 2020 00:29:03 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8D7D25D9F1; Fri, 25 Sep 2020 00:29:02 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600993746; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JAuWcurd2bQlFa76ujgiI/gh0ag/aedHuk6D4YKnRc0=; b=QbUjmHbYnhW5Fmz/w492Q/G0/KNFKcX2fcEGY5PgTfhidVz1C4uKYpfY4twVwp3rlj/CF7 f7JAMp27T2ElwscxxhxwqB9V7964vBJPmU9/HwuudK8+Via95AlwG8SiswVPxByhvPse5K TywwYpKJMrKe71MjqbP2nVTHCLpMqbU= X-MC-Unique: Sp_cuZqfOEKX3dhAhDfWug-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 02/47] [DO-NOT-MERGE] docs: repair broken references Date: Thu, 24 Sep 2020 20:28:15 -0400 Message-Id: <20200925002900.465855-3-jsnow@redhat.com> In-Reply-To: <20200925002900.465855-1-jsnow@redhat.com> References: <20200925002900.465855-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/24 01:10:00 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: John Snow Reviewed-by: Cleber Rosa --- docs/devel/multi-thread-tcg.rst | 2 +- docs/devel/testing.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/devel/multi-thread-tcg.rst b/docs/devel/multi-thread-tcg.= rst index 21483870db..92a9eba13c 100644 --- a/docs/devel/multi-thread-tcg.rst +++ b/docs/devel/multi-thread-tcg.rst @@ -267,7 +267,7 @@ of view of external observers (e.g. another processor c= ore). They can apply to any memory operations as well as just loads or stores. =20 The Linux kernel has an excellent `write-up -` +`_ on the various forms of memory barrier and the guarantees they can provide. =20 diff --git a/docs/devel/testing.rst b/docs/devel/testing.rst index 666c4d7240..f21f3f58eb 100644 --- a/docs/devel/testing.rst +++ b/docs/devel/testing.rst @@ -953,7 +953,7 @@ compiler flags are needed to build for a given target. If you have the ability to run containers as the user you can also take advantage of the build systems "Docker" support. It will then use containers to build any test case for an enabled guest where there is -no system compiler available. See :ref: `_docker-ref` for details. +no system compiler available. See `docker-ref` for details. =20 Running subset of tests ----------------------- --=20 2.26.2 From nobody Wed May 15 22:57:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600993996; cv=none; d=zohomail.com; s=zohoarc; b=E3HanDl/iZB3pZotJGCOQ07Rv9nCHcq4tP4zoP3lxxSoyHNd4oZa8erMxFeJHEewHnUvxHbP+WhYBPkg7g/unA5Nd21i+1uPobTKZaaU+62XuAhKvAoWOjbqlrdGK7pGSN+xtMiGyeBw4tdviRfMRiHlNlEZ4zFJYq0HRl6XXLk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600993996; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IeM04lapevKTHqeknWiyBVqeCQ71OkXYt22/0qzWNxA=; b=R/DSFhWgLkXbwoQT6sIjhgHOGnbTVFdVh/gnNnwhZfO1oLuzDcPsgfq99kt+/p5e9xfnHUf6PWAlj+FUpAeEZCnnibQ7vBFjxsvDRIhpwb8VKm5UWgownno30XUJ6ZTVfxcof0WbHthmJQY4FWSKFISvd6/f4sjwBnnkbzHX+9k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600993996913955.753770369988; Thu, 24 Sep 2020 17:33:16 -0700 (PDT) Received: from localhost ([::1]:40438 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLbfm-0002kD-Qw for importer@patchew.org; Thu, 24 Sep 2020 20:33:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50948) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLbbp-0000kB-Uv for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:09 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:32004) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLbbn-00008K-Ht for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:09 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-216-B_n8Hn6FPf-XsAqkh86iTw-1; Thu, 24 Sep 2020 20:29:04 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EC8DD805EE4 for ; Fri, 25 Sep 2020 00:29:03 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 579735D9F1; Fri, 25 Sep 2020 00:29:03 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600993746; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IeM04lapevKTHqeknWiyBVqeCQ71OkXYt22/0qzWNxA=; b=CssMJh4LJ4ji3jll/ndORV5AivvS0YeN8ydqCsjrNDJrpPomIM3DBdKE6AWKNeL1YSpsme 2lIR2S/KqJucTyTCTEFik9V/CmPw/JRG+byLzaVNaYoHdQyNS7Sldy0kTCPN8rKERV6B4x YSIi80Z4BnNvk9o5N5mOr/VaEDJvHTo= X-MC-Unique: B_n8Hn6FPf-XsAqkh86iTw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 03/47] [DO-NOT-MERGE] docs/sphinx: change default role to "any" Date: Thu, 24 Sep 2020 20:28:16 -0400 Message-Id: <20200925002900.465855-4-jsnow@redhat.com> In-Reply-To: <20200925002900.465855-1-jsnow@redhat.com> References: <20200925002900.465855-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/24 01:10:00 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: John Snow --- docs/conf.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/conf.py b/docs/conf.py index 0dbd90dc11..a68f616d5a 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -81,6 +81,9 @@ # The master toctree document. master_doc =3D 'index' =20 +# Interpret `this` to be a cross-reference to "anything". +default_role =3D 'any' + # General information about the project. project =3D u'QEMU' copyright =3D u'2020, The QEMU Project Developers' --=20 2.26.2 From nobody Wed May 15 22:57:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600994218; cv=none; d=zohomail.com; s=zohoarc; b=a+MvYDv1+VPOGtt6omUQfn6/VjnhyItSEBZ/7sHv73mNgkx1Jkuq/vTUUwrIWWBtC8h1gTH0oyLmjDOhuHql3g67hEJFt9ZOZqTACvKZ2lnRCG3YUyqovFTZYEOimLnERvvH91H5uIz736Y2102sQHR2YRZ2PvbuTXAGMkttgSY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600994218; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IEYyTsPP9nkDV/uKK/aUX06wihmga88s0g6fn1fxzRY=; b=DB5zVob0DUURPqCPQg3ZJUVn9/yhwj2OOo4SQe3j+UA8q8CQ8n36Ub2Jmtn2rnzYaR9PvADjrej1fLCTpUAICjCB+7HhZGbCkeOTvsYdaUxp7urYwfMvj4yLxydpNFV9GoXCvfmb2vf06eFZL6oeiXy/gKjvnagJ3AMK8skLNHc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600994218216261.90085915313045; Thu, 24 Sep 2020 17:36:58 -0700 (PDT) Received: from localhost ([::1]:48948 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLbjM-0006Qd-TP for importer@patchew.org; Thu, 24 Sep 2020 20:36:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51028) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLbbw-0000m5-6Q for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:26106) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLbbo-00008Q-SH for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:15 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-477-3615KZsoPcmAMVhmjkznKA-1; Thu, 24 Sep 2020 20:29:05 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B7F961091066 for ; Fri, 25 Sep 2020 00:29:04 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1EFAE5D9F1; Fri, 25 Sep 2020 00:29:04 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600993747; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IEYyTsPP9nkDV/uKK/aUX06wihmga88s0g6fn1fxzRY=; b=SvgrTjcbC12ddT1+41Ai0xuFbpNDcOQlcJXmU0Map8QSaDVQy1JvqMMK+qkU+6uepxYrnH MIUuOluDlsqVgZg68O4oJ+eJ+heakwf8HSW/nvHjdqrURwsHg+iXE0X+PdS8usSBXNmMqF vpEMZ+XGwjg3m4pNXCUWAoTVAvDgJeg= X-MC-Unique: 3615KZsoPcmAMVhmjkznKA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 04/47] qapi: modify docstrings to be sphinx-compatible Date: Thu, 24 Sep 2020 20:28:17 -0400 Message-Id: <20200925002900.465855-5-jsnow@redhat.com> In-Reply-To: <20200925002900.465855-1-jsnow@redhat.com> References: <20200925002900.465855-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 23:02:20 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" I did not say "sphinx beautiful", just "sphinx compatible". They will not throw errors when parsed and interpreted as ReST. Signed-off-by: John Snow --- scripts/qapi/doc.py | 10 +++++----- scripts/qapi/gen.py | 6 ++++-- scripts/qapi/parser.py | 9 +++++---- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/scripts/qapi/doc.py b/scripts/qapi/doc.py index 92f584edcf..c41e9d29f5 100644 --- a/scripts/qapi/doc.py +++ b/scripts/qapi/doc.py @@ -65,11 +65,11 @@ def texi_format(doc): Format documentation =20 Lines starting with: - - |: generates an @example - - =3D: generates @section - - =3D=3D: generates @subsection - - 1. or 1): generates an @enumerate @item - - */-: generates an @itemize list + - ``|:`` generates an @example + - ``=3D:`` generates @section + - ``=3D=3D:`` generates @subsection + - ``1.`` or ``1):`` generates an @enumerate @item + - ``*/-:`` generates an @itemize list """ ret =3D '' doc =3D subst_braces(doc) diff --git a/scripts/qapi/gen.py b/scripts/qapi/gen.py index bf5552a4e7..3d25a8cff4 100644 --- a/scripts/qapi/gen.py +++ b/scripts/qapi/gen.py @@ -154,9 +154,11 @@ def _bottom(self): =20 @contextmanager def ifcontext(ifcond, *args): - """A 'with' statement context manager to wrap with start_if()/end_if() + """ + A 'with' statement context manager to wrap with start_if()/end_if() =20 - *args: any number of QAPIGenCCode + :param ifcond: List of conditionals + :param args: any number of QAPIGenCCode =20 Example:: =20 diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py index 165925ca72..00738cea8c 100644 --- a/scripts/qapi/parser.py +++ b/scripts/qapi/parser.py @@ -366,10 +366,11 @@ def append(self, line): =20 The way that the line is dealt with depends on which part of the documentation we're parsing right now: - * The body section: ._append_line is ._append_body_line - * An argument section: ._append_line is ._append_args_line - * A features section: ._append_line is ._append_features_line - * An additional section: ._append_line is ._append_various_line + + * The body section: ._append_line is ._append_body_line + * An argument section: ._append_line is ._append_args_line + * A features section: ._append_line is ._append_features_line + * An additional section: ._append_line is ._append_various_line """ line =3D line[1:] if not line: --=20 2.26.2 From nobody Wed May 15 22:57:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600994381; cv=none; d=zohomail.com; s=zohoarc; b=MBlUi09JpfmGOG6ylu9SDToNSEkgwb2/YQ2Q9n9q/AtryY+0m+oIGY29fXkXhWftEbJrcmQTZMlGb+6qeME56/+raGTWbqdSnfXew4OqMDRpGXWD+9aj0RwQ0suiR3JsKOG3NuR+/+OfRTBUD2o5f6UU2SJF7a2hbdGDUgGTSfU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600994381; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vvIQsDwNl+94LSH/6oLoNRcB7oBvAmpNhdtuAr1b5VE=; b=LR9FJ2I738fkd9MJW5t/cx3q4neRg3lYTYXqxumqMN+sM8OHf6zfQv9oG+FuEOdA6lxSrGXU8cX8anh2EBYwiAXdZTbOPzwWJzCANKFRC+1c1oSCnSIZc5Qart+4CbT9pRwDJed/998lF9UBs+jqUHHqQoUM9K7cJKxEEfD29n4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600994381189651.3492086167957; Thu, 24 Sep 2020 17:39:41 -0700 (PDT) Received: from localhost ([::1]:57256 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLblz-0001P3-DB for importer@patchew.org; Thu, 24 Sep 2020 20:39:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51050) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLbbw-0000my-UZ for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:22660) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLbbu-00009I-JZ for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:16 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-318-GLmoNCc-PUmnLyKOAzuYcg-1; Thu, 24 Sep 2020 20:29:06 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 820F36408A for ; Fri, 25 Sep 2020 00:29:05 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id DE1235D9F1; Fri, 25 Sep 2020 00:29:04 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600993753; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vvIQsDwNl+94LSH/6oLoNRcB7oBvAmpNhdtuAr1b5VE=; b=bV2FsxJIqDuDnlyGAQ6uiSpwhkHeemGiWme1XL1N1RbdjIDpczre12vkeIyPlr8IV1qAgN u3XCyYAyRA6MFlsqHmV3bHd1qQDt+R+6gHVqB/AVo2Ezo/2XLj7PjhS18L2sQmxrxnKUQg UdsCyR2U5MT2JS1LqaDkoK6h5XVPM28= X-MC-Unique: GLmoNCc-PUmnLyKOAzuYcg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 05/47] qapi/doc.py: Change code templates from function to string Date: Thu, 24 Sep 2020 20:28:18 -0400 Message-Id: <20200925002900.465855-6-jsnow@redhat.com> In-Reply-To: <20200925002900.465855-1-jsnow@redhat.com> References: <20200925002900.465855-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/24 01:10:00 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" For whatever reason, when these are stored as functions instead of strings, it confuses sphinx-autodoc into believing them to be docstrings, and it chokes on the syntax. Keeping them as dumb strings instead avoids the problem. Signed-off-by: John Snow Reviewed-by: Markus Armbruster --- scripts/qapi/doc.py | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/scripts/qapi/doc.py b/scripts/qapi/doc.py index c41e9d29f5..d12eda9e1e 100644 --- a/scripts/qapi/doc.py +++ b/scripts/qapi/doc.py @@ -8,26 +8,26 @@ from qapi.gen import QAPIGenDoc, QAPISchemaVisitor =20 =20 -MSG_FMT =3D """ +_MSG =3D ''' @deftypefn {type} {{}} {name} =20 {body}{members}{features}{sections} @end deftypefn =20 -""".format +''' =20 -TYPE_FMT =3D """ +_TYPE =3D ''' @deftp {{{type}}} {name} =20 {body}{members}{features}{sections} @end deftp =20 -""".format +''' =20 -EXAMPLE_FMT =3D """@example +_EXAMPLE =3D '''@example {code} @end example -""".format +''' =20 =20 def subst_strong(doc): @@ -57,7 +57,7 @@ def texi_example(doc): # function to subst_special() or subs_texi_special(). If we do that, = we # need to delay it until after subst_vars() in texi_format(). doc =3D subst_braces(doc).strip('\n') - return EXAMPLE_FMT(code=3Ddoc) + return _EXAMPLE.format(code=3Ddoc) =20 =20 def texi_format(doc): @@ -90,7 +90,7 @@ def texi_format(doc): # Make sure to update section "Documentation markup" in # docs/devel/qapi-code-gen.txt when fixing this. if line.startswith('| '): - line =3D EXAMPLE_FMT(code=3Dline[2:]) + line =3D _EXAMPLE.format(code=3Dline[2:]) elif line.startswith('=3D '): line =3D '@section ' + line[2:] elif line.startswith('=3D=3D '): @@ -217,21 +217,21 @@ def texi_sections(doc, ifcond): =20 =20 def texi_type(typ, doc, ifcond, members): - return TYPE_FMT(type=3Dtyp, - name=3Ddoc.symbol, - body=3Dtexi_body(doc), - members=3Dmembers, - features=3Dtexi_features(doc), - sections=3Dtexi_sections(doc, ifcond)) + return _TYPE.format(type=3Dtyp, + name=3Ddoc.symbol, + body=3Dtexi_body(doc), + members=3Dmembers, + features=3Dtexi_features(doc), + sections=3Dtexi_sections(doc, ifcond)) =20 =20 def texi_msg(typ, doc, ifcond, members): - return MSG_FMT(type=3Dtyp, - name=3Ddoc.symbol, - body=3Dtexi_body(doc), - members=3Dmembers, - features=3Dtexi_features(doc), - sections=3Dtexi_sections(doc, ifcond)) + return _MSG.format(type=3Dtyp, + name=3Ddoc.symbol, + body=3Dtexi_body(doc), + members=3Dmembers, + features=3Dtexi_features(doc), + sections=3Dtexi_sections(doc, ifcond)) =20 =20 class QAPISchemaGenDocVisitor(QAPISchemaVisitor): --=20 2.26.2 From nobody Wed May 15 22:57:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600994383; cv=none; d=zohomail.com; s=zohoarc; b=KZmNqFc8ObzDHTYtJ/F/vi3gWLhHDHYD6eRm8AmrgJuKGVXB3nt0avYmoA7uaVN0rNF0VQUrI14cJKs4iCkCr9BZWZ1/AccKVewejbNUcUNQfkvUSNx1JEpSmPdPfPBao3vgmX26ZSMEUlH6OlOrEkgfdUYntvjp1CwYwTEYzss= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600994383; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=70wmEGCw8tkrUgTGDon2oVro9iXJxI9XDN1PeT2SQmo=; b=NYSKu4nfFDtd7jbRoPpv1VZYHM9u//efcYP+L4vYRrhKAMA8zB9mpiEcMVp6ecCDf/S070aWP6SKdpoPHweYMchmVd1ZMUZEtHVj1uFom90FJf4poSrCEvQFzSRyIYMHCC1AGovnuLkEbst1g5W2toD3L8gaA6pWtZbfRP6OoWs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600994382996877.4564025113337; Thu, 24 Sep 2020 17:39:42 -0700 (PDT) Received: from localhost ([::1]:57476 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLbm1-0001UO-MC for importer@patchew.org; Thu, 24 Sep 2020 20:39:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51054) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLbbx-0000nG-4G for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:28087) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLbbu-00009M-Iu for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:16 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-211--h3Gf3quPWa7POw79jnoSg-1; Thu, 24 Sep 2020 20:29:07 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4C5311008548 for ; Fri, 25 Sep 2020 00:29:06 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id A8C1A5D9DD; Fri, 25 Sep 2020 00:29:05 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600993753; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=70wmEGCw8tkrUgTGDon2oVro9iXJxI9XDN1PeT2SQmo=; b=CJ3SSxv8CnFX/5rrV4U8iAkdYGB+rbdkGEO3Wsq0c/S6aDfLqqQW41Lo04rplb+10tiogP etzk9W4p+OVeIX1c5jBomdzJKGIFCMCOV12gCCpNOEjVbPIeC/T4yuFZrjRK3E6F/1nMr5 3oBOxhNaUCnBVGxmbgEg/b/L361wvQ4= X-MC-Unique: -h3Gf3quPWa7POw79jnoSg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 06/47] [DO-NOT-MERGE] docs: enable sphinx-autodoc for scripts/qapi Date: Thu, 24 Sep 2020 20:28:19 -0400 Message-Id: <20200925002900.465855-7-jsnow@redhat.com> In-Reply-To: <20200925002900.465855-1-jsnow@redhat.com> References: <20200925002900.465855-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 23:02:20 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: John Snow --- docs/conf.py | 6 +++++- docs/devel/index.rst | 1 + docs/devel/python/index.rst | 7 +++++++ docs/devel/python/qapi.commands.rst | 7 +++++++ docs/devel/python/qapi.common.rst | 7 +++++++ docs/devel/python/qapi.doc.rst | 7 +++++++ docs/devel/python/qapi.error.rst | 7 +++++++ docs/devel/python/qapi.events.rst | 7 +++++++ docs/devel/python/qapi.expr.rst | 7 +++++++ docs/devel/python/qapi.gen.rst | 7 +++++++ docs/devel/python/qapi.introspect.rst | 7 +++++++ docs/devel/python/qapi.parser.rst | 8 ++++++++ docs/devel/python/qapi.rst | 26 ++++++++++++++++++++++++++ docs/devel/python/qapi.schema.rst | 7 +++++++ docs/devel/python/qapi.source.rst | 7 +++++++ docs/devel/python/qapi.types.rst | 7 +++++++ docs/devel/python/qapi.visit.rst | 7 +++++++ 17 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 docs/devel/python/index.rst create mode 100644 docs/devel/python/qapi.commands.rst create mode 100644 docs/devel/python/qapi.common.rst create mode 100644 docs/devel/python/qapi.doc.rst create mode 100644 docs/devel/python/qapi.error.rst create mode 100644 docs/devel/python/qapi.events.rst create mode 100644 docs/devel/python/qapi.expr.rst create mode 100644 docs/devel/python/qapi.gen.rst create mode 100644 docs/devel/python/qapi.introspect.rst create mode 100644 docs/devel/python/qapi.parser.rst create mode 100644 docs/devel/python/qapi.rst create mode 100644 docs/devel/python/qapi.schema.rst create mode 100644 docs/devel/python/qapi.source.rst create mode 100644 docs/devel/python/qapi.types.rst create mode 100644 docs/devel/python/qapi.visit.rst diff --git a/docs/conf.py b/docs/conf.py index a68f616d5a..d03ef465a6 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -54,6 +54,9 @@ # sys.path.insert(0, os.path.join(qemu_docdir, "sphinx")) =20 +# Make scripts/qapi module available for autodoc +sys.path.insert(0, os.path.join(qemu_docdir, "../scripts")) + =20 # -- General configuration ------------------------------------------------ =20 @@ -67,7 +70,8 @@ # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. -extensions =3D ['kerneldoc', 'qmp_lexer', 'hxtool', 'depfile'] +extensions =3D ['kerneldoc', 'qmp_lexer', 'hxtool', + 'depfile', 'sphinx.ext.autodoc'] =20 # Add any paths that contain templates here, relative to this directory. templates_path =3D ['_templates'] diff --git a/docs/devel/index.rst b/docs/devel/index.rst index 04773ce076..04726ca787 100644 --- a/docs/devel/index.rst +++ b/docs/devel/index.rst @@ -31,3 +31,4 @@ Contents: reset s390-dasd-ipl clocks + python/index diff --git a/docs/devel/python/index.rst b/docs/devel/python/index.rst new file mode 100644 index 0000000000..31c470154b --- /dev/null +++ b/docs/devel/python/index.rst @@ -0,0 +1,7 @@ +qapi +=3D=3D=3D=3D + +.. toctree:: + :maxdepth: 4 + + qapi diff --git a/docs/devel/python/qapi.commands.rst b/docs/devel/python/qapi.c= ommands.rst new file mode 100644 index 0000000000..018f7b08a9 --- /dev/null +++ b/docs/devel/python/qapi.commands.rst @@ -0,0 +1,7 @@ +qapi.commands module +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +.. automodule:: qapi.commands + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/devel/python/qapi.common.rst b/docs/devel/python/qapi.com= mon.rst new file mode 100644 index 0000000000..128a90d74b --- /dev/null +++ b/docs/devel/python/qapi.common.rst @@ -0,0 +1,7 @@ +qapi.common module +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +.. automodule:: qapi.common + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/devel/python/qapi.doc.rst b/docs/devel/python/qapi.doc.rst new file mode 100644 index 0000000000..556c2bca1f --- /dev/null +++ b/docs/devel/python/qapi.doc.rst @@ -0,0 +1,7 @@ +qapi.doc module +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +.. automodule:: qapi.doc + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/devel/python/qapi.error.rst b/docs/devel/python/qapi.erro= r.rst new file mode 100644 index 0000000000..980e32b63d --- /dev/null +++ b/docs/devel/python/qapi.error.rst @@ -0,0 +1,7 @@ +qapi.error module +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +.. automodule:: qapi.error + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/devel/python/qapi.events.rst b/docs/devel/python/qapi.eve= nts.rst new file mode 100644 index 0000000000..1fce85b044 --- /dev/null +++ b/docs/devel/python/qapi.events.rst @@ -0,0 +1,7 @@ +qapi.events module +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +.. automodule:: qapi.events + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/devel/python/qapi.expr.rst b/docs/devel/python/qapi.expr.= rst new file mode 100644 index 0000000000..0660270629 --- /dev/null +++ b/docs/devel/python/qapi.expr.rst @@ -0,0 +1,7 @@ +qapi.expr module +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +.. automodule:: qapi.expr + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/devel/python/qapi.gen.rst b/docs/devel/python/qapi.gen.rst new file mode 100644 index 0000000000..7b495fd4bf --- /dev/null +++ b/docs/devel/python/qapi.gen.rst @@ -0,0 +1,7 @@ +qapi.gen module +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +.. automodule:: qapi.gen + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/devel/python/qapi.introspect.rst b/docs/devel/python/qapi= .introspect.rst new file mode 100644 index 0000000000..f65ebfccd1 --- /dev/null +++ b/docs/devel/python/qapi.introspect.rst @@ -0,0 +1,7 @@ +qapi.introspect module +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +.. automodule:: qapi.introspect + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/devel/python/qapi.parser.rst b/docs/devel/python/qapi.par= ser.rst new file mode 100644 index 0000000000..1a8f7b347e --- /dev/null +++ b/docs/devel/python/qapi.parser.rst @@ -0,0 +1,8 @@ +qapi.parser module +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +.. automodule:: qapi.parser + :members: + :undoc-members: + :show-inheritance: + :private-members: diff --git a/docs/devel/python/qapi.rst b/docs/devel/python/qapi.rst new file mode 100644 index 0000000000..24fbf34981 --- /dev/null +++ b/docs/devel/python/qapi.rst @@ -0,0 +1,26 @@ +qapi package +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +.. automodule:: qapi + :members: + :undoc-members: + :show-inheritance: + +Submodules +---------- + +.. toctree:: + + qapi.commands + qapi.common + qapi.doc + qapi.error + qapi.events + qapi.expr + qapi.gen + qapi.introspect + qapi.parser + qapi.schema + qapi.source + qapi.types + qapi.visit diff --git a/docs/devel/python/qapi.schema.rst b/docs/devel/python/qapi.sch= ema.rst new file mode 100644 index 0000000000..a08f75ed72 --- /dev/null +++ b/docs/devel/python/qapi.schema.rst @@ -0,0 +1,7 @@ +qapi.schema module +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +.. automodule:: qapi.schema + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/devel/python/qapi.source.rst b/docs/devel/python/qapi.sou= rce.rst new file mode 100644 index 0000000000..e61e9f6021 --- /dev/null +++ b/docs/devel/python/qapi.source.rst @@ -0,0 +1,7 @@ +qapi.source module +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +.. automodule:: qapi.source + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/devel/python/qapi.types.rst b/docs/devel/python/qapi.type= s.rst new file mode 100644 index 0000000000..6eea827557 --- /dev/null +++ b/docs/devel/python/qapi.types.rst @@ -0,0 +1,7 @@ +qapi.types module +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +.. automodule:: qapi.types + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/devel/python/qapi.visit.rst b/docs/devel/python/qapi.visi= t.rst new file mode 100644 index 0000000000..84307cbc23 --- /dev/null +++ b/docs/devel/python/qapi.visit.rst @@ -0,0 +1,7 @@ +qapi.visit module +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +.. automodule:: qapi.visit + :members: + :undoc-members: + :show-inheritance: --=20 2.26.2 From nobody Wed May 15 22:57:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600993999; cv=none; d=zohomail.com; s=zohoarc; b=Izozz+9/hYyZHKjKsTjbuMDwFO2Wr4I/+hjJBx+XkzxvVJIiidaplSgAG8ziRiAs50XYQ7mYIMXTlYjw/RWkHvFkQ08jyT5+xtgsqZVr4Th4B9aQK5ntqBrhXOe33EIbKiCsCsDcPQMDIckwVIvJuBkynah3hcHoARv/PDDBuCE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600993999; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=t8U8C4CXg32323bNC83EyuM3sRWhcXArgZlCoK1zzr8=; b=E6xZC0Mwoy/UJf2CFC69n2Zg0/lkPnm+PiXB9Rl14ReucgVphUkl5b139jf110OEUGGpf/AI8USt9X3PJg9XE7KVUiIR5lsIz0+lZpCkTehDrkOQCLzvaW4xI768SzyrVCRh0UxcAfhHWRIKQumaM7bU4qzFf4iLe+/ccCsGENY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600993999017293.3228729288645; Thu, 24 Sep 2020 17:33:19 -0700 (PDT) Received: from localhost ([::1]:40864 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLbfp-0002vt-D8 for importer@patchew.org; Thu, 24 Sep 2020 20:33:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50992) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLbbu-0000kc-Tl for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:14 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:20442) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLbbr-00008v-Ia for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:14 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-91-hiqPrKsIMXaAUdb7oP80Hw-1; Thu, 24 Sep 2020 20:29:08 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1A9DA81F007 for ; Fri, 25 Sep 2020 00:29:07 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 740CC5D9DD; Fri, 25 Sep 2020 00:29:06 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600993751; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=t8U8C4CXg32323bNC83EyuM3sRWhcXArgZlCoK1zzr8=; b=KnNphjWadWlLna3bBY0oGbLuoJM/xxcKeP+fM7pCqrLaR13wc53tbAugKc5OdYudxpaXG9 C7q5NiftZTdtWmA0TNCTMka+stla0T6xozWWJ5t85FUSgXEOBFyiSkFqKOrVqEKjQPp8P2 TB1YC6PRtgh6ANApWQ52Z8dt401wj40= X-MC-Unique: hiqPrKsIMXaAUdb7oP80Hw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 07/47] qapi-gen: Separate arg-parsing from generation Date: Thu, 24 Sep 2020 20:28:20 -0400 Message-Id: <20200925002900.465855-8-jsnow@redhat.com> In-Reply-To: <20200925002900.465855-1-jsnow@redhat.com> References: <20200925002900.465855-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 23:02:20 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This is a minor re-work of the entrypoint script. It isolates a generate() method from the actual command-line mechanism. The regex match error checking was modified slightly to check that we actually got a regex match. Signed-off-by: John Snow Reviewed-by: Eduardo Habkost Reviewed-by: Cleber Rosa Tested-by: Cleber Rosa --- scripts/qapi-gen.py | 87 ++++++++++++++++++++++++++++++++------------- 1 file changed, 63 insertions(+), 24 deletions(-) diff --git a/scripts/qapi-gen.py b/scripts/qapi-gen.py index 4b03f7d53b..59becba3e1 100644 --- a/scripts/qapi-gen.py +++ b/scripts/qapi-gen.py @@ -1,9 +1,13 @@ #!/usr/bin/env python3 -# QAPI generator -# + # This work is licensed under the terms of the GNU GPL, version 2 or later. # See the COPYING file in the top-level directory. =20 +""" +QAPI Generator + +This script is the main entry point for generating C code from the QAPI sc= hema. +""" =20 import argparse import re @@ -11,21 +15,65 @@ =20 from qapi.commands import gen_commands from qapi.doc import gen_doc +from qapi.error import QAPIError from qapi.events import gen_events from qapi.introspect import gen_introspect -from qapi.schema import QAPIError, QAPISchema +from qapi.schema import QAPISchema from qapi.types import gen_types from qapi.visit import gen_visit =20 =20 -def main(argv): +DEFAULT_OUTPUT_DIR =3D '' +DEFAULT_PREFIX =3D '' + + +def generate(schema_file: str, + output_dir: str, + prefix: str, + unmask: bool =3D False, + builtins: bool =3D False) -> None: + """ + generate uses a given schema to produce C code in the target directory. + + :param schema_file: The primary QAPI schema file. + :param output_dir: The output directory to store generated code. + :param prefix: Optional C-code prefix for symbol names. + :param unmask: Expose non-ABI names through introspection? + :param builtins: Generate code for built-in types? + + :raise QAPIError: On failures. + """ + match =3D re.match(r'([A-Za-z_.-][A-Za-z0-9_.-]*)?', prefix) + if match and match.end() !=3D len(prefix): + msg =3D "funny character '{:s}' in prefix '{:s}'".format( + prefix[match.end()], prefix) + raise QAPIError('', None, msg) + + schema =3D QAPISchema(schema_file) + gen_types(schema, output_dir, prefix, builtins) + gen_visit(schema, output_dir, prefix, builtins) + gen_commands(schema, output_dir, prefix) + gen_events(schema, output_dir, prefix) + gen_introspect(schema, output_dir, prefix, unmask) + gen_doc(schema, output_dir, prefix) + + +def main() -> int: + """ + gapi-gen shell script entrypoint. + Expects arguments via sys.argv, see --help for details. + + :return: int, 0 on success, 1 on failure. + """ parser =3D argparse.ArgumentParser( description=3D'Generate code from a QAPI schema') parser.add_argument('-b', '--builtins', action=3D'store_true', help=3D"generate code for built-in types") - parser.add_argument('-o', '--output-dir', action=3D'store', default=3D= '', + parser.add_argument('-o', '--output-dir', action=3D'store', + default=3DDEFAULT_OUTPUT_DIR, help=3D"write output to directory OUTPUT_DIR") - parser.add_argument('-p', '--prefix', action=3D'store', default=3D'', + parser.add_argument('-p', '--prefix', action=3D'store', + default=3DDEFAULT_PREFIX, help=3D"prefix for symbols") parser.add_argument('-u', '--unmask-non-abi-names', action=3D'store_tr= ue', dest=3D'unmask', @@ -33,26 +81,17 @@ def main(argv): parser.add_argument('schema', action=3D'store') args =3D parser.parse_args() =20 - match =3D re.match(r'([A-Za-z_.-][A-Za-z0-9_.-]*)?', args.prefix) - if match.end() !=3D len(args.prefix): - print("%s: 'funny character '%s' in argument of --prefix" - % (sys.argv[0], args.prefix[match.end()]), - file=3Dsys.stderr) - sys.exit(1) - try: - schema =3D QAPISchema(args.schema) + generate(args.schema, + output_dir=3Dargs.output_dir, + prefix=3Dargs.prefix, + unmask=3Dargs.unmask, + builtins=3Dargs.builtins) except QAPIError as err: - print(err, file=3Dsys.stderr) - exit(1) - - gen_types(schema, args.output_dir, args.prefix, args.builtins) - gen_visit(schema, args.output_dir, args.prefix, args.builtins) - gen_commands(schema, args.output_dir, args.prefix) - gen_events(schema, args.output_dir, args.prefix) - gen_introspect(schema, args.output_dir, args.prefix, args.unmask) - gen_doc(schema, args.output_dir, args.prefix) + print(f"{sys.argv[0]}: {str(err)}", file=3Dsys.stderr) + return 1 + return 0 =20 =20 if __name__ =3D=3D '__main__': - main(sys.argv) + sys.exit(main()) --=20 2.26.2 From nobody Wed May 15 22:57:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600994222; cv=none; d=zohomail.com; s=zohoarc; b=FB08x79Nv+knqU+WOVujFHtTgodXt3H+FexMzDae0yUPI8X1Qf2oRlLoM6en9xso7fecnTiudRWX1i5jj4ZwKleJxDrBHHiBwZSp0gula+nWa2BJGE5+Tb+JpKthsz+AJ28ri6iTsqMAovjMc72OQeieVI9HwJ3rtTSDH0JkvhQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600994222; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=uDqJTuCfJxOa0dgmgjeRYR5P+BlDQHtVZccRyQiHsNk=; b=LznuE34EG3XpNCH1ed/5g4KDHTS4aJdSmNiYuv7AYCqSb3ypxPntygwfrqUNerCs54pAcsFOj0KRr7bAWZUo4oxwxxs36TRmAEqd58tVQjesIWfm991Jk3ASdB4FHs6V2yNa4W7w/VFSSnpC2vLtavJJCeX6ALHFpO6ljPrTcE8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600994222946694.3147224702435; Thu, 24 Sep 2020 17:37:02 -0700 (PDT) Received: from localhost ([::1]:49254 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLbjR-0006Xt-Kn for importer@patchew.org; Thu, 24 Sep 2020 20:37:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51006) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLbbv-0000kz-CC for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:37570) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLbbr-00008y-Nv for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:15 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-101-6tyvb7shOtWBxAwqkUe0fg-1; Thu, 24 Sep 2020 20:29:09 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 36A821091073 for ; Fri, 25 Sep 2020 00:29:08 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 423025D9DD; Fri, 25 Sep 2020 00:29:07 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600993751; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uDqJTuCfJxOa0dgmgjeRYR5P+BlDQHtVZccRyQiHsNk=; b=hP4C/hY+sogy0VzJTDGZKARbohwgrcvZEwDJQss+z6pDePFLERkoMBczcd/rhFi74cE44G cMUbMVsgjwNoH2qScz4DG9EMcwC/JzW5FxsuR5iS79GX7FjVA2eS8EAhufaJYnyX2eOopB q7Bgfih8GHI0QHMT/bUAQXS85RW1iOM= X-MC-Unique: 6tyvb7shOtWBxAwqkUe0fg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 08/47] qapi: move generator entrypoint into module Date: Thu, 24 Sep 2020 20:28:21 -0400 Message-Id: <20200925002900.465855-9-jsnow@redhat.com> In-Reply-To: <20200925002900.465855-1-jsnow@redhat.com> References: <20200925002900.465855-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 23:02:20 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" As part of delinting and adding type hints to the QAPI generator, it's helpful for the entrypoint to be part of the package, only leaving a very tiny entrypoint shim outside of the module. Signed-off-by: John Snow Reviewed-by: Eduardo Habkost Reviewed-by: Cleber Rosa Tested-by: Cleber Rosa --- scripts/qapi-gen.py | 90 +++---------------------------------------- scripts/qapi/main.py | 91 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+), 84 deletions(-) create mode 100644 scripts/qapi/main.py diff --git a/scripts/qapi-gen.py b/scripts/qapi-gen.py index 59becba3e1..f3518d29a5 100644 --- a/scripts/qapi-gen.py +++ b/scripts/qapi-gen.py @@ -4,94 +4,16 @@ # See the COPYING file in the top-level directory. =20 """ -QAPI Generator +QAPI code generation execution shim. =20 -This script is the main entry point for generating C code from the QAPI sc= hema. +This standalone script exists primarily to facilitate the running of the Q= API +code generator without needing to install the python module to the current +execution environment. """ =20 -import argparse -import re import sys =20 -from qapi.commands import gen_commands -from qapi.doc import gen_doc -from qapi.error import QAPIError -from qapi.events import gen_events -from qapi.introspect import gen_introspect -from qapi.schema import QAPISchema -from qapi.types import gen_types -from qapi.visit import gen_visit - - -DEFAULT_OUTPUT_DIR =3D '' -DEFAULT_PREFIX =3D '' - - -def generate(schema_file: str, - output_dir: str, - prefix: str, - unmask: bool =3D False, - builtins: bool =3D False) -> None: - """ - generate uses a given schema to produce C code in the target directory. - - :param schema_file: The primary QAPI schema file. - :param output_dir: The output directory to store generated code. - :param prefix: Optional C-code prefix for symbol names. - :param unmask: Expose non-ABI names through introspection? - :param builtins: Generate code for built-in types? - - :raise QAPIError: On failures. - """ - match =3D re.match(r'([A-Za-z_.-][A-Za-z0-9_.-]*)?', prefix) - if match and match.end() !=3D len(prefix): - msg =3D "funny character '{:s}' in prefix '{:s}'".format( - prefix[match.end()], prefix) - raise QAPIError('', None, msg) - - schema =3D QAPISchema(schema_file) - gen_types(schema, output_dir, prefix, builtins) - gen_visit(schema, output_dir, prefix, builtins) - gen_commands(schema, output_dir, prefix) - gen_events(schema, output_dir, prefix) - gen_introspect(schema, output_dir, prefix, unmask) - gen_doc(schema, output_dir, prefix) - - -def main() -> int: - """ - gapi-gen shell script entrypoint. - Expects arguments via sys.argv, see --help for details. - - :return: int, 0 on success, 1 on failure. - """ - parser =3D argparse.ArgumentParser( - description=3D'Generate code from a QAPI schema') - parser.add_argument('-b', '--builtins', action=3D'store_true', - help=3D"generate code for built-in types") - parser.add_argument('-o', '--output-dir', action=3D'store', - default=3DDEFAULT_OUTPUT_DIR, - help=3D"write output to directory OUTPUT_DIR") - parser.add_argument('-p', '--prefix', action=3D'store', - default=3DDEFAULT_PREFIX, - help=3D"prefix for symbols") - parser.add_argument('-u', '--unmask-non-abi-names', action=3D'store_tr= ue', - dest=3D'unmask', - help=3D"expose non-ABI names in introspection") - parser.add_argument('schema', action=3D'store') - args =3D parser.parse_args() - - try: - generate(args.schema, - output_dir=3Dargs.output_dir, - prefix=3Dargs.prefix, - unmask=3Dargs.unmask, - builtins=3Dargs.builtins) - except QAPIError as err: - print(f"{sys.argv[0]}: {str(err)}", file=3Dsys.stderr) - return 1 - return 0 - +from qapi import main =20 if __name__ =3D=3D '__main__': - sys.exit(main()) + sys.exit(main.main()) diff --git a/scripts/qapi/main.py b/scripts/qapi/main.py new file mode 100644 index 0000000000..18c246bbb4 --- /dev/null +++ b/scripts/qapi/main.py @@ -0,0 +1,91 @@ +# This work is licensed under the terms of the GNU GPL, version 2 or later. +# See the COPYING file in the top-level directory. + +""" +QAPI Generator + +This is the main entry point for generating C code from the QAPI schema. +""" + +import argparse +import re +import sys + +from qapi.commands import gen_commands +from qapi.doc import gen_doc +from qapi.error import QAPIError +from qapi.events import gen_events +from qapi.introspect import gen_introspect +from qapi.schema import QAPISchema +from qapi.types import gen_types +from qapi.visit import gen_visit + + +DEFAULT_OUTPUT_DIR =3D '' +DEFAULT_PREFIX =3D '' + + +def generate(schema_file: str, + output_dir: str, + prefix: str, + unmask: bool =3D False, + builtins: bool =3D False) -> None: + """ + generate uses a given schema to produce C code in the target directory. + + :param schema_file: The primary QAPI schema file. + :param output_dir: The output directory to store generated code. + :param prefix: Optional C-code prefix for symbol names. + :param unmask: Expose non-ABI names through introspection? + :param builtins: Generate code for built-in types? + + :raise QAPIError: On failures. + """ + match =3D re.match(r'([A-Za-z_.-][A-Za-z0-9_.-]*)?', prefix) + if match and match.end() !=3D len(prefix): + msg =3D "funny character '{:s}' in prefix '{:s}'".format( + prefix[match.end()], prefix) + raise QAPIError('', None, msg) + + schema =3D QAPISchema(schema_file) + gen_types(schema, output_dir, prefix, builtins) + gen_visit(schema, output_dir, prefix, builtins) + gen_commands(schema, output_dir, prefix) + gen_events(schema, output_dir, prefix) + gen_introspect(schema, output_dir, prefix, unmask) + gen_doc(schema, output_dir, prefix) + + +def main() -> int: + """ + gapi-gen shell script entrypoint. + Expects arguments via sys.argv, see --help for details. + + :return: int, 0 on success, 1 on failure. + """ + parser =3D argparse.ArgumentParser( + description=3D'Generate code from a QAPI schema') + parser.add_argument('-b', '--builtins', action=3D'store_true', + help=3D"generate code for built-in types") + parser.add_argument('-o', '--output-dir', action=3D'store', + default=3DDEFAULT_OUTPUT_DIR, + help=3D"write output to directory OUTPUT_DIR") + parser.add_argument('-p', '--prefix', action=3D'store', + default=3DDEFAULT_PREFIX, + help=3D"prefix for symbols") + parser.add_argument('-u', '--unmask-non-abi-names', action=3D'store_tr= ue', + dest=3D'unmask', + help=3D"expose non-ABI names in introspection") + parser.add_argument('schema', action=3D'store') + args =3D parser.parse_args() + + try: + generate(args.schema, + output_dir=3Dargs.output_dir, + prefix=3Dargs.prefix, + unmask=3Dargs.unmask, + builtins=3Dargs.builtins) + except QAPIError as err: + print(f"{sys.argv[0]}: {str(err)}", file=3Dsys.stderr) + return 1 + return 0 --=20 2.26.2 From nobody Wed May 15 22:57:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600994566; cv=none; d=zohomail.com; s=zohoarc; b=AcI4hNEOmWy40Lb1JJWgsOKS5ArbvoldPn2qt9lapJwrbODuuujfQoe1ofR0n+jcZ85Evxo9f1aNqFpKPZXLO8LdLZPJn8LSeS6Bkb4N/kFjBS3khIzk1aMQl1onKeHQjZtn5HywJ57uUf6VUuFXqH8bkm+MbH8cj0/WqsdGwrE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600994566; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tX78Gui1r8r8XVVk/jpqqfWFRjIABe5ZP6Kta4p10bE=; b=Nb9/yx1Ba5R5Y3jUVc+VcynNem6F0wY+XkC4bLsNDI8h0MN+hEJLsIae7CcfyM4NdnF8WkftMK89Xpc3HDxIgwJZx5zIKVLlQupcmBJgDjJpu1Zx5+jR8jYpg6kcdrzYFlyPVoYPU9jzkQSxUtOTo+p+y1hMtxKRYTqLrBTzfuc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600994566940458.1453073691963; Thu, 24 Sep 2020 17:42:46 -0700 (PDT) Received: from localhost ([::1]:37316 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLboz-0004tK-In for importer@patchew.org; Thu, 24 Sep 2020 20:42:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51062) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLbbx-0000nk-Dd for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:59223) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLbbu-000097-IX for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:17 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-529-6elhsRd4OBKOAceaYP-y1A-1; Thu, 24 Sep 2020 20:29:10 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9C1D41091062 for ; Fri, 25 Sep 2020 00:29:09 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7DADD5D9DD; Fri, 25 Sep 2020 00:29:08 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600993752; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tX78Gui1r8r8XVVk/jpqqfWFRjIABe5ZP6Kta4p10bE=; b=MfYexGgrLg2waOlyTw+oTnWN7K6JPcz225I70nY/WQ40WlYG5sTzWPBeyZOJ7zhji7DrpV xhCuTb0chKO9w44DQiQnYS9q1yKHLWDxIeAswc/olcdJIrO2oguLz+pFpEkCyJD+RCGapY 0epcM8RAg+7MnlI49VZHWdgJECTwzPw= X-MC-Unique: 6elhsRd4OBKOAceaYP-y1A-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 09/47] [DO-NOT-MERGE] docs: add scripts/qapi/main to python manual Date: Thu, 24 Sep 2020 20:28:22 -0400 Message-Id: <20200925002900.465855-10-jsnow@redhat.com> In-Reply-To: <20200925002900.465855-1-jsnow@redhat.com> References: <20200925002900.465855-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 23:02:20 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: John Snow --- docs/devel/python/qapi.main.rst | 7 +++++++ docs/devel/python/qapi.rst | 1 + 2 files changed, 8 insertions(+) create mode 100644 docs/devel/python/qapi.main.rst diff --git a/docs/devel/python/qapi.main.rst b/docs/devel/python/qapi.main.= rst new file mode 100644 index 0000000000..1255fcda63 --- /dev/null +++ b/docs/devel/python/qapi.main.rst @@ -0,0 +1,7 @@ +qapi.main module +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +.. automodule:: qapi.main + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/devel/python/qapi.rst b/docs/devel/python/qapi.rst index 24fbf34981..1d73509e98 100644 --- a/docs/devel/python/qapi.rst +++ b/docs/devel/python/qapi.rst @@ -19,6 +19,7 @@ Submodules qapi.expr qapi.gen qapi.introspect + qapi.main qapi.parser qapi.schema qapi.source --=20 2.26.2 From nobody Wed May 15 22:57:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600994819; cv=none; d=zohomail.com; s=zohoarc; b=VvInheHu3CFt4a6NsQgOeiixMdALTIzaCINRn6+vnzBJpm+j5AORU8Ih+aGUbxRAlMEuFgie+pti0N8ev6EjbCAvvke4PTyJBWOqdUODgThjy3pRSXC3cEFrw0aKevV/IgDSP/HDRiRh0txhWXpxK9cRM6wW+3QKxueQaYNKDiQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600994819; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XBSqE+opm+aIyVTm4B6tgJWmGKe1lqAup8qByI8y/+Q=; b=XED/E4yQoOCtEOA3YUAQ+mxHq55w4XmQM+ugqrwPMCPB0xhe/z2TzLKz+P8PXMMvvbJ7JB5kmAZCDggl/6nxFGNjCavIhW4XajB+QtfmOqPkPLvBoUxGGrHSFZY7fFQoAgbYpw7ZxQmv0KaXVBAhybRv9WJF3yiMBlgGQ5YCLas= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600994819054573.8839191318011; Thu, 24 Sep 2020 17:46:59 -0700 (PDT) Received: from localhost ([::1]:49148 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLbt3-0001SK-L2 for importer@patchew.org; Thu, 24 Sep 2020 20:46:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51096) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLbbz-0000rt-75 for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:28037) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLbbu-00009Q-QZ for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:18 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-249-ERnVmA4tPI-DTvjQ-fsRDA-1; Thu, 24 Sep 2020 20:29:11 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 66EDC801002 for ; Fri, 25 Sep 2020 00:29:10 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id C2B8E5D9DD; Fri, 25 Sep 2020 00:29:09 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600993754; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XBSqE+opm+aIyVTm4B6tgJWmGKe1lqAup8qByI8y/+Q=; b=RZCspB+Luv6pFWKXXVSMWbE/YeP4Xk2SyM14/sX4ZRKV71iNM3iLRN/1Rl8M+R3BqGtQnw g4AI21orV2keETNydiR3+cnN7W9w26e4QBp+oRRJj8KJznYWS2oasyPvG+ZSjgjc8NBxVp wnRIjLbgenT0qQzfEax15S1XuT/NNvM= X-MC-Unique: ERnVmA4tPI-DTvjQ-fsRDA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 10/47] qapi: Prefer explicit relative imports Date: Thu, 24 Sep 2020 20:28:23 -0400 Message-Id: <20200925002900.465855-11-jsnow@redhat.com> In-Reply-To: <20200925002900.465855-1-jsnow@redhat.com> References: <20200925002900.465855-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 23:02:20 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" All of the QAPI include statements are changed to be package-aware, as explicit relative imports. A quirk of Python packages is that the name of the package exists only *outside* of the package. This means that to a module inside of the qapi folder, there is inherently no such thing as the "qapi" package. The reason these imports work is because the "qapi" package exists in the context of the caller -- the execution shim, where sys.path includes a directory that has a 'qapi' folder in it. When we write "from qapi import sibling", we are NOT referencing the folder 'qapi', but rather "any package named qapi in sys.path". If you should so happen to have a 'qapi' package in your path, it will use *that* package. When we write "from .sibling import foo", we always reference explicitly our sibling module; guaranteeing consistency in *where* we are importing these modules from. This can be useful when working with virtual environments and packages in development mode. In development mode, a package is installed as a series of symlinks that forwards to your same source files. The problem arises because code quality checkers will follow "import qapi.x" to the "installed" version instead of the sibling file and -- even though they are the same file -- they have different module paths, and this causes cyclic import problems, false positive type mismatch errors, and more. It can also be useful when dealing with hierarchical packages, e.g. if we allow qemu.core.qmp, qemu.qapi.parser, etc. Signed-off-by: John Snow Reviewed-by: Eduardo Habkost Reviewed-by: Cleber Rosa --- 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/main.py | 16 ++++++++-------- scripts/qapi/parser.py | 4 ++-- scripts/qapi/schema.py | 8 ++++---- scripts/qapi/types.py | 6 +++--- scripts/qapi/visit.py | 6 +++--- 11 files changed, 35 insertions(+), 35 deletions(-) diff --git a/scripts/qapi/commands.py b/scripts/qapi/commands.py index 3cf9e1110b..ce5926146a 100644 --- a/scripts/qapi/commands.py +++ b/scripts/qapi/commands.py @@ -13,8 +13,8 @@ See the COPYING file in the top-level directory. """ =20 -from qapi.common import * -from qapi.gen import QAPIGenCCode, QAPISchemaModularCVisitor, ifcontext +from .common import * +from .gen import QAPIGenCCode, QAPISchemaModularCVisitor, ifcontext =20 =20 def gen_command_decl(name, arg_type, boxed, ret_type): diff --git a/scripts/qapi/doc.py b/scripts/qapi/doc.py index d12eda9e1e..b764a8ccc0 100644 --- a/scripts/qapi/doc.py +++ b/scripts/qapi/doc.py @@ -5,7 +5,7 @@ """This script produces the documentation of a qapi schema in texinfo form= at""" =20 import re -from qapi.gen import QAPIGenDoc, QAPISchemaVisitor +from .gen import QAPIGenDoc, QAPISchemaVisitor =20 =20 _MSG =3D ''' diff --git a/scripts/qapi/events.py b/scripts/qapi/events.py index b544af5a1c..0467272438 100644 --- a/scripts/qapi/events.py +++ b/scripts/qapi/events.py @@ -12,10 +12,10 @@ See the COPYING file in the top-level directory. """ =20 -from qapi.common import * -from qapi.gen import QAPISchemaModularCVisitor, ifcontext -from qapi.schema import QAPISchemaEnumMember -from qapi.types import gen_enum, gen_enum_lookup +from .common import * +from .gen import QAPISchemaModularCVisitor, ifcontext +from .schema import QAPISchemaEnumMember +from .types import gen_enum, gen_enum_lookup =20 =20 def build_event_send_proto(name, arg_type, boxed): diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index 2942520399..03b31ecfc1 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -16,8 +16,8 @@ =20 import re from collections import OrderedDict -from qapi.common import c_name -from qapi.error import QAPISemError +from .common import c_name +from .error import QAPISemError =20 =20 # Names must be letters, numbers, -, and _. They must start with letter, diff --git a/scripts/qapi/gen.py b/scripts/qapi/gen.py index 3d25a8cff4..f82ce9b661 100644 --- a/scripts/qapi/gen.py +++ b/scripts/qapi/gen.py @@ -17,8 +17,8 @@ import re from contextlib import contextmanager =20 -from qapi.common import * -from qapi.schema import QAPISchemaVisitor +from .common import * +from .schema import QAPISchemaVisitor =20 =20 class QAPIGen: diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index 23652be810..2a34cd1e8e 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -10,10 +10,10 @@ See the COPYING file in the top-level directory. """ =20 -from qapi.common import * -from qapi.gen import QAPISchemaMonolithicCVisitor -from qapi.schema import (QAPISchemaArrayType, QAPISchemaBuiltinType, - QAPISchemaType) +from .common import * +from .gen import QAPISchemaMonolithicCVisitor +from .schema import (QAPISchemaArrayType, QAPISchemaBuiltinType, + QAPISchemaType) =20 =20 def _make_tree(obj, ifcond, features, extra=3DNone): diff --git a/scripts/qapi/main.py b/scripts/qapi/main.py index 18c246bbb4..3f8338ade8 100644 --- a/scripts/qapi/main.py +++ b/scripts/qapi/main.py @@ -11,14 +11,14 @@ import re import sys =20 -from qapi.commands import gen_commands -from qapi.doc import gen_doc -from qapi.error import QAPIError -from qapi.events import gen_events -from qapi.introspect import gen_introspect -from qapi.schema import QAPISchema -from qapi.types import gen_types -from qapi.visit import gen_visit +from .commands import gen_commands +from .doc import gen_doc +from .error import QAPIError +from .events import gen_events +from .introspect import gen_introspect +from .schema import QAPISchema +from .types import gen_types +from .visit import gen_visit =20 =20 DEFAULT_OUTPUT_DIR =3D '' diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py index 00738cea8c..76d28c1ce9 100644 --- a/scripts/qapi/parser.py +++ b/scripts/qapi/parser.py @@ -18,8 +18,8 @@ import re from collections import OrderedDict =20 -from qapi.error import QAPIParseError, QAPISemError -from qapi.source import QAPISourceInfo +from .error import QAPIParseError, QAPISemError +from .source import QAPISourceInfo =20 =20 class QAPISchemaParser: diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 78309a00f0..a835ee6fde 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -18,10 +18,10 @@ import re from collections import OrderedDict =20 -from qapi.common import c_name, pointer_suffix -from qapi.error import QAPIError, QAPISemError -from qapi.expr import check_exprs -from qapi.parser import QAPISchemaParser +from .common import c_name, pointer_suffix +from .error import QAPIError, QAPISemError +from .expr import check_exprs +from .parser import QAPISchemaParser =20 =20 class QAPISchemaEntity: diff --git a/scripts/qapi/types.py b/scripts/qapi/types.py index 3640f17cd6..ca9a5aacb3 100644 --- a/scripts/qapi/types.py +++ b/scripts/qapi/types.py @@ -13,9 +13,9 @@ # See the COPYING file in the top-level directory. """ =20 -from qapi.common import * -from qapi.gen import QAPISchemaModularCVisitor, ifcontext -from qapi.schema import QAPISchemaEnumMember, QAPISchemaObjectType +from .common import * +from .gen import QAPISchemaModularCVisitor, ifcontext +from .schema import QAPISchemaEnumMember, QAPISchemaObjectType =20 =20 # variants must be emitted before their container; track what has already diff --git a/scripts/qapi/visit.py b/scripts/qapi/visit.py index cdabc5fa28..7850f6e848 100644 --- a/scripts/qapi/visit.py +++ b/scripts/qapi/visit.py @@ -13,9 +13,9 @@ See the COPYING file in the top-level directory. """ =20 -from qapi.common import * -from qapi.gen import QAPISchemaModularCVisitor, ifcontext -from qapi.schema import QAPISchemaObjectType +from .common import * +from .gen import QAPISchemaModularCVisitor, ifcontext +from .schema import QAPISchemaObjectType =20 =20 def gen_visit_decl(name, scalar=3DFalse): --=20 2.26.2 From nobody Wed May 15 22:57:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600994780; cv=none; d=zohomail.com; s=zohoarc; b=mYi7mUGquFJjMgAJuYGC67z28J2GKM3VuaRAoR28FDlRVefKXBsHrsMNM6qV8UaKyt2FcuNa4zd1ojvVaVBrC8Jn1rYhgMite+ISC7Z/OSh9xVAxsNiATpy9mjexs/RapoTZUayO9eyGAws9IZWXzsnd4kGNUFOZ5datWmgmY+Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600994780; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mJCCI9PEKemOs8lv+3p8WkT+iAoGzjEh/EoijsMA9Dk=; b=h/ks4QDtCPCekAqiUsdusQFzLAGRmRxpi5f84LL9jT2yFPcaJyuX6qJ+qodrq6lJYselxdUVVXKAC3C1+I5QE6wvM3B4/IkMeNtRGhjt3eSULrTpGxPXseLnkEDX/FI1quvAS1drskRwiLS6s4yRsx8ABsBlEYzXrJZymOY52h4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 160099478038431.703886844523595; Thu, 24 Sep 2020 17:46:20 -0700 (PDT) Received: from localhost ([::1]:45834 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLbsQ-00005B-Lc for importer@patchew.org; Thu, 24 Sep 2020 20:46:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51090) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLbby-0000qf-N2 for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:49826) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLbbu-00009S-Uf for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:18 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-295-Q1hTjf0FPaWPc8rDxHroOQ-1; Thu, 24 Sep 2020 20:29:12 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4224064095 for ; Fri, 25 Sep 2020 00:29:11 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8F2A05D9DD; Fri, 25 Sep 2020 00:29:10 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600993754; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mJCCI9PEKemOs8lv+3p8WkT+iAoGzjEh/EoijsMA9Dk=; b=e+rxuMJCV94lu2eo8jVIyQV1/1uDI2zxayMl6kY0H2Ms+ee4ngWntzJZ/bpUwaMql+YV+6 GedB6d5Vfugwjp7fksyZUjNasmUu6pfRLqafgiXewWUO7Cc3qkQTDV6p9osdpYncD4BZ3W 2nUsWBrpLehQO6iTGrMbrFSzQsWPhOE= X-MC-Unique: Q1hTjf0FPaWPc8rDxHroOQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 11/47] qapi: Remove wildcard includes Date: Thu, 24 Sep 2020 20:28:24 -0400 Message-Id: <20200925002900.465855-12-jsnow@redhat.com> In-Reply-To: <20200925002900.465855-1-jsnow@redhat.com> References: <20200925002900.465855-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 23:02:20 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Wildcard includes become hard to manage when refactoring and dealing with circular dependencies with strictly typed mypy. flake8 also flags each one as a warning, as it is not smart enough to know which names exist in the imported file. Remove them and include things explicitly by name instead. Signed-off-by: John Snow Reviewed-by: Eduardo Habkost Reviewed-by: Cleber Rosa --- scripts/qapi/commands.py | 6 +++++- scripts/qapi/events.py | 7 ++++++- scripts/qapi/gen.py | 12 +++++++++--- scripts/qapi/introspect.py | 7 ++++++- scripts/qapi/types.py | 8 +++++++- scripts/qapi/visit.py | 10 +++++++++- 6 files changed, 42 insertions(+), 8 deletions(-) diff --git a/scripts/qapi/commands.py b/scripts/qapi/commands.py index ce5926146a..e1df0e341f 100644 --- a/scripts/qapi/commands.py +++ b/scripts/qapi/commands.py @@ -13,7 +13,11 @@ See the COPYING file in the top-level directory. """ =20 -from .common import * +from .common import ( + build_params, + c_name, + mcgen, +) from .gen import QAPIGenCCode, QAPISchemaModularCVisitor, ifcontext =20 =20 diff --git a/scripts/qapi/events.py b/scripts/qapi/events.py index 0467272438..6b3afa14d7 100644 --- a/scripts/qapi/events.py +++ b/scripts/qapi/events.py @@ -12,7 +12,12 @@ See the COPYING file in the top-level directory. """ =20 -from .common import * +from .common import ( + build_params, + c_enum_const, + c_name, + mcgen, +) from .gen import QAPISchemaModularCVisitor, ifcontext from .schema import QAPISchemaEnumMember from .types import gen_enum, gen_enum_lookup diff --git a/scripts/qapi/gen.py b/scripts/qapi/gen.py index f82ce9b661..d37339fe8f 100644 --- a/scripts/qapi/gen.py +++ b/scripts/qapi/gen.py @@ -11,13 +11,19 @@ # This work is licensed under the terms of the GNU GPL, version 2. # See the COPYING file in the top-level directory. =20 - +from contextlib import contextmanager import errno import os import re -from contextlib import contextmanager =20 -from .common import * +from .common import ( + c_fname, + gen_endif, + gen_if, + guardend, + guardstart, + mcgen, +) from .schema import QAPISchemaVisitor =20 =20 diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index 2a34cd1e8e..b036fcf9ce 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -10,7 +10,12 @@ See the COPYING file in the top-level directory. """ =20 -from .common import * +from .common import ( + c_name, + gen_endif, + gen_if, + mcgen, +) from .gen import QAPISchemaMonolithicCVisitor from .schema import (QAPISchemaArrayType, QAPISchemaBuiltinType, QAPISchemaType) diff --git a/scripts/qapi/types.py b/scripts/qapi/types.py index ca9a5aacb3..53b47f9e58 100644 --- a/scripts/qapi/types.py +++ b/scripts/qapi/types.py @@ -13,7 +13,13 @@ # See the COPYING file in the top-level directory. """ =20 -from .common import * +from .common import ( + c_enum_const, + c_name, + gen_endif, + gen_if, + mcgen, +) from .gen import QAPISchemaModularCVisitor, ifcontext from .schema import QAPISchemaEnumMember, QAPISchemaObjectType =20 diff --git a/scripts/qapi/visit.py b/scripts/qapi/visit.py index 7850f6e848..ea277e7704 100644 --- a/scripts/qapi/visit.py +++ b/scripts/qapi/visit.py @@ -13,7 +13,15 @@ See the COPYING file in the top-level directory. """ =20 -from .common import * +from .common import ( + c_enum_const, + c_name, + gen_endif, + gen_if, + mcgen, + pop_indent, + push_indent, +) from .gen import QAPISchemaModularCVisitor, ifcontext from .schema import QAPISchemaObjectType =20 --=20 2.26.2 From nobody Wed May 15 22:57:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600994662; cv=none; d=zohomail.com; s=zohoarc; b=eHe7IkQJ1Z9NtiXrzFyJ5TMuGAoLwONUgCBJXzIAgmE+rYJI3wTX+XFihvJquM8H/To8GgCeRLjZhL0GExg/oQiID2s9e9ET77SATXol1/ogttXP94cwtx5Tl/sScpN/lDz73pPe9WCX75Jz2jEgvJX0E9Yv23edffgUqRoNs28= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600994662; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=wMogz3UY4+2VVe3Yqivuz7WZ5WTRsaKaTdJjGZ64c68=; b=TXK95INVJUtDrlZdlW+CocE+vbZffPam5Cs2PrzpstBP8f+ljZapTQ/gq0WRIYpmGiOVOiRi3BP1KQavHM26X8bK6DxhVKC8TFFeuW4kZK7YYtEoqUTXuXsKmSfgpsDYJm2ZJdXt/Andjsv6ZxVATjUT8u9oN6uIWhaLprlezdk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600994662050318.6142641774329; Thu, 24 Sep 2020 17:44:22 -0700 (PDT) Received: from localhost ([::1]:40652 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLbqW-0006FK-PB for importer@patchew.org; Thu, 24 Sep 2020 20:44:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51094) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLbby-0000r7-VK for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:41848) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLbbv-00009e-S4 for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:18 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-573-iqmv2GUgMDKoPLpI48PMgA-1; Thu, 24 Sep 2020 20:29:13 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5E15781F03E for ; Fri, 25 Sep 2020 00:29:12 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7EBC85D9DD; Fri, 25 Sep 2020 00:29:11 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600993755; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wMogz3UY4+2VVe3Yqivuz7WZ5WTRsaKaTdJjGZ64c68=; b=VBhV4POQVc3+x1DEKZ6gVTWpb92jpYOZzyHOg3w1rV+dZgbuNdWt8mDMGKAlhyET84vHIW FeMwtgcZhoDJIJIG28lsuh3CXAYQvin9nxVtH8GKRnHmN77xzgnRDMI8CHHvOZsosHEorB 48NKg/PElTCzCnG/KZUsMxwhLNWBo7s= X-MC-Unique: iqmv2GUgMDKoPLpI48PMgA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 12/47] qapi: enforce import order/styling with isort Date: Thu, 24 Sep 2020 20:28:25 -0400 Message-Id: <20200925002900.465855-13-jsnow@redhat.com> In-Reply-To: <20200925002900.465855-1-jsnow@redhat.com> References: <20200925002900.465855-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 23:02:20 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" While we're mucking around with imports, we might as well formalize the style we use. Let's use isort to do it for us. force_sort_within_sections: Intermingles "from x" and "import x" style statements, such that sorting is always performed strictly on the module name itself. force_grid_wrap=3D4: Four or more imports from a single module will force the one-per-line style that's more git-friendly. This will generally happen for 'typing' imports. multi_line_output=3D3: Uses the one-per-line indented style for long imports. include_trailing_comma: Adds a comma to the last import in a group, which makes git conflicts nicer to deal with, generally. Suggested-by: Cleber Rosa Signed-off-by: John Snow Reviewed-by: Cleber Rosa Tested-by: Cleber Rosa --- scripts/qapi/.isort.cfg | 5 +++++ scripts/qapi/commands.py | 6 +----- scripts/qapi/doc.py | 2 +- scripts/qapi/expr.py | 4 ++-- scripts/qapi/introspect.py | 3 +-- scripts/qapi/main.py | 1 - scripts/qapi/parser.py | 2 +- scripts/qapi/schema.py | 2 +- scripts/qapi/types.py | 1 - 9 files changed, 12 insertions(+), 14 deletions(-) create mode 100644 scripts/qapi/.isort.cfg diff --git a/scripts/qapi/.isort.cfg b/scripts/qapi/.isort.cfg new file mode 100644 index 0000000000..b0aeffec26 --- /dev/null +++ b/scripts/qapi/.isort.cfg @@ -0,0 +1,5 @@ +[settings] +force_sort_within_sections=3DTrue +force_grid_wrap=3D4 +multi_line_output=3D3 +include_trailing_comma=3DTrue diff --git a/scripts/qapi/commands.py b/scripts/qapi/commands.py index e1df0e341f..64ed5278f9 100644 --- a/scripts/qapi/commands.py +++ b/scripts/qapi/commands.py @@ -13,11 +13,7 @@ See the COPYING file in the top-level directory. """ =20 -from .common import ( - build_params, - c_name, - mcgen, -) +from .common import build_params, c_name, mcgen from .gen import QAPIGenCCode, QAPISchemaModularCVisitor, ifcontext =20 =20 diff --git a/scripts/qapi/doc.py b/scripts/qapi/doc.py index b764a8ccc0..1acb773e0a 100644 --- a/scripts/qapi/doc.py +++ b/scripts/qapi/doc.py @@ -5,9 +5,9 @@ """This script produces the documentation of a qapi schema in texinfo form= at""" =20 import re + from .gen import QAPIGenDoc, QAPISchemaVisitor =20 - _MSG =3D ''' @deftypefn {type} {{}} {name} =20 diff --git a/scripts/qapi/expr.py b/scripts/qapi/expr.py index 03b31ecfc1..3e952a1462 100644 --- a/scripts/qapi/expr.py +++ b/scripts/qapi/expr.py @@ -14,12 +14,12 @@ # This work is licensed under the terms of the GNU GPL, version 2. # See the COPYING file in the top-level directory. =20 -import re from collections import OrderedDict +import re + from .common import c_name from .error import QAPISemError =20 - # Names must be letters, numbers, -, and _. They must start with letter, # except for downstream extensions which must start with __RFQDN_. # Dots are only valid in the downstream extension prefix. diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index b036fcf9ce..2850121cbd 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -17,8 +17,7 @@ mcgen, ) from .gen import QAPISchemaMonolithicCVisitor -from .schema import (QAPISchemaArrayType, QAPISchemaBuiltinType, - QAPISchemaType) +from .schema import QAPISchemaArrayType, QAPISchemaBuiltinType, QAPISchema= Type =20 =20 def _make_tree(obj, ifcond, features, extra=3DNone): diff --git a/scripts/qapi/main.py b/scripts/qapi/main.py index 3f8338ade8..b2f20581fd 100644 --- a/scripts/qapi/main.py +++ b/scripts/qapi/main.py @@ -20,7 +20,6 @@ from .types import gen_types from .visit import gen_visit =20 - DEFAULT_OUTPUT_DIR =3D '' DEFAULT_PREFIX =3D '' =20 diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py index 76d28c1ce9..fd89e2188b 100644 --- a/scripts/qapi/parser.py +++ b/scripts/qapi/parser.py @@ -14,9 +14,9 @@ # This work is licensed under the terms of the GNU GPL, version 2. # See the COPYING file in the top-level directory. =20 +from collections import OrderedDict import os import re -from collections import OrderedDict =20 from .error import QAPIParseError, QAPISemError from .source import QAPISourceInfo diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index a835ee6fde..093f7a38d8 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -14,9 +14,9 @@ =20 # TODO catching name collisions in generated code would be nice =20 +from collections import OrderedDict import os import re -from collections import OrderedDict =20 from .common import c_name, pointer_suffix from .error import QAPIError, QAPISemError diff --git a/scripts/qapi/types.py b/scripts/qapi/types.py index 53b47f9e58..cc6dad4c89 100644 --- a/scripts/qapi/types.py +++ b/scripts/qapi/types.py @@ -23,7 +23,6 @@ from .gen import QAPISchemaModularCVisitor, ifcontext from .schema import QAPISchemaEnumMember, QAPISchemaObjectType =20 - # variants must be emitted before their container; track what has already # been output objects_seen =3D set() --=20 2.26.2 From nobody Wed May 15 22:57:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600994025; cv=none; d=zohomail.com; s=zohoarc; b=cEHSfQf4fjK8GMt4dyDXSnf1PS2AdG3PDcImdqMoDfZuenSBaWP28/2RWtWNvsvP0SgqetJ74+ONDprlOFK+JmLf1S9xocaQEQ1lG9o4BGxVlkg2vveHk+WtNcbCCPIELpsPA8gOduhqqL88ENp0wgTJJxBs9b+uhYmOQMc94qU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600994025; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=EM/9SLIysbSVW3ZW58L3soB0wBJh+tajanNL6oCUKYI=; b=gf11ISBHMZde0UeMV6hO17Le22KlmG8IIODTVDrbCqq5WRAl8Xh9txfJCWJrRe1OVKCq8D74timPCpjEddXncgnlJmhR6pMvQGR6ncnTBeNM/VUdLTREa6i9VAcL4N6SKyUs8WYdGUihyBIDLvfEU3Y/6sDi/5JMJQBxA2xTFAA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600994025847239.71277407966386; Thu, 24 Sep 2020 17:33:45 -0700 (PDT) Received: from localhost ([::1]:41234 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLbgG-00035y-IP for importer@patchew.org; Thu, 24 Sep 2020 20:33:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51102) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLbbz-0000tB-LS for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:60245) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLbbx-0000A1-2D for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:19 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-40-qHj48_uzMSyxC4ISgKEP-Q-1; Thu, 24 Sep 2020 20:29:14 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 94C818015A5 for ; Fri, 25 Sep 2020 00:29:13 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id A4F785D9DD; Fri, 25 Sep 2020 00:29:12 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600993756; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EM/9SLIysbSVW3ZW58L3soB0wBJh+tajanNL6oCUKYI=; b=Ubzal3fN5i+4JRVzMMNWJoAXiOG26D32WHwVfiCqsLfeWbGHvMX2vV66pJsWywqW4AJvBx Fce0nbOHNfSvOJtSNdhnFhwO5OCRO2RXWmjDvq13WkCAi4IeRi5w4XNbxsak16r1eJFyFk 9ySobu0PSR6gNYs+qdrqqV0TeQBXLHE= X-MC-Unique: qHj48_uzMSyxC4ISgKEP-Q-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 13/47] qapi: delint using flake8 Date: Thu, 24 Sep 2020 20:28:26 -0400 Message-Id: <20200925002900.465855-14-jsnow@redhat.com> In-Reply-To: <20200925002900.465855-1-jsnow@redhat.com> References: <20200925002900.465855-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/24 01:10:00 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Petty style guide fixes and line length enforcement. Not a big win, not a big loss, but flake8 passes 100% on the qapi module, which gives us an easy baseline to enforce hereafter. A note on the flake8 exception: flake8 will warn on *any* bare except, but pylint's is context-aware and will suppress the warning if you re-raise the exception. Signed-off-by: John Snow Reviewed-by: Eduardo Habkost Reviewed-by: Cleber Rosa --- scripts/qapi/.flake8 | 2 ++ scripts/qapi/commands.py | 3 ++- scripts/qapi/schema.py | 8 +++++--- scripts/qapi/visit.py | 16 +++++++++++----- 4 files changed, 20 insertions(+), 9 deletions(-) create mode 100644 scripts/qapi/.flake8 diff --git a/scripts/qapi/.flake8 b/scripts/qapi/.flake8 new file mode 100644 index 0000000000..6b158c68b8 --- /dev/null +++ b/scripts/qapi/.flake8 @@ -0,0 +1,2 @@ +[flake8] +extend-ignore =3D E722 # Prefer pylint's bare-except checks to flake8's diff --git a/scripts/qapi/commands.py b/scripts/qapi/commands.py index 64ed5278f9..5dc2f5a9fa 100644 --- a/scripts/qapi/commands.py +++ b/scripts/qapi/commands.py @@ -65,7 +65,8 @@ def gen_call(name, arg_type, boxed, ret_type): def gen_marshal_output(ret_type): return mcgen(''' =20 -static void qmp_marshal_output_%(c_name)s(%(c_type)s ret_in, QObject **ret= _out, Error **errp) +static void qmp_marshal_output_%(c_name)s(%(c_type)s ret_in, + QObject **ret_out, Error **errp) { Visitor *v; =20 diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 093f7a38d8..cfc52e1ae4 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -536,7 +536,7 @@ def set_defined_in(self, name): v.set_defined_in(name) =20 def check(self, schema, seen): - if not self.tag_member: # flat union + if not self.tag_member: # flat union self.tag_member =3D seen.get(c_name(self._tag_name)) base =3D "'base'" # Pointing to the base type when not implicit would be @@ -821,7 +821,7 @@ def __init__(self, fname): self._entity_dict =3D {} self._module_dict =3D OrderedDict() self._schema_dir =3D os.path.dirname(fname) - self._make_module(None) # built-ins + self._make_module(None) # built-ins self._make_module(fname) self._predefining =3D True self._def_predefineds() @@ -965,7 +965,9 @@ def _make_implicit_object_type(self, name, info, ifcond= , role, members): # But it's not tight: the disjunction need not imply it. We # may end up compiling useless wrapper types. # TODO kill simple unions or implement the disjunction - assert (ifcond or []) =3D=3D typ._ifcond # pylint: disable=3Dp= rotected-access + + # pylint: disable=3Dprotected-access + assert (ifcond or []) =3D=3D typ._ifcond else: self._def_entity(QAPISchemaObjectType( name, info, None, ifcond, None, None, members, None)) diff --git a/scripts/qapi/visit.py b/scripts/qapi/visit.py index ea277e7704..808410d6f1 100644 --- a/scripts/qapi/visit.py +++ b/scripts/qapi/visit.py @@ -31,7 +31,9 @@ def gen_visit_decl(name, scalar=3DFalse): if not scalar: c_type +=3D '*' return mcgen(''' -bool visit_type_%(c_name)s(Visitor *v, const char *name, %(c_type)sobj, Er= ror **errp); + +bool visit_type_%(c_name)s(Visitor *v, const char *name, + %(c_type)sobj, Error **errp); ''', c_name=3Dc_name(name), c_type=3Dc_type) =20 @@ -125,7 +127,8 @@ def gen_visit_object_members(name, base, members, varia= nts): def gen_visit_list(name, element_type): return mcgen(''' =20 -bool visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s **obj,= Error **errp) +bool visit_type_%(c_name)s(Visitor *v, const char *name, + %(c_name)s **obj, Error **errp) { bool ok =3D false; %(c_name)s *tail; @@ -158,7 +161,8 @@ def gen_visit_list(name, element_type): def gen_visit_enum(name): return mcgen(''' =20 -bool visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s *obj, = Error **errp) +bool visit_type_%(c_name)s(Visitor *v, const char *name, + %(c_name)s *obj, Error **errp) { int value =3D *obj; bool ok =3D visit_type_enum(v, name, &value, &%(c_name)s_lookup, errp); @@ -172,7 +176,8 @@ def gen_visit_enum(name): def gen_visit_alternate(name, variants): ret =3D mcgen(''' =20 -bool visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s **obj,= Error **errp) +bool visit_type_%(c_name)s + (Visitor *v, const char *name, %(c_name)s **obj, Error **errp) { bool ok =3D false; =20 @@ -247,7 +252,8 @@ def gen_visit_alternate(name, variants): def gen_visit_object(name, base, members, variants): return mcgen(''' =20 -bool visit_type_%(c_name)s(Visitor *v, const char *name, %(c_name)s **obj,= Error **errp) +bool visit_type_%(c_name)s + (Visitor *v, const char *name, %(c_name)s **obj, Error **errp) { bool ok =3D false; =20 --=20 2.26.2 From nobody Wed May 15 22:57:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600995120; cv=none; d=zohomail.com; s=zohoarc; b=X/33Y8i9vtVJSQbMeQRrNI3YnyI9ACQ2ybMN7DQlUNGww8zV6EEdm7spaVRCoCmDpfuJCuQyIpono+ztkOrhuAH9rcMEzlVjKg5JeqawmoWUjBDaRJmznQbclsleXqt5bEAfeClspQf+ak00YncPf4H+5CK2htdSU6X91CMTjX0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600995120; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=B0MgVzc6UwqHvYZ10ytMYSk1oMAHGPSbXoWqlzyvijw=; b=cLKfc4g2EDBL7vxEi0Fzz1RyP0D+k78CmQcGUy56EH8CYXj9F5V8wH/i3m6KBW7B8uqxxXcG1Vnz7H45DXjwmyB+nYT88tcPzGe7X+kt9SPKotxNKVRPsVGzolf0lpofpFD7ryHcQFGBiDHGaour66zDn4kEJdclCNa/XI3FA34= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600995120873925.1727726347513; Thu, 24 Sep 2020 17:52:00 -0700 (PDT) Received: from localhost ([::1]:35058 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLbxv-0007Of-Bm for importer@patchew.org; Thu, 24 Sep 2020 20:51:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51186) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLbcF-00014I-Dq for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:48426) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLbc3-0000Be-7o for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:33 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-485-XDy1NdU3MlCeLgSEPFxJWA-1; Thu, 24 Sep 2020 20:29:15 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CE493801AAB for ; Fri, 25 Sep 2020 00:29:14 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id D7CA45D9DD; Fri, 25 Sep 2020 00:29:13 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600993762; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=B0MgVzc6UwqHvYZ10ytMYSk1oMAHGPSbXoWqlzyvijw=; b=aDRK32DwCzXGvM+LkAnLfGM+PvwZJJ+d357SihqqpTx2qBWbEzVJI/ZiIWbV1NCPcLUyAj ZZoo5g0fCCaimVzAmlDTsG6fuZKqgfPYtuXuSCKTb7vqzhfxIhBIqqFKsHxsI55w3BHtve 5sLJk7isXvKEhSKBK3w2JuBi3dAdt3E= X-MC-Unique: XDy1NdU3MlCeLgSEPFxJWA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 14/47] qapi: add pylintrc Date: Thu, 24 Sep 2020 20:28:27 -0400 Message-Id: <20200925002900.465855-15-jsnow@redhat.com> In-Reply-To: <20200925002900.465855-1-jsnow@redhat.com> References: <20200925002900.465855-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 23:02:20 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Using `pylint --generate-rcfile > pylintrc`, generate a skeleton pylintrc file. Sections that are not presently relevant (by the end of this series) are removed leaving just the empty section as a search engine / documentation hint to future authors. I am targeting pylint 2.6.0. In the future (and hopefully before 5.2 is released), I aim to have gitlab CI running the specific targeted versions of pylint, mypy, flake8, etc in a job. 2.5.x will work if you additionally pass --disable=3Dbad-whitespace. This warning was removed from 2.6.x, for lack of consistent support. Right now, quite a few modules are ignored as they are known to fail as of this commit. modules will be removed from the known-bad list throughout this and following series as they are repaired. Note: Normally, pylintrc would go in the folder above the module, but as that folder is shared by many things, it is going inside the module folder (for now). Due to a bug in pylint 2.5+, pylint does not correctly recognize when it is being run from "inside" a package, and must be run *outside* of the package. Therefore, to run it, you must: > pylint scripts/qapi/ --rcfile=3Dscripts/qapi/pylintrc Signed-off-by: John Snow Tested-by: Eduardo Habkost Reviewed-by: Cleber Rosa Tested-by: Cleber Rosa --- scripts/qapi/pylintrc | 74 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 scripts/qapi/pylintrc diff --git a/scripts/qapi/pylintrc b/scripts/qapi/pylintrc new file mode 100644 index 0000000000..02dd22c863 --- /dev/null +++ b/scripts/qapi/pylintrc @@ -0,0 +1,74 @@ +[MASTER] + +# Add files or directories matching the regex patterns to the ignore list. +# The regex matches against base names, not paths. +ignore-patterns=3Dcommon.py, + doc.py, + error.py, + expr.py, + gen.py, + parser.py, + schema.py, + source.py, + types.py, + visit.py, + + +[MESSAGES CONTROL] + +# Disable the message, report, category or checker with the given id(s). Y= ou +# can either give multiple identifiers separated by comma (,) or put this +# option multiple times (only on the command line, not in the configuration +# file where it should appear only once). You can also use "--disable=3Dal= l" to +# disable everything first and then reenable specific checks. For example,= if +# you want to run only the similarities checker, you can use "--disable=3D= all +# --enable=3Dsimilarities". If you want to run only the classes checker, b= ut have +# no Warning level messages displayed, use "--disable=3Dall --enable=3Dcla= sses +# --disable=3DW". +disable=3Dfixme, + missing-docstring, + too-many-arguments, + too-many-branches, + too-many-statements, + too-many-instance-attributes, + +[REPORTS] + +[REFACTORING] + +[MISCELLANEOUS] + +[LOGGING] + +[BASIC] + +# Good variable names which should always be accepted, separated by a comm= a. +good-names=3Di, + j, + k, + ex, + Run, + _ + +[VARIABLES] + +[STRING] + +[SPELLING] + +[FORMAT] + +[SIMILARITIES] + +# Ignore import statements themselves when computing similarities. +ignore-imports=3Dyes + +[TYPECHECK] + +[CLASSES] + +[IMPORTS] + +[DESIGN] + +[EXCEPTIONS] --=20 2.26.2 From nobody Wed May 15 22:57:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600994225; cv=none; d=zohomail.com; s=zohoarc; b=Yt9kzpITHFjC42aaI3F23/AOZHRq0hSFDhGOewfPwGmMiThuprf53mpxII3yu1ONv6Ksq0adPzahbbMmFy5Xg69jvlPa2F+otHtWLldZRtrFVO4yinkpFizOtRPSwPLzpqu0pchTyrA/f3sGOqGnmfmC1HN27nYfIrfOpGNV5U0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600994225; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=m9h2zukFjbhKmOktF4waQNR43yY/9y0Kxw8OLVbTV1I=; b=jxrUtSdbRarfj3Z03XisRkic2CVmUOTHXrMQcfgNBzg1XJ0EA1rzKEMZxCpxONsIlwt21ZNxWz2m5CLrz/I7VyLBHQC7BiJfWz+HB79t1Ti7XhsCHKeGNAYIRFs3BQleqWtO5YtRYzuHmG3Pju8n5V+L23PjaXngJPYBvyz371E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600994225529819.0934021450928; Thu, 24 Sep 2020 17:37:05 -0700 (PDT) Received: from localhost ([::1]:49528 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLbjU-0006ew-A3 for importer@patchew.org; Thu, 24 Sep 2020 20:37:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51112) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLbc0-0000wQ-TR for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:20 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:23532) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLbbz-0000Ac-6A for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:20 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-162-21bFMBiiOTWYYUvTP9wWtA-1; Thu, 24 Sep 2020 20:29:16 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CC9C26408A for ; Fri, 25 Sep 2020 00:29:15 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1FEF35D9DD; Fri, 25 Sep 2020 00:29:14 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600993758; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=m9h2zukFjbhKmOktF4waQNR43yY/9y0Kxw8OLVbTV1I=; b=Xr9UPHHFdZZgzngbPkg8xqTqfvTuaMUgK+MUc9gMeWRrw3jm0nZRQYfkyYqIYXO6VEuwwi LGeClfHr4YwVW3KtIToaVb6W2KeDm4JbXHJP9KkgN7V7UirRNgzKwajIbmDOFxaavGsapD /TjD1FU7MnxmzhsMkfJq2GAte+iHjI4= X-MC-Unique: 21bFMBiiOTWYYUvTP9wWtA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 15/47] qapi/common.py: Remove python compatibility workaround Date: Thu, 24 Sep 2020 20:28:28 -0400 Message-Id: <20200925002900.465855-16-jsnow@redhat.com> In-Reply-To: <20200925002900.465855-1-jsnow@redhat.com> References: <20200925002900.465855-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/24 01:10:00 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: John Snow Reviewed-by: Eduardo Habkost Reviewed-by: Cleber Rosa --- scripts/qapi/common.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index ba35abea47..cee63eb95c 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -119,10 +119,7 @@ def cgen(code, **kwds): raw =3D code % kwds if indent_level: indent =3D genindent(indent_level) - # re.subn() lacks flags support before Python 2.7, use re.compile() - raw =3D re.subn(re.compile(r'^(?!(#|$))', re.MULTILINE), - indent, raw) - raw =3D raw[0] + raw =3D re.sub(r'^(?!(#|$))', indent, raw, flags=3Dre.MULTILINE) return re.sub(re.escape(eatspace) + r' *', '', raw) =20 =20 --=20 2.26.2 From nobody Wed May 15 22:57:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600994388; cv=none; d=zohomail.com; s=zohoarc; b=N+76p0ycZ+9phaaGzuJ75T7I4IwogSHNAlAacNmhJqLlRdcjFSThsDuckS2GwIUvD1bSVA9WlvRpQghFLZH1GU9gGJjnl6c64RrhO+pGseRb5qgPhG71GDgXJ469K6Jh8O1Jha4qmGtZe23M96zDupxspxIOaPK6LCcOuiNftDI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600994388; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=itd7Gk2vFiXD6pma457JcdqSYp+OjlBf6wrCUoFxFd4=; b=RYCB/wUOSCBWWhq21uOLLOhVHOOAJ/mBtqx6fSqBBzh0YFzghLPWWozXzml515YyoRqYQZ6OVZYijRkWs9PcGQsTo8RIBk/P+mD5t+7M1aZoeriuYHniwkG6XI9/fIjXrBwqLtQYwjFBEnHFndntxXQJxEWFjWTVCCM8DJjY9OQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 160099438836217.904953913487134; Thu, 24 Sep 2020 17:39:48 -0700 (PDT) Received: from localhost ([::1]:57746 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLbm6-0001b2-V7 for importer@patchew.org; Thu, 24 Sep 2020 20:39:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51138) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLbc3-00010N-5F for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:20165) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLbc1-0000B3-BW for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:22 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-228-gwmXmQ4PPBi3xfhCNymz7w-1; Thu, 24 Sep 2020 20:29:17 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9681C8015A5 for ; Fri, 25 Sep 2020 00:29:16 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id F37855D9DD; Fri, 25 Sep 2020 00:29:15 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600993760; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=itd7Gk2vFiXD6pma457JcdqSYp+OjlBf6wrCUoFxFd4=; b=hBM+CPpgUzthP22HjdpvE/f8XEa3G03kFp/N1mfJbDBLIX89a7YI7UEBram9mbYeT9CPI+ H34Aw9RlqYQZZp7HN5CQBRH1KzdyItf/F4pJ+A+ov9uq/hjlGYviK11gDfqlQsOEShf8l0 d/D7nWFnRV0WsCeznToB6Wl2j6YvSBM= X-MC-Unique: gwmXmQ4PPBi3xfhCNymz7w-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 16/47] qapi/common.py: Add indent manager Date: Thu, 24 Sep 2020 20:28:29 -0400 Message-Id: <20200925002900.465855-17-jsnow@redhat.com> In-Reply-To: <20200925002900.465855-1-jsnow@redhat.com> References: <20200925002900.465855-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/24 01:10:00 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Code style tools really dislike the use of global keywords, because it generally involves re-binding the name at runtime which can have strange effects depending on when and how that global name is referenced in other modules. Make a little indent level manager instead. Signed-off-by: John Snow Reviewed-by: Eduardo Habkost Reviewed-by: Cleber Rosa --- scripts/qapi/common.py | 49 ++++++++++++++++++++++++++++-------------- scripts/qapi/visit.py | 7 +++--- 2 files changed, 36 insertions(+), 20 deletions(-) diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index cee63eb95c..b35318b72c 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -93,33 +93,50 @@ def c_name(name, protect=3DTrue): pointer_suffix =3D ' *' + eatspace =20 =20 -def genindent(count): - ret =3D '' - for _ in range(count): - ret +=3D ' ' - return ret +class Indentation: + """ + Indentation level management. =20 + :param initial: Initial number of spaces, default 0. + """ + def __init__(self, initial: int =3D 0) -> None: + self._level =3D initial =20 -indent_level =3D 0 + def __int__(self) -> int: + return self._level =20 + def __repr__(self) -> str: + return "{}({:d})".format(type(self).__name__, self._level) =20 -def push_indent(indent_amount=3D4): - global indent_level - indent_level +=3D indent_amount + def __str__(self) -> str: + """Return the current indentation as a string of spaces.""" + return ' ' * self._level =20 + def __bool__(self) -> bool: + """True when there is a non-zero indentation.""" + return bool(self._level) =20 -def pop_indent(indent_amount=3D4): - global indent_level - indent_level -=3D indent_amount + def increase(self, amount: int =3D 4) -> None: + """Increase the indentation level by ``amount``, default 4.""" + self._level +=3D amount + + def decrease(self, amount: int =3D 4) -> None: + """Decrease the indentation level by ``amount``, default 4.""" + if self._level < amount: + raise ArithmeticError( + f"Can't remove {amount:d} spaces from {self!r}") + self._level -=3D amount + + +indent =3D Indentation() =20 =20 # Generate @code with @kwds interpolated. -# Obey indent_level, and strip eatspace. +# Obey indent, and strip eatspace. def cgen(code, **kwds): raw =3D code % kwds - if indent_level: - indent =3D genindent(indent_level) - raw =3D re.sub(r'^(?!(#|$))', indent, raw, flags=3Dre.MULTILINE) + if indent: + raw =3D re.sub(r'^(?!(#|$))', str(indent), raw, flags=3Dre.MULTILI= NE) return re.sub(re.escape(eatspace) + r' *', '', raw) =20 =20 diff --git a/scripts/qapi/visit.py b/scripts/qapi/visit.py index 808410d6f1..14f30c228b 100644 --- a/scripts/qapi/visit.py +++ b/scripts/qapi/visit.py @@ -18,9 +18,8 @@ c_name, gen_endif, gen_if, + indent, mcgen, - pop_indent, - push_indent, ) from .gen import QAPISchemaModularCVisitor, ifcontext from .schema import QAPISchemaObjectType @@ -69,7 +68,7 @@ def gen_visit_object_members(name, base, members, variant= s): if (visit_optional(v, "%(name)s", &obj->has_%(c_name)s)) { ''', name=3Dmemb.name, c_name=3Dc_name(memb.name)) - push_indent() + indent.increase() ret +=3D mcgen(''' if (!visit_type_%(c_type)s(v, "%(name)s", &obj->%(c_name)s, errp)) { return false; @@ -78,7 +77,7 @@ def gen_visit_object_members(name, base, members, variant= s): c_type=3Dmemb.type.c_name(), name=3Dmemb.name, c_name=3Dc_name(memb.name)) if memb.optional: - pop_indent() + indent.decrease() ret +=3D mcgen(''' } ''') --=20 2.26.2 From nobody Wed May 15 22:57:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600994918; cv=none; d=zohomail.com; s=zohoarc; b=KNRI8pyqNwILfeUoPUJhkrvshuQ38n9xuXGChkju+1z4EN47dq0ptpzyGqwXDYnfDbEKSabFq37ba54aNWUx2i7hpb30PgJguR0Kj2XazqBifq+H/fKrn1XH2RG32C8N1cB5v0mqkL6NtICMqK3ji2KEFBiXSqwWLolxRyDfCds= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600994918; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LPf1pzMj8KPhnb+3IXk7jMQ4s+1YpfsVGd6crqm9dQA=; b=Ddvsfx9w212POH9p2YMLMH1uAGT9FNGAUj2VtYYYB2XXdApD2VBjNboz8i4XpGdGJKd0JCSk0Gy8lbWqDfqQA16F63cDwjChn/V6SuTyrZMseRoiStnCALRL+4DESwHImx7C2/vR2QNXXDUCjHBo2ohESq+WrIJtghsNCvpExmE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600994918190123.86006227522626; Thu, 24 Sep 2020 17:48:38 -0700 (PDT) Received: from localhost ([::1]:54936 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLbue-0003sQ-S3 for importer@patchew.org; Thu, 24 Sep 2020 20:48:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51190) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLbcG-00014M-2O for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:30451) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLbc2-0000BC-2d for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:35 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-163-fyQ42eXUO26POFKaNYVKsA-1; Thu, 24 Sep 2020 20:29:18 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5D621188C125 for ; Fri, 25 Sep 2020 00:29:17 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id BCA205D9DD; Fri, 25 Sep 2020 00:29:16 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600993761; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LPf1pzMj8KPhnb+3IXk7jMQ4s+1YpfsVGd6crqm9dQA=; b=iZ4+MIlJgsnJg0yA8yiLXy5bQGuPpnCuFFA2SaQh5/e/wwPWhu6wz9vGxdDrWVg8hjzEl/ mK+SIad9Mj323nJp9Gwr2nXg1CRXBAMkITJedMGWfcWNlRv1589kMrc+EWTbj7DRtAJeh6 RQiqRDqe/jk/eem7aTW8mTxkIUHFnu0= X-MC-Unique: fyQ42eXUO26POFKaNYVKsA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 17/47] qapi/common.py: delint with pylint Date: Thu, 24 Sep 2020 20:28:30 -0400 Message-Id: <20200925002900.465855-18-jsnow@redhat.com> In-Reply-To: <20200925002900.465855-1-jsnow@redhat.com> References: <20200925002900.465855-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 23:02:20 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" At this point, that just means using a consistent strategy for constant nam= es. constants get UPPER_CASE and names not used externally get a leading unders= core. As a preference, while renaming constants to be UPPERCASE, move them to the head of the file. Generally, it's nice to be able to audit the code that runs on import in one central place. Signed-off-by: John Snow Reviewed-by: Eduardo Habkost Reviewed-by: Cleber Rosa --- scripts/qapi/common.py | 17 +++++++---------- scripts/qapi/schema.py | 14 +++++++------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index b35318b72c..c096df0d2d 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -13,6 +13,10 @@ =20 import re =20 +EATSPACE =3D '\033EATSPACE.' +POINTER_SUFFIX =3D ' *' + EATSPACE +_C_NAME_TRANS =3D str.maketrans('.-', '__') + =20 # ENUMName -> ENUM_NAME, EnumName1 -> ENUM_NAME1 # ENUM_NAME -> ENUM_NAME, ENUM_NAME1 -> ENUM_NAME1, ENUM_Name2 -> ENUM_NAM= E2 @@ -42,9 +46,6 @@ def c_enum_const(type_name, const_name, prefix=3DNone): return camel_to_upper(type_name) + '_' + c_name(const_name, False).upp= er() =20 =20 -c_name_trans =3D str.maketrans('.-', '__') - - # Map @name to a valid C identifier. # If @protect, avoid returning certain ticklish identifiers (like # C keywords) by prepending 'q_'. @@ -82,17 +83,13 @@ def c_name(name, protect=3DTrue): 'not_eq', 'or', 'or_eq', 'xor', 'xor_eq']) # namespace pollution: polluted_words =3D set(['unix', 'errno', 'mips', 'sparc', 'i386']) - name =3D name.translate(c_name_trans) + name =3D name.translate(_C_NAME_TRANS) if protect and (name in c89_words | c99_words | c11_words | gcc_words | cpp_words | polluted_words): return 'q_' + name return name =20 =20 -eatspace =3D '\033EATSPACE.' -pointer_suffix =3D ' *' + eatspace - - class Indentation: """ Indentation level management. @@ -132,12 +129,12 @@ def decrease(self, amount: int =3D 4) -> None: =20 =20 # Generate @code with @kwds interpolated. -# Obey indent, and strip eatspace. +# Obey indent, and strip EATSPACE. def cgen(code, **kwds): raw =3D code % kwds if indent: raw =3D re.sub(r'^(?!(#|$))', str(indent), raw, flags=3Dre.MULTILI= NE) - return re.sub(re.escape(eatspace) + r' *', '', raw) + return re.sub(re.escape(EATSPACE) + r' *', '', raw) =20 =20 def mcgen(code, **kwds): diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index cfc52e1ae4..74c6b96d39 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -18,7 +18,7 @@ import os import re =20 -from .common import c_name, pointer_suffix +from .common import POINTER_SUFFIX, c_name from .error import QAPIError, QAPISemError from .expr import check_exprs from .parser import QAPISchemaParser @@ -309,7 +309,7 @@ def is_implicit(self): return True =20 def c_type(self): - return c_name(self.name) + pointer_suffix + return c_name(self.name) + POINTER_SUFFIX =20 def json_type(self): return 'array' @@ -430,7 +430,7 @@ def c_name(self): =20 def c_type(self): assert not self.is_implicit() - return c_name(self.name) + pointer_suffix + return c_name(self.name) + POINTER_SUFFIX =20 def c_unboxed_type(self): return c_name(self.name) @@ -504,7 +504,7 @@ def connect_doc(self, doc=3DNone): v.connect_doc(doc) =20 def c_type(self): - return c_name(self.name) + pointer_suffix + return c_name(self.name) + POINTER_SUFFIX =20 def json_type(self): return 'value' @@ -896,7 +896,7 @@ def _def_builtin_type(self, name, json_type, c_type): self._make_array_type(name, None) =20 def _def_predefineds(self): - for t in [('str', 'string', 'char' + pointer_suffix), + for t in [('str', 'string', 'char' + POINTER_SUFFIX), ('number', 'number', 'double'), ('int', 'int', 'int64_t'), ('int8', 'int', 'int8_t'), @@ -909,8 +909,8 @@ def _def_predefineds(self): ('uint64', 'int', 'uint64_t'), ('size', 'int', 'uint64_t'), ('bool', 'boolean', 'bool'), - ('any', 'value', 'QObject' + pointer_suffix), - ('null', 'null', 'QNull' + pointer_suffix)]: + ('any', 'value', 'QObject' + POINTER_SUFFIX), + ('null', 'null', 'QNull' + POINTER_SUFFIX)]: self._def_builtin_type(*t) self.the_empty_object_type =3D QAPISchemaObjectType( 'q_empty', None, None, None, None, None, [], None) --=20 2.26.2 From nobody Wed May 15 22:57:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600994582; cv=none; d=zohomail.com; s=zohoarc; b=Wiy+3dYFTNugYDFPWJVQVJ8OOhaY4DadW/5wzQS8xjH32nsuYl5TW/CPuX2BTzleuaRmds3OjagNFpeochwacQm5kd+OqqElQE87SAAhxemihhQrLdCCucqBQ2zhP9ZjPKn2BT9R5wAENZFKQ5lGuiTBVyIrC1FbN5r3fR7UNZs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600994582; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=G85ZFxQhuY9nZYEjGfJqXHJIQfKDaz/nSB9JQGY3ucA=; b=KxxMVefmT1eEmADL7IXxAqMW8jrz6Q9A2L2kBoqskptHsMV1CyQLKU8pnhnqPd8igf1xqGtrwlxfVy/6tT9sd2Yn9SlqUKuNnomNj5BWDWwE0LRNQoq45GtCENG3wd1n8Xi4hVB2yjlRn+bLWhzWNdiAXZjjOK6T4wC8BPyGcAw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600994582123204.60745102008912; Thu, 24 Sep 2020 17:43:02 -0700 (PDT) Received: from localhost ([::1]:38268 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLbpE-0005Gh-RM for importer@patchew.org; Thu, 24 Sep 2020 20:43:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51148) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLbc3-00011D-G7 for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:32659) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLbc1-0000BA-Qf for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:23 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-261-0Q9vc0nfNW2icaBjZjBhNw-1; Thu, 24 Sep 2020 20:29:19 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2686E6408A for ; Fri, 25 Sep 2020 00:29:18 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 83E405D9DD; Fri, 25 Sep 2020 00:29:17 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600993761; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=G85ZFxQhuY9nZYEjGfJqXHJIQfKDaz/nSB9JQGY3ucA=; b=X44avN1R792eNf4kp1LtzAOpBZ8eeK2kI8vpJckAx/PlrbplUATpkeK5KJXvcfwzZkmBrA THgKdp7E8Cezr4CR4rloCGLn6gtKIthFQjeeBX2eNUU6XJfuagekxPDp2Guw9YJVmZDGaW v5GOcR9epMeWmxNVMoiXvqv5H3nAB4o= X-MC-Unique: 0Q9vc0nfNW2icaBjZjBhNw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 18/47] qapi/common.py: Replace one-letter 'c' variable Date: Thu, 24 Sep 2020 20:28:31 -0400 Message-Id: <20200925002900.465855-19-jsnow@redhat.com> In-Reply-To: <20200925002900.465855-1-jsnow@redhat.com> References: <20200925002900.465855-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 23:02:20 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: John Snow Reviewed-by: Cleber Rosa Reviewed-by: Eduardo Habkost --- scripts/qapi/common.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index c096df0d2d..9e50070f62 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -29,14 +29,14 @@ def camel_to_upper(value): new_name =3D '' length =3D len(c_fun_str) for i in range(length): - c =3D c_fun_str[i] - # When c is upper and no '_' appears before, do more checks - if c.isupper() and (i > 0) and c_fun_str[i - 1] !=3D '_': + char =3D c_fun_str[i] + # When char is upper case and no '_' appears before, do more checks + if char.isupper() and (i > 0) and c_fun_str[i - 1] !=3D '_': if i < length - 1 and c_fun_str[i + 1].islower(): new_name +=3D '_' elif c_fun_str[i - 1].isdigit(): new_name +=3D '_' - new_name +=3D c + new_name +=3D char return new_name.lstrip('_').upper() =20 =20 --=20 2.26.2 From nobody Wed May 15 22:57:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600994788; cv=none; d=zohomail.com; s=zohoarc; b=LDNgU2sNHvCDnySiHq8GnPIiH+ewiuTGow0ZaJqNBWAEmbW2JKugrNkp2qCVRDZSsY9gZVpb+F9n3G9B+dOpFCD3Ne6PPOmXyNLx0u7ZoQTvVPsieWAEbg8fKjPZCWMDviQEhaZaBDBBhshcLrV3CG5xpf3jBQnUSMVJn+NBk1w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600994788; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=wHiKdb4KxUCEeWEQLFqKeu735EVLNLwGYY7fMxRkcYA=; b=B+ZNcuPit1C2suxoBIYvVY97LomtlGm+gND6KsXqZzBL8rQsV34h2npf8gzm4HI0Lg4JuECf5XoToteicslZi0B4kox+g1viqBsJyICswijVPOJcNPOXIZPUalBQH71plvZtlvy1ddv2zECzAKBjG96SewAObAS5cioO3nE1hc4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600994788631615.737047786792; Thu, 24 Sep 2020 17:46:28 -0700 (PDT) Received: from localhost ([::1]:46638 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLbsY-0000RZ-7d for importer@patchew.org; Thu, 24 Sep 2020 20:46:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51180) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLbcC-000131-2Q for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:44508) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLbc2-0000BO-GN for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:25 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-69-bz7uvFT6N3CD99JdsKgNbg-1; Thu, 24 Sep 2020 20:29:19 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E8D191008548 for ; Fri, 25 Sep 2020 00:29:18 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4E1005D9DD; Fri, 25 Sep 2020 00:29:18 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600993761; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wHiKdb4KxUCEeWEQLFqKeu735EVLNLwGYY7fMxRkcYA=; b=Q2XvcLiadtkd3EHddfaj6iJCqdnRrrjDfOVWI3d16578uwPsxBICq8XutKUXMiW0enBRtS pmiv4fBIdu+/mtHIZaFU9NkM88f8pwXht1wsL1l5PySvAaJ7RlA7OytVbKX5L1lbNli2OV AuPoMktPa+d7trurCSJhh/db5WVcGmQ= X-MC-Unique: bz7uvFT6N3CD99JdsKgNbg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 19/47] qapi/common.py: check with pylint Date: Thu, 24 Sep 2020 20:28:32 -0400 Message-Id: <20200925002900.465855-20-jsnow@redhat.com> In-Reply-To: <20200925002900.465855-1-jsnow@redhat.com> References: <20200925002900.465855-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 23:02:20 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Remove qapi/common.py from the pylintrc ignore list. Signed-off-by: John Snow Reviewed-by: Cleber Rosa Tested-by: Cleber Rosa Tested-by: Eduardo Habkost --- scripts/qapi/pylintrc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/qapi/pylintrc b/scripts/qapi/pylintrc index 02dd22c863..6151427a51 100644 --- a/scripts/qapi/pylintrc +++ b/scripts/qapi/pylintrc @@ -2,8 +2,7 @@ =20 # Add files or directories matching the regex patterns to the ignore list. # The regex matches against base names, not paths. -ignore-patterns=3Dcommon.py, - doc.py, +ignore-patterns=3Ddoc.py, error.py, expr.py, gen.py, --=20 2.26.2 From nobody Wed May 15 22:57:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600994969; cv=none; d=zohomail.com; s=zohoarc; b=gFg/cifVwju6KhWo7zmHe19zT/4uMbFDi1In+VglkR6Scp+PX0cJRLsY8P5ORTODnLnMJvBYL3qG0P8/Y3H2QmshRXEB3LmrjKt6gP9vh44KK6BJCfHs3Bts1cQMSHzw+EyOpQWVXfBp2HFvATgJNpMtaKOkdr37EDuT5EvHSxU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600994969; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=biFOPHLzKBCldBmC6JjpuVxRRXigQ6l8u6YAFIG2HQs=; b=Vd4PqjykZNR1thz6YJ9ux6I4iZq2DHqpKmRwIyChrLXmV2wOaPr18B14arODIj0gcQJXyh/cn9S77joCk83RkIJxJVzbUnDS1h7MEch78R+804nrK0GaNw/eiwP5oEai8GwBPKm6U4Nvu5h5HkQ5M6vf/ZJeRGRsTGEyTn+bgio= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600994969163598.1601875523456; Thu, 24 Sep 2020 17:49:29 -0700 (PDT) Received: from localhost ([::1]:57482 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLbvR-0004tR-O2 for importer@patchew.org; Thu, 24 Sep 2020 20:49:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51184) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLbcF-00014H-Df for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:21359) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLbc3-0000BX-3y for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:31 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-557-3YHvcvR2PEuPhIfaPm3lxA-1; Thu, 24 Sep 2020 20:29:20 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B4CE98015A5 for ; Fri, 25 Sep 2020 00:29:19 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1AE0F5D9DD; Fri, 25 Sep 2020 00:29:19 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600993762; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=biFOPHLzKBCldBmC6JjpuVxRRXigQ6l8u6YAFIG2HQs=; b=YI6EZ1iKWF3czjF77anGvWJzZNGqMPNAwYdbuGAs5dJwo2bKBJnYiKMbaHHSg4hYUbIql5 9V+Kt32gCgBprpjoPbp2mXrflyJDVRLoEHjS81tgnHgJ24MhdF0gNzjZUE1Pr2uilcTfL+ pUVioCXp6/CL3EdQuQSiry7T2pd59/E= X-MC-Unique: 3YHvcvR2PEuPhIfaPm3lxA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 20/47] qapi/common.py: add type hint annotations Date: Thu, 24 Sep 2020 20:28:33 -0400 Message-Id: <20200925002900.465855-21-jsnow@redhat.com> In-Reply-To: <20200925002900.465855-1-jsnow@redhat.com> References: <20200925002900.465855-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 23:02:20 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Annotations do not change runtime behavior. This commit *only* adds annotations. Signed-off-by: John Snow Reviewed-by: Eduardo Habkost Reviewed-by: Cleber Rosa --- scripts/qapi/common.py | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index 9e50070f62..d1d39fdb4c 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -12,6 +12,7 @@ # See the COPYING file in the top-level directory. =20 import re +from typing import Optional, Sequence =20 EATSPACE =3D '\033EATSPACE.' POINTER_SUFFIX =3D ' *' + EATSPACE @@ -21,7 +22,7 @@ # ENUMName -> ENUM_NAME, EnumName1 -> ENUM_NAME1 # ENUM_NAME -> ENUM_NAME, ENUM_NAME1 -> ENUM_NAME1, ENUM_Name2 -> ENUM_NAM= E2 # ENUM24_Name -> ENUM24_NAME -def camel_to_upper(value): +def camel_to_upper(value: str) -> str: c_fun_str =3D c_name(value, False) if value.isupper(): return c_fun_str @@ -40,7 +41,9 @@ def camel_to_upper(value): return new_name.lstrip('_').upper() =20 =20 -def c_enum_const(type_name, const_name, prefix=3DNone): +def c_enum_const(type_name: str, + const_name: str, + prefix: Optional[str] =3D None) -> str: if prefix is not None: type_name =3D prefix return camel_to_upper(type_name) + '_' + c_name(const_name, False).upp= er() @@ -55,7 +58,7 @@ def c_enum_const(type_name, const_name, prefix=3DNone): # into substrings of a generated C function name. # '__a.b_c' -> '__a_b_c', 'x-foo' -> 'x_foo' # protect=3DTrue: 'int' -> 'q_int'; protect=3DFalse: 'int' -> 'int' -def c_name(name, protect=3DTrue): +def c_name(name: str, protect: bool =3D True) -> str: # ANSI X3J11/88-090, 3.1.1 c89_words =3D set(['auto', 'break', 'case', 'char', 'const', 'continue= ', 'default', 'do', 'double', 'else', 'enum', 'extern', @@ -130,24 +133,24 @@ def decrease(self, amount: int =3D 4) -> None: =20 # Generate @code with @kwds interpolated. # Obey indent, and strip EATSPACE. -def cgen(code, **kwds): +def cgen(code: str, **kwds: object) -> str: raw =3D code % kwds if indent: raw =3D re.sub(r'^(?!(#|$))', str(indent), raw, flags=3Dre.MULTILI= NE) return re.sub(re.escape(EATSPACE) + r' *', '', raw) =20 =20 -def mcgen(code, **kwds): +def mcgen(code: str, **kwds: object) -> str: if code[0] =3D=3D '\n': code =3D code[1:] return cgen(code, **kwds) =20 =20 -def c_fname(filename): +def c_fname(filename: str) -> str: return re.sub(r'[^A-Za-z0-9_]', '_', filename) =20 =20 -def guardstart(name): +def guardstart(name: str) -> str: return mcgen(''' #ifndef %(name)s #define %(name)s @@ -156,7 +159,7 @@ def guardstart(name): name=3Dc_fname(name).upper()) =20 =20 -def guardend(name): +def guardend(name: str) -> str: return mcgen(''' =20 #endif /* %(name)s */ @@ -164,7 +167,7 @@ def guardend(name): name=3Dc_fname(name).upper()) =20 =20 -def gen_if(ifcond): +def gen_if(ifcond: Sequence[str]) -> str: ret =3D '' for ifc in ifcond: ret +=3D mcgen(''' @@ -173,7 +176,7 @@ def gen_if(ifcond): return ret =20 =20 -def gen_endif(ifcond): +def gen_endif(ifcond: Sequence[str]) -> str: ret =3D '' for ifc in reversed(ifcond): ret +=3D mcgen(''' @@ -182,7 +185,9 @@ def gen_endif(ifcond): return ret =20 =20 -def build_params(arg_type, boxed, extra=3DNone): +def build_params(arg_type, + boxed: bool, + extra: Optional[str] =3D None) -> str: ret =3D '' sep =3D '' if boxed: --=20 2.26.2 From nobody Wed May 15 22:57:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600995101; cv=none; d=zohomail.com; s=zohoarc; b=bahHxVefHb4QTauJNcn0xrC5IbxNI0F2gSdBN45o19xW7unoJejqlk2Ivea6VRCqraJPPq2o9gm/7tcY2v2pw5+6R7nnHcQhT4bbUyMSXttx07I35YOvvYHSoUBdcyApqJEcN+Tez5K8GRVtsek7McsnXfjexF6yZWDwS99FxUo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600995101; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ylzF/IIamaWomiXqQv96DBcpHMKC7MoFM0bc+7Gvqcs=; b=jn3ReziQhqUkvXQL6AtHqgI76Wnx5Zk5Y55q/zqml3Z2FA7FWYqJ9zVmUDoT0xqsyYfZgsivJDJV6BKeRstwgkSqGy5ziLpTogO4okK8XLucm5LcDyxJqIqtLprnLUAW0iqkcSTxFuxuAjT0gDujYf2c7dH9T2/0qh/LFuB4d4c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600995101299512.4163237440105; Thu, 24 Sep 2020 17:51:41 -0700 (PDT) Received: from localhost ([::1]:34508 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLbxb-0007Aa-LG for importer@patchew.org; Thu, 24 Sep 2020 20:51:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51408) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLbcV-0001Mr-Lz for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:49523) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLbcG-0000CO-TY for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:51 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-298-yWOmHon6N6Cv-YMPxHtpeQ-1; Thu, 24 Sep 2020 20:29:21 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 808231008549 for ; Fri, 25 Sep 2020 00:29:20 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id DCD615D9DD; Fri, 25 Sep 2020 00:29:19 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600993765; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ylzF/IIamaWomiXqQv96DBcpHMKC7MoFM0bc+7Gvqcs=; b=VJuVlEbNvX3DxhosZetB+bEO1hgEMJ07idAo9tAzKjkUeDVXhfj4zrJvQ17NATZnUUIX9V EkUPGsx80QjI3hPPOCLqBspkXLquiCPd1DqrexJREHCYSris2I6ebC55Zr0FrmSh+nlgtp gHaFPrrSRd5zPWTfsZK/qN6U81KaN7w= X-MC-Unique: yWOmHon6N6Cv-YMPxHtpeQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 21/47] qapi/common.py: Convert comments into docstrings, and elaborate Date: Thu, 24 Sep 2020 20:28:34 -0400 Message-Id: <20200925002900.465855-22-jsnow@redhat.com> In-Reply-To: <20200925002900.465855-1-jsnow@redhat.com> References: <20200925002900.465855-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/24 01:10:00 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" As docstrings, they'll show up in documentation and IDE help. The docstring style being targeted is the Sphinx documentation style. Sphinx uses an extension of ReST with "domains". We use the (implicit) Python domain, which supports a number of custom "info fields". Those info fields are documented here: https://www.sphinx-doc.org/en/master/usage/restructuredtext/domains.html#in= fo-field-lists Primarily, we use `:param X: descr`, `:return[s]: descr`, and `:raise[s] Z: when`. Everything else is the Sphinx dialect of ReST. (No, nothing checks or enforces this style that I am aware of. Sphinx either chokes or succeeds, but does not enforce a standard of what is otherwise inside the docstring. Pycharm does highlight when your param fields are not aligned with the actual fields present. It does not highlight missing return or exception statements. There is no existing style guide I am aware of that covers a standard for a minimally acceptable docstring. I am debating writing one.) Signed-off-by: John Snow Reviewed-by: Eduardo Habkost Reviewed-by: Cleber Rosa --- scripts/qapi/common.py | 53 +++++++++++++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 14 deletions(-) diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index d1d39fdb4c..82266fe56a 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -14,15 +14,24 @@ import re from typing import Optional, Sequence =20 +#: Sentinel value that causes all space to its right to be removed. EATSPACE =3D '\033EATSPACE.' POINTER_SUFFIX =3D ' *' + EATSPACE _C_NAME_TRANS =3D str.maketrans('.-', '__') =20 =20 -# ENUMName -> ENUM_NAME, EnumName1 -> ENUM_NAME1 -# ENUM_NAME -> ENUM_NAME, ENUM_NAME1 -> ENUM_NAME1, ENUM_Name2 -> ENUM_NAM= E2 -# ENUM24_Name -> ENUM24_NAME def camel_to_upper(value: str) -> str: + """ + Converts CamelCase to CAMEL_CASE. + + Examples: + ENUMName -> ENUM_NAME + EnumName1 -> ENUM_NAME1 + ENUM_NAME -> ENUM_NAME + ENUM_NAME1 -> ENUM_NAME1 + ENUM_Name2 -> ENUM_NAME2 + ENUM24_Name -> ENUM24_NAME + """ c_fun_str =3D c_name(value, False) if value.isupper(): return c_fun_str @@ -44,21 +53,33 @@ def camel_to_upper(value: str) -> str: def c_enum_const(type_name: str, const_name: str, prefix: Optional[str] =3D None) -> str: + """ + Generate a C enumeration constant name. + + :param type_name: The name of the enumeration. + :param const_name: The name of this constant. + :param prefix: Optional, prefix that overrides the type_name. + """ if prefix is not None: type_name =3D prefix return camel_to_upper(type_name) + '_' + c_name(const_name, False).upp= er() =20 =20 -# Map @name to a valid C identifier. -# If @protect, avoid returning certain ticklish identifiers (like -# C keywords) by prepending 'q_'. -# -# Used for converting 'name' from a 'name':'type' qapi definition -# into a generated struct member, as well as converting type names -# into substrings of a generated C function name. -# '__a.b_c' -> '__a_b_c', 'x-foo' -> 'x_foo' -# protect=3DTrue: 'int' -> 'q_int'; protect=3DFalse: 'int' -> 'int' def c_name(name: str, protect: bool =3D True) -> str: + """ + Map ``name`` to a valid C identifier. + + Used for converting 'name' from a 'name':'type' qapi definition + into a generated struct member, as well as converting type names + into substrings of a generated C function name. + + '__a.b_c' -> '__a_b_c', 'x-foo' -> 'x_foo' + protect=3DTrue: 'int' -> 'q_int'; protect=3DFalse: 'int' -> 'int' + + :param name: The name to map. + :param protect: If true, avoid returning certain ticklish identifiers + (like C keywords) by prepending ``q_``. + """ # ANSI X3J11/88-090, 3.1.1 c89_words =3D set(['auto', 'break', 'case', 'char', 'const', 'continue= ', 'default', 'do', 'double', 'else', 'enum', 'extern', @@ -128,12 +149,16 @@ def decrease(self, amount: int =3D 4) -> None: self._level -=3D amount =20 =20 +#: Global, current indent level for code generation. indent =3D Indentation() =20 =20 -# Generate @code with @kwds interpolated. -# Obey indent, and strip EATSPACE. def cgen(code: str, **kwds: object) -> str: + """ + Generate ``code`` with ``kwds`` interpolated. + + Obey `indent`, and strip `EATSPACE`. + """ raw =3D code % kwds if indent: raw =3D re.sub(r'^(?!(#|$))', str(indent), raw, flags=3Dre.MULTILI= NE) --=20 2.26.2 From nobody Wed May 15 22:57:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600995247; cv=none; d=zohomail.com; s=zohoarc; b=ZleLH1DEhFgZNz6rpDWBjkFkliowKXDPn8gQqRy6sqwyPmqAAzR//wmp2qw9pg0j+sWSmFs66sAwde6Yy5IFVe3KuCqEMSttrVijDfHYi6sC1E6C5NlMtiYdQkd7fBv0KeCNl4A7IOvv10dpwSs1Yc15+gHxj14/gw7q/ROK1T0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600995247; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ITtr8FRP2qqkswnra/IZey+5dXkiVYXMKJ2QMAipPdk=; b=nymUljX3wPwz15YMPRYTwjWxzYyKAWPVRw4pBPusWaV/LehVkCpfQUXUXh39qqEV/3pNRyKomITKxcX9CkbtkuHlrmxXIu45JhkSjw0eiQ6zHl+6bZamWpVx1XbXtXOmrpva6Rnf4k9CRZ2NYUCOd43Cec6z8Fz5uTjUHIxFrDo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600995247262225.82896364958515; Thu, 24 Sep 2020 17:54:07 -0700 (PDT) Received: from localhost ([::1]:43528 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLbzx-0002a0-Tc for importer@patchew.org; Thu, 24 Sep 2020 20:54:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51246) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLbcM-00016e-1f for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:41825) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLbcF-0000CG-5R for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:41 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-343-UFBDhVY8NUq3Y2FyGytoQg-1; Thu, 24 Sep 2020 20:29:22 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4F7551008548 for ; Fri, 25 Sep 2020 00:29:21 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id A7C1B5D9DD; Fri, 25 Sep 2020 00:29:20 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600993764; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ITtr8FRP2qqkswnra/IZey+5dXkiVYXMKJ2QMAipPdk=; b=EMUMylhZQgkw7UelY8aS5jASjHtG8/1W+srRR8TZB3kEZxdgA1ee4oQ3sj8slQfMm/j0mR slmc8ghSuMqKlNkJ3RnduSPDmEchOzPN9aOUOEMy5a8WbyZ5lqCO4cDoAtGMbOjs1uXzm2 dT5+HrNQGRJkIAioqJNILw7DFqLtmVI= X-MC-Unique: UFBDhVY8NUq3Y2FyGytoQg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 22/47] qapi/common.py: move build_params into gen.py Date: Thu, 24 Sep 2020 20:28:35 -0400 Message-Id: <20200925002900.465855-23-jsnow@redhat.com> In-Reply-To: <20200925002900.465855-1-jsnow@redhat.com> References: <20200925002900.465855-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 23:02:20 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Including it in common.py creates a circular import dependency; schema relies on common, but common.build_params requires a type annotation from schema. To type this properly, it needs to be moved outside the cycle. Signed-off-by: John Snow Reviewed-by: Eduardo Habkost Reviewed-by: Cleber Rosa --- scripts/qapi/commands.py | 9 +++++++-- scripts/qapi/common.py | 23 ----------------------- scripts/qapi/events.py | 9 ++------- scripts/qapi/gen.py | 31 +++++++++++++++++++++++++++++-- 4 files changed, 38 insertions(+), 34 deletions(-) diff --git a/scripts/qapi/commands.py b/scripts/qapi/commands.py index 5dc2f5a9fa..f67393f871 100644 --- a/scripts/qapi/commands.py +++ b/scripts/qapi/commands.py @@ -13,8 +13,13 @@ See the COPYING file in the top-level directory. """ =20 -from .common import build_params, c_name, mcgen -from .gen import QAPIGenCCode, QAPISchemaModularCVisitor, ifcontext +from .common import c_name, mcgen +from .gen import ( + QAPIGenCCode, + QAPISchemaModularCVisitor, + build_params, + ifcontext, +) =20 =20 def gen_command_decl(name, arg_type, boxed, ret_type): diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index 82266fe56a..430466be49 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -208,26 +208,3 @@ def gen_endif(ifcond: Sequence[str]) -> str: #endif /* %(cond)s */ ''', cond=3Difc) return ret - - -def build_params(arg_type, - boxed: bool, - extra: Optional[str] =3D None) -> str: - ret =3D '' - sep =3D '' - if boxed: - assert arg_type - ret +=3D '%s arg' % arg_type.c_param_type() - sep =3D ', ' - elif arg_type: - assert not arg_type.variants - for memb in arg_type.members: - ret +=3D sep - sep =3D ', ' - if memb.optional: - ret +=3D 'bool has_%s, ' % c_name(memb.name) - ret +=3D '%s %s' % (memb.type.c_param_type(), - c_name(memb.name)) - if extra: - ret +=3D sep + extra - return ret if ret else 'void' diff --git a/scripts/qapi/events.py b/scripts/qapi/events.py index 6b3afa14d7..f840a62ed9 100644 --- a/scripts/qapi/events.py +++ b/scripts/qapi/events.py @@ -12,13 +12,8 @@ See the COPYING file in the top-level directory. """ =20 -from .common import ( - build_params, - c_enum_const, - c_name, - mcgen, -) -from .gen import QAPISchemaModularCVisitor, ifcontext +from .common import c_enum_const, c_name, mcgen +from .gen import QAPISchemaModularCVisitor, build_params, ifcontext from .schema import QAPISchemaEnumMember from .types import gen_enum, gen_enum_lookup =20 diff --git a/scripts/qapi/gen.py b/scripts/qapi/gen.py index d37339fe8f..c1e65f2e52 100644 --- a/scripts/qapi/gen.py +++ b/scripts/qapi/gen.py @@ -2,9 +2,11 @@ # # QAPI code generation # -# Copyright (c) 2018-2019 Red Hat Inc. +# Copyright IBM, Corp. 2011 +# Copyright (c) 2013-2019 Red Hat Inc. # # Authors: +# Anthony Liguori # Markus Armbruster # Marc-Andr=C3=A9 Lureau # @@ -15,16 +17,18 @@ import errno import os import re +from typing import Optional =20 from .common import ( c_fname, + c_name, gen_endif, gen_if, guardend, guardstart, mcgen, ) -from .schema import QAPISchemaVisitor +from .schema import QAPISchemaObjectType, QAPISchemaVisitor =20 =20 class QAPIGen: @@ -90,6 +94,29 @@ def _wrap_ifcond(ifcond, before, after): return out =20 =20 +def build_params(arg_type: Optional[QAPISchemaObjectType], + boxed: bool, + extra: Optional[str] =3D None) -> str: + ret =3D '' + sep =3D '' + if boxed: + assert arg_type + ret +=3D '%s arg' % arg_type.c_param_type() + sep =3D ', ' + elif arg_type: + assert not arg_type.variants + for memb in arg_type.members: + ret +=3D sep + sep =3D ', ' + if memb.optional: + ret +=3D 'bool has_%s, ' % c_name(memb.name) + ret +=3D '%s %s' % (memb.type.c_param_type(), + c_name(memb.name)) + if extra: + ret +=3D sep + extra + return ret if ret else 'void' + + class QAPIGenCCode(QAPIGen): =20 def __init__(self, fname): --=20 2.26.2 From nobody Wed May 15 22:57:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600995165; cv=none; d=zohomail.com; s=zohoarc; b=X99G+TJrymkdhX2vkQa3yQ/mYn4TntaaxJXNH/AVjqZBccHwlhIdGgCDZ6StlMDdlSHJnTsnv9AiBp9ghs4touG9nbKLnmgvAVAVW+unrc7D1qfcoSPWDep0ifBS6+CUGvYyscMc7nrQcmGh9V74Q7jbNgcZZKSfyPwiwEisMpA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600995165; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=erm01s8U0BV2hK5tv59L7Qcnc1kFpvd5KvbBrL2CWKo=; b=Re3AzrU9nm/Oy4mGA3enY1F2ia7jFiFZ+Xw2R2WF8qfmWRdQPY6c6C4nT52RfA8eKiqEqKCbChmPKzTyIVQ3TITUH+AVqK8wjSx1mP2TwgiLWszAKorIugDPs341FdNTrH4TOjZ/TeVn1yLg7dWFZmKNKG5rj2yjZm690uA9fso= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600995165825496.61985578308895; Thu, 24 Sep 2020 17:52:45 -0700 (PDT) Received: from localhost ([::1]:37710 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLbye-00009S-Ep for importer@patchew.org; Thu, 24 Sep 2020 20:52:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51294) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLbcN-0001Bl-QT for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:37870) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLbcG-0000Cn-R4 for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:43 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-279-XiVLWSBAOMq0Up_g_QTIvg-1; Thu, 24 Sep 2020 20:29:23 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 19ED6188C122 for ; Fri, 25 Sep 2020 00:29:22 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 764665D9DD; Fri, 25 Sep 2020 00:29:21 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600993768; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=erm01s8U0BV2hK5tv59L7Qcnc1kFpvd5KvbBrL2CWKo=; b=ETzoW3+NJgjcdVJwcojW1X1Gsf7lhxIXrFZ5/v3P36Abp3mY55MJKbp12YysL474f8sxq8 3JeWGiKO4rWSGQMXaNulN0uEM6O8h7Wuz5nACm/xNHoyuXLUKEmHxCZ/btjfRjKOmPN5rS 19qyCn9HzMF5ld9oaHSL7JCvZhkXA9g= X-MC-Unique: XiVLWSBAOMq0Up_g_QTIvg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 23/47] qapi: establish mypy type-checking baseline Date: Thu, 24 Sep 2020 20:28:36 -0400 Message-Id: <20200925002900.465855-24-jsnow@redhat.com> In-Reply-To: <20200925002900.465855-1-jsnow@redhat.com> References: <20200925002900.465855-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 23:02:20 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Fix two very minor issues, and then establish a mypy type-checking baseline. Like pylint, this should be run from the folder above: > mypy --config-file=3Dqapi/mypy.ini qapi/ This is designed and tested for mypy 0.770 or greater. Signed-off-by: John Snow Tested-by: Eduardo Habkost Reviewed-by: Cleber Rosa Tested-by: Cleber Rosa --- scripts/qapi/doc.py | 3 +- scripts/qapi/mypy.ini | 65 ++++++++++++++++++++++++++++++++++++++++++ scripts/qapi/schema.py | 3 +- 3 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 scripts/qapi/mypy.ini diff --git a/scripts/qapi/doc.py b/scripts/qapi/doc.py index 1acb773e0a..42ef19ddf6 100644 --- a/scripts/qapi/doc.py +++ b/scripts/qapi/doc.py @@ -6,7 +6,8 @@ =20 import re =20 -from .gen import QAPIGenDoc, QAPISchemaVisitor +from .gen import QAPIGenDoc +from .schema import QAPISchemaVisitor =20 _MSG =3D ''' @deftypefn {type} {{}} {name} diff --git a/scripts/qapi/mypy.ini b/scripts/qapi/mypy.ini new file mode 100644 index 0000000000..a0f2365a53 --- /dev/null +++ b/scripts/qapi/mypy.ini @@ -0,0 +1,65 @@ +[mypy] +strict =3D True +strict_optional =3D False +disallow_untyped_calls =3D False +python_version =3D 3.6 + +[mypy-qapi.commands] +disallow_untyped_defs =3D False +disallow_incomplete_defs =3D False +check_untyped_defs =3D False + +[mypy-qapi.doc] +disallow_subclassing_any =3D False +disallow_untyped_defs =3D False +disallow_incomplete_defs =3D False + +[mypy-qapi.error] +disallow_untyped_defs =3D False +disallow_incomplete_defs =3D False +check_untyped_defs =3D False + +[mypy-qapi.events] +disallow_untyped_defs =3D False +disallow_incomplete_defs =3D False +check_untyped_defs =3D False + +[mypy-qapi.expr] +disallow_untyped_defs =3D False +disallow_incomplete_defs =3D False +check_untyped_defs =3D False + +[mypy-qapi.gen] +disallow_untyped_defs =3D False +disallow_incomplete_defs =3D False +check_untyped_defs =3D False + +[mypy-qapi.introspect] +disallow_untyped_defs =3D False +disallow_incomplete_defs =3D False +check_untyped_defs =3D False + +[mypy-qapi.parser] +disallow_untyped_defs =3D False +disallow_incomplete_defs =3D False +check_untyped_defs =3D False + +[mypy-qapi.schema] +disallow_untyped_defs =3D False +disallow_incomplete_defs =3D False +check_untyped_defs =3D False + +[mypy-qapi.source] +disallow_untyped_defs =3D False +disallow_incomplete_defs =3D False +check_untyped_defs =3D False + +[mypy-qapi.types] +disallow_untyped_defs =3D False +disallow_incomplete_defs =3D False +check_untyped_defs =3D False + +[mypy-qapi.visit] +disallow_untyped_defs =3D False +disallow_incomplete_defs =3D False +check_untyped_defs =3D False diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 74c6b96d39..483b4b68df 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -17,6 +17,7 @@ from collections import OrderedDict import os import re +from typing import Optional =20 from .common import POINTER_SUFFIX, c_name from .error import QAPIError, QAPISemError @@ -25,7 +26,7 @@ =20 =20 class QAPISchemaEntity: - meta =3D None + meta: Optional[str] =3D None =20 def __init__(self, name, info, doc, ifcond=3DNone, features=3DNone): assert name is None or isinstance(name, str) --=20 2.26.2 From nobody Wed May 15 22:57:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600994911; cv=none; d=zohomail.com; s=zohoarc; b=XSwljrmIlteaIYQF7lbhLaJUPk2tlvaZcR19+RGuVPGhEwNnaAUsVgxR/lJh6j+3Ks/PiRhF0vh0HVhw+Y/WWcx0i5VPx5u3I6zd7V/2a3xs/l07ubKOuBQqy3+diQCL9bMJRTEfNzTjM4KQXaQ6YSvXQE8BEvvbmJIHY475xh8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600994911; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Y+Ir7909UwwubpEAdy5Dbc48ZC62f1Oe2iGB0o5pX5c=; b=LhOCIh9tVQtbUmBwdmrhe9Xo6oC7zc5Ees/lLccfAb4AhP+k9oOeNrgCPoir3oBTF8B4fpGeOrPSJbLch/lbAC1MaJM3KW5uAH75Ly5ZhhLoeic3ODC7rGga+LQHR0356+N2QEx0eSpvPVpscnw/oImq4NB9yYdubWo6Tcz6H4k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600994911220863.9978060977268; Thu, 24 Sep 2020 17:48:31 -0700 (PDT) Received: from localhost ([::1]:54234 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLbuY-0003ZH-12 for importer@patchew.org; Thu, 24 Sep 2020 20:48:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51256) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLbcM-00017r-Ff for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:30069) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLbcF-0000CW-Pz for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:42 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-595-BBjdWJTDNVeMcI2e7HxXiw-1; Thu, 24 Sep 2020 20:29:23 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DB8A81008549 for ; Fri, 25 Sep 2020 00:29:22 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4141C5D9DD; Fri, 25 Sep 2020 00:29:22 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600993766; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Y+Ir7909UwwubpEAdy5Dbc48ZC62f1Oe2iGB0o5pX5c=; b=N/4HsBTc8z5zlL8r2L4u9dpdwYfmqIo4nqsdek19H4C8Gp/Ek3Z9IIYDv0bpIcnnknoU93 YRr8jJgsv1xBNrFUjhnbSX592Hdo5ZKJ3JD2QmC1t9gsjjdWMnA88ugCVqwHEXA4kJVfkN Wk+IrJ1mkhZnMM0K4BDzB5piAfB3m4w= X-MC-Unique: BBjdWJTDNVeMcI2e7HxXiw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 24/47] qapi/events.py: add type hint annotations Date: Thu, 24 Sep 2020 20:28:37 -0400 Message-Id: <20200925002900.465855-25-jsnow@redhat.com> In-Reply-To: <20200925002900.465855-1-jsnow@redhat.com> References: <20200925002900.465855-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 23:02:20 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Annotations do not change runtime behavior. This commit *only* adds annotations. Signed-off-by: John Snow Reviewed-by: Eduardo Habkost Reviewed-by: Cleber Rosa --- scripts/qapi/events.py | 46 ++++++++++++++++++++++++++++++++---------- scripts/qapi/mypy.ini | 5 ----- 2 files changed, 35 insertions(+), 16 deletions(-) diff --git a/scripts/qapi/events.py b/scripts/qapi/events.py index f840a62ed9..57e0939e96 100644 --- a/scripts/qapi/events.py +++ b/scripts/qapi/events.py @@ -12,19 +12,31 @@ See the COPYING file in the top-level directory. """ =20 +from typing import List + from .common import c_enum_const, c_name, mcgen from .gen import QAPISchemaModularCVisitor, build_params, ifcontext -from .schema import QAPISchemaEnumMember +from .schema import ( + QAPISchema, + QAPISchemaEnumMember, + QAPISchemaFeature, + QAPISchemaObjectType, +) +from .source import QAPISourceInfo from .types import gen_enum, gen_enum_lookup =20 =20 -def build_event_send_proto(name, arg_type, boxed): +def build_event_send_proto(name: str, + arg_type: QAPISchemaObjectType, + boxed: bool) -> str: return 'void qapi_event_send_%(c_name)s(%(param)s)' % { 'c_name': c_name(name.lower()), 'param': build_params(arg_type, boxed)} =20 =20 -def gen_event_send_decl(name, arg_type, boxed): +def gen_event_send_decl(name: str, + arg_type: QAPISchemaObjectType, + boxed: bool) -> str: return mcgen(''' =20 %(proto)s; @@ -33,7 +45,7 @@ def gen_event_send_decl(name, arg_type, boxed): =20 =20 # Declare and initialize an object 'qapi' using parameters from build_para= ms() -def gen_param_var(typ): +def gen_param_var(typ: QAPISchemaObjectType) -> str: assert not typ.variants ret =3D mcgen(''' %(c_name)s param =3D { @@ -61,7 +73,11 @@ def gen_param_var(typ): return ret =20 =20 -def gen_event_send(name, arg_type, boxed, event_enum_name, event_emit): +def gen_event_send(name: str, + arg_type: QAPISchemaObjectType, + boxed: bool, + event_enum_name: str, + event_emit: str) -> str: # FIXME: Our declaration of local variables (and of 'errp' in the # parameter list) can collide with exploded members of the event's # data type passed in as parameters. If this collision ever hits in @@ -137,15 +153,15 @@ def gen_event_send(name, arg_type, boxed, event_enum_= name, event_emit): =20 class QAPISchemaGenEventVisitor(QAPISchemaModularCVisitor): =20 - def __init__(self, prefix): + def __init__(self, prefix: str): super().__init__( prefix, 'qapi-events', ' * Schema-defined QAPI/QMP events', None, __doc__) self._event_enum_name =3D c_name(prefix + 'QAPIEvent', protect=3DF= alse) - self._event_enum_members =3D [] + self._event_enum_members: List[QAPISchemaEnumMember] =3D [] self._event_emit_name =3D c_name(prefix + 'qapi_event_emit') =20 - def _begin_user_module(self, name): + def _begin_user_module(self, name: str) -> None: events =3D self._module_basename('qapi-events', name) types =3D self._module_basename('qapi-types', name) visit =3D self._module_basename('qapi-visit', name) @@ -168,7 +184,7 @@ def _begin_user_module(self, name): ''', types=3Dtypes)) =20 - def visit_end(self): + def visit_end(self) -> None: self._add_system_module('emit', ' * QAPI Events emission') self._genc.preamble_add(mcgen(''' #include "qemu/osdep.h" @@ -189,7 +205,13 @@ def visit_end(self): event_emit=3Dself._event_emit_name, event_enum=3Dself._event_enum_name)) =20 - def visit_event(self, name, info, ifcond, features, arg_type, boxed): + def visit_event(self, + name: str, + info: QAPISourceInfo, + ifcond: List[str], + features: List[QAPISchemaFeature], + arg_type: QAPISchemaObjectType, + boxed: bool) -> None: with ifcontext(ifcond, self._genh, self._genc): self._genh.add(gen_event_send_decl(name, arg_type, boxed)) self._genc.add(gen_event_send(name, arg_type, boxed, @@ -200,7 +222,9 @@ def visit_event(self, name, info, ifcond, features, arg= _type, boxed): self._event_enum_members.append(QAPISchemaEnumMember(name, None)) =20 =20 -def gen_events(schema, output_dir, prefix): +def gen_events(schema: QAPISchema, + output_dir: str, + prefix: str) -> None: vis =3D QAPISchemaGenEventVisitor(prefix) schema.visit(vis) vis.write(output_dir) diff --git a/scripts/qapi/mypy.ini b/scripts/qapi/mypy.ini index a0f2365a53..b668776d94 100644 --- a/scripts/qapi/mypy.ini +++ b/scripts/qapi/mypy.ini @@ -19,11 +19,6 @@ disallow_untyped_defs =3D False disallow_incomplete_defs =3D False check_untyped_defs =3D False =20 -[mypy-qapi.events] -disallow_untyped_defs =3D False -disallow_incomplete_defs =3D False -check_untyped_defs =3D False - [mypy-qapi.expr] disallow_untyped_defs =3D False disallow_incomplete_defs =3D False --=20 2.26.2 From nobody Wed May 15 22:57:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600995408; cv=none; d=zohomail.com; s=zohoarc; b=FxqTIUOMlVBq5/rRAqtShU27j3mk614d4RHgeCUrwAHyOhB6vJlzIuMydpSALvenpRDHk0rUkFQ49l2A7qgBEA65yHO/qiL11AHuVEABA9x4Eq8wZReBhIswgfQjxOWGlbs5vQS9xFaujLtAKyx3veV0qxcFg7HfCpRAKSwflTA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600995408; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=g0VDozwZmG4h2xMcdgZPrspcqeWEjJ1N+oifo4zyE7I=; b=aCreyScynSpHL3Eb4dGAufUm35kSLWU6IsR8R1i9890tDVBme/mm3b5nojHOXiTQ/PHdcZyLHQFDRk5uLPfdrWyQgCByQaJoR0Zgm5S9NiimFWMuCPbFQeup7zMsGzJ73yxSz5vEjagV6FZDglNLX8tYmMde8UIIGv9k46JBXg0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600995408701852.331731408702; Thu, 24 Sep 2020 17:56:48 -0700 (PDT) Received: from localhost ([::1]:51820 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLc2Z-0006DD-CH for importer@patchew.org; Thu, 24 Sep 2020 20:56:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51290) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLbcN-0001Au-Ha for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:24154) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLbcG-0000CY-PU for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:43 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-443-AYkYzOUoM9qGkcmiJGaScA-1; Thu, 24 Sep 2020 20:29:24 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A97DC801002 for ; Fri, 25 Sep 2020 00:29:23 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0DD655D9DD; Fri, 25 Sep 2020 00:29:22 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600993766; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g0VDozwZmG4h2xMcdgZPrspcqeWEjJ1N+oifo4zyE7I=; b=f/o0I1DoHtq7sNzZIRMVPX7UfqBXfkILEUpUe4SPbSFd5wdyQkUqqh5k5AjH+/UO+8Wvnq Xhm/O6JfZ6r1C6O9Ptx/QnRRBCm03zd4nk2S/HOVROCW6fqGQ7XjIkf0baF400JUPLRMJp lPlbf0pU/YgbdPWGbnzxYMUGqt/y7OQ= X-MC-Unique: AYkYzOUoM9qGkcmiJGaScA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 25/47] qapi/events.py: Move comments into docstrings Date: Thu, 24 Sep 2020 20:28:38 -0400 Message-Id: <20200925002900.465855-26-jsnow@redhat.com> In-Reply-To: <20200925002900.465855-1-jsnow@redhat.com> References: <20200925002900.465855-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 23:02:20 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: John Snow Reviewed-by: Eduardo Habkost Reviewed-by: Cleber Rosa --- scripts/qapi/events.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/qapi/events.py b/scripts/qapi/events.py index 57e0939e96..9f868589bb 100644 --- a/scripts/qapi/events.py +++ b/scripts/qapi/events.py @@ -44,8 +44,10 @@ def gen_event_send_decl(name: str, proto=3Dbuild_event_send_proto(name, arg_type, boxed)) =20 =20 -# Declare and initialize an object 'qapi' using parameters from build_para= ms() def gen_param_var(typ: QAPISchemaObjectType) -> str: + """ + Declare and initialize a qapi object, using parameters from `build_par= ams`. + """ assert not typ.variants ret =3D mcgen(''' %(c_name)s param =3D { --=20 2.26.2 From nobody Wed May 15 22:57:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600995550; cv=none; d=zohomail.com; s=zohoarc; b=oBfjpeYbTSQsNsARCHyrsFyKnire8ergIqNbsN9Kl/RJ5Ep2A59hYrwH90XlaMU92Ud5pbGpiYI8E+OSfaQoC4jA+DkmdoTDZuablVde0Z6do0h3kEbCabZoZGm4Ur31/BkW62GcYe/LhMOICbVxhytGqWyf2vB9+zx2nl1Neyo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600995550; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=JC1bz0wKOCwex/SFfWEIER9tx9xou2AUTwrAn/BNUM8=; b=KMUdvCE2Gz2RwiZv5Uh/9WAGZg1Rd2kNxlghnfgIx2XttN1YjrXbTwgBeIpkSzoW9YQTppfnlQk+GapZjgrhyTr1ZhgpMxX22CEnHteCi79QjIvJKxxae49AXBMsaZKEVyYLMPC+Kk9iST9nO9jXFEtvk5F1jIyk6PkTZf57imQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600995550910289.91296299523106; Thu, 24 Sep 2020 17:59:10 -0700 (PDT) Received: from localhost ([::1]:60210 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLc4r-0001OR-Fr for importer@patchew.org; Thu, 24 Sep 2020 20:59:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51366) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLbcQ-0001Gf-Pn for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:44662) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLbcL-0000Ce-Lk for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:46 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-499-TXwg1uqEMkGmXpCyO_nA9Q-1; Thu, 24 Sep 2020 20:29:25 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 70D3D188C125 for ; Fri, 25 Sep 2020 00:29:24 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id CED555D9DD; Fri, 25 Sep 2020 00:29:23 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600993767; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JC1bz0wKOCwex/SFfWEIER9tx9xou2AUTwrAn/BNUM8=; b=XmGX8FC8nVWxIXWSuoRqcFQEB72L09of9fXYGWBewOWxFL0OnGBU5B6QmaaMBga1x1rOZ9 1jS2Zvo2bhivBrqJxox+U0MAGdfwWDy2mYJFQoBIdCa7Wmk1qiheLScFREn2w7n21iP/2S 6WL9yyW2QQycTIEHbg7Bg7rV+no31Q8= X-MC-Unique: TXwg1uqEMkGmXpCyO_nA9Q-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 26/47] qapi/commands.py: Don't re-bind to variable of different type Date: Thu, 24 Sep 2020 20:28:39 -0400 Message-Id: <20200925002900.465855-27-jsnow@redhat.com> In-Reply-To: <20200925002900.465855-1-jsnow@redhat.com> References: <20200925002900.465855-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 23:02:20 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Mypy isn't a fan of rebinding a variable with a new data type. It's easy enough to avoid. Signed-off-by: John Snow Reviewed-by: Eduardo Habkost Reviewed-by: Cleber Rosa --- scripts/qapi/commands.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/qapi/commands.py b/scripts/qapi/commands.py index f67393f871..586774a23c 100644 --- a/scripts/qapi/commands.py +++ b/scripts/qapi/commands.py @@ -195,14 +195,12 @@ def gen_register_command(name, success_response, allo= w_oob, allow_preconfig): if not options: options =3D ['QCO_NO_OPTIONS'] =20 - options =3D " | ".join(options) - ret =3D mcgen(''' qmp_register_command(cmds, "%(name)s", qmp_marshal_%(c_name)s, %(opts)s); ''', name=3Dname, c_name=3Dc_name(name), - opts=3Doptions) + opts=3D" | ".join(options)) return ret =20 =20 --=20 2.26.2 From nobody Wed May 15 22:57:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600994913; cv=none; d=zohomail.com; s=zohoarc; b=btur9Dtwgt7dpsKvarUXeDxKeeYXOW3xYnICixvWeC7+QhHSaT5KVJyzzr3du5lOytG6aR/1mKCWmUGk3WGYXKrJiYiiecKHtWTvv0rzsFn/9ikPig0ACOeB/3wH836fmYbh+bBaNnPypXoubEllZmNbEMTXOM/FICQ0523oGEY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600994913; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=EcZzCDAAodwXkbInNEhy36YJxjFeqEwUu0AdiLobeVQ=; b=YGCGhiiqBCL1r8z9XSyMwMlz0UiTOy1negidYXAZTPuIDKmo2qFnSoL+77emP8Ow1sOzUfornqEXqej+4B5kOpjPA4vTvFjz7IT8eNytxgUucOTLCA3e8b+PXAE5jd8K7il/26MaTPXNl6Q/B5XAlg4S10HBY23HKGqGZiN02qc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600994913048728.0182738088865; Thu, 24 Sep 2020 17:48:33 -0700 (PDT) Received: from localhost ([::1]:54480 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLbuZ-0003fb-P5 for importer@patchew.org; Thu, 24 Sep 2020 20:48:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51356) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLbcQ-0001FR-3L for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:44572) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLbcG-0000Cq-TE for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:45 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-61-lUz1EovePrOtRv2QRVRorA-1; Thu, 24 Sep 2020 20:29:26 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 44325188C128 for ; Fri, 25 Sep 2020 00:29:25 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9BC9F5D9DD; Fri, 25 Sep 2020 00:29:24 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600993768; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EcZzCDAAodwXkbInNEhy36YJxjFeqEwUu0AdiLobeVQ=; b=Feq32QGMnSdqJi8KqWtPaAVMnRGsPcN11yOVm/ceMlQi6XkQyWYa5EuQWM30ukn9hJpDUT z+ciMJR7xfLuT00z7A5iLrVon7FJOa3RLdo6IWDTtwYK0JZHLUYxRTs4B9BBqMiVAHdfJ/ ZxJ4IGYZK5qPXsGpWZECn72djmK2DAQ= X-MC-Unique: lUz1EovePrOtRv2QRVRorA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 27/47] qapi/commands.py: add type hint annotations Date: Thu, 24 Sep 2020 20:28:40 -0400 Message-Id: <20200925002900.465855-28-jsnow@redhat.com> In-Reply-To: <20200925002900.465855-1-jsnow@redhat.com> References: <20200925002900.465855-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 23:02:20 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Annotations do not change runtime behavior. This commit *only* adds annotations. Signed-off-by: John Snow Reviewed-by: Eduardo Habkost Reviewed-by: Cleber Rosa --- scripts/qapi/commands.py | 71 ++++++++++++++++++++++++++++++---------- 1 file changed, 54 insertions(+), 17 deletions(-) diff --git a/scripts/qapi/commands.py b/scripts/qapi/commands.py index 586774a23c..24f347a3f1 100644 --- a/scripts/qapi/commands.py +++ b/scripts/qapi/commands.py @@ -13,16 +13,34 @@ See the COPYING file in the top-level directory. """ =20 +from typing import ( + Dict, + List, + Optional, + Set, +) + from .common import c_name, mcgen from .gen import ( + QAPIGenC, QAPIGenCCode, QAPISchemaModularCVisitor, build_params, ifcontext, ) +from .schema import ( + QAPISchema, + QAPISchemaFeature, + QAPISchemaObjectType, + QAPISchemaType, +) +from .source import QAPISourceInfo =20 =20 -def gen_command_decl(name, arg_type, boxed, ret_type): +def gen_command_decl(name: str, + arg_type: Optional[QAPISchemaObjectType], + boxed: bool, + ret_type: Optional[QAPISchemaType]) -> str: return mcgen(''' %(c_type)s qmp_%(c_name)s(%(params)s); ''', @@ -31,7 +49,10 @@ def gen_command_decl(name, arg_type, boxed, ret_type): params=3Dbuild_params(arg_type, boxed, 'Error **errp')) =20 =20 -def gen_call(name, arg_type, boxed, ret_type): +def gen_call(name: str, + arg_type: Optional[QAPISchemaObjectType], + boxed: bool, + ret_type: Optional[QAPISchemaType]) -> str: ret =3D '' =20 argstr =3D '' @@ -67,7 +88,7 @@ def gen_call(name, arg_type, boxed, ret_type): return ret =20 =20 -def gen_marshal_output(ret_type): +def gen_marshal_output(ret_type: QAPISchemaType) -> str: return mcgen(''' =20 static void qmp_marshal_output_%(c_name)s(%(c_type)s ret_in, @@ -88,19 +109,22 @@ def gen_marshal_output(ret_type): c_type=3Dret_type.c_type(), c_name=3Dret_type.c_name()) =20 =20 -def build_marshal_proto(name): +def build_marshal_proto(name: str) -> str: return ('void qmp_marshal_%s(QDict *args, QObject **ret, Error **errp)' % c_name(name)) =20 =20 -def gen_marshal_decl(name): +def gen_marshal_decl(name: str) -> str: return mcgen(''' %(proto)s; ''', proto=3Dbuild_marshal_proto(name)) =20 =20 -def gen_marshal(name, arg_type, boxed, ret_type): +def gen_marshal(name: str, + arg_type: Optional[QAPISchemaObjectType], + boxed: bool, + ret_type: Optional[QAPISchemaType]) -> str: have_args =3D boxed or (arg_type and not arg_type.is_empty()) =20 ret =3D mcgen(''' @@ -182,7 +206,10 @@ def gen_marshal(name, arg_type, boxed, ret_type): return ret =20 =20 -def gen_register_command(name, success_response, allow_oob, allow_preconfi= g): +def gen_register_command(name: str, + success_response: bool, + allow_oob: bool, + allow_preconfig: bool) -> str: options =3D [] =20 if not success_response: @@ -204,7 +231,7 @@ def gen_register_command(name, success_response, allow_= oob, allow_preconfig): return ret =20 =20 -def gen_registry(registry, prefix): +def gen_registry(registry: str, prefix: str) -> str: ret =3D mcgen(''' =20 void %(c_prefix)sqmp_init_marshal(QmpCommandList *cmds) @@ -221,15 +248,14 @@ def gen_registry(registry, prefix): =20 =20 class QAPISchemaGenCommandVisitor(QAPISchemaModularCVisitor): - - def __init__(self, prefix): + def __init__(self, prefix: str): super().__init__( prefix, 'qapi-commands', ' * Schema-defined QAPI/QMP commands', None, __doc__) self._regy =3D QAPIGenCCode(None) - self._visited_ret_types =3D {} + self._visited_ret_types: Dict[QAPIGenC, Set[QAPISchemaType]] =3D {} =20 - def _begin_user_module(self, name): + def _begin_user_module(self, name: str) -> None: self._visited_ret_types[self._genc] =3D set() commands =3D self._module_basename('qapi-commands', name) types =3D self._module_basename('qapi-types', name) @@ -253,7 +279,7 @@ def _begin_user_module(self, name): ''', types=3Dtypes)) =20 - def visit_end(self): + def visit_end(self) -> None: self._add_system_module('init', ' * QAPI Commands initialization') self._genh.add(mcgen(''' #include "qapi/qmp/dispatch.h" @@ -269,9 +295,18 @@ def visit_end(self): prefix=3Dself._prefix)) self._genc.add(gen_registry(self._regy.get_content(), self._prefix= )) =20 - def visit_command(self, name, info, ifcond, features, - arg_type, ret_type, gen, success_response, boxed, - allow_oob, allow_preconfig): + def visit_command(self, + name: str, + info: QAPISourceInfo, + ifcond: List[str], + features: List[QAPISchemaFeature], + arg_type: Optional[QAPISchemaObjectType], + ret_type: Optional[QAPISchemaType], + gen: bool, + success_response: bool, + boxed: bool, + allow_oob: bool, + allow_preconfig: bool) -> None: if not gen: return # FIXME: If T is a user-defined type, the user is responsible @@ -292,7 +327,9 @@ def visit_command(self, name, info, ifcond, features, allow_oob, allow_preconfig= )) =20 =20 -def gen_commands(schema, output_dir, prefix): +def gen_commands(schema: QAPISchema, + output_dir: str, + prefix: str) -> None: vis =3D QAPISchemaGenCommandVisitor(prefix) schema.visit(vis) vis.write(output_dir) --=20 2.26.2 From nobody Wed May 15 22:57:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600994570; cv=none; d=zohomail.com; s=zohoarc; b=PTEJlWUbt36JEcip5hy6cs58UJ/pwBDUtziPD27+BZWUZi0gsuaDJohhIXPD1ioJyKOHWguiMGnDz6lwnyad1bdUDjNx5tCPOQZKUNlQN0zF/bz24Wm0yS9KPfTrO4qWs6t//+hlUaYuIk+qI9TzLpoQ9/KVMO8MAB88AFr8DTg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600994570; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0UwIbjyB0chSx2kXG1CfAG0/PqtX/jJxxt9+SS423G8=; b=NmzjgBUk+nSyVYREWcVLJbWd6/jj667S7Fu1zK6pmXxl8/ekLdjmp+bDReC4naitQAmLER5wF2WHNoekYilY2LnsPhsqPcs7JJzmTINipJ0tMS99N/EwEyr7r4GLdjNHk0xL/cYq+hhJ/SI18p/bRCybvnBDCfr/NWPj5JrLHGs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600994570597910.9710360373871; Thu, 24 Sep 2020 17:42:50 -0700 (PDT) Received: from localhost ([::1]:37770 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLbp3-00054S-AT for importer@patchew.org; Thu, 24 Sep 2020 20:42:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51292) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLbcN-0001BB-LF for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:28660) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLbcG-0000Cx-QK for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:43 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-425-o-c1e57zO6KEyy1ePmlZLA-1; Thu, 24 Sep 2020 20:29:26 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 137031008550 for ; Fri, 25 Sep 2020 00:29:26 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 69EB75D9DD; Fri, 25 Sep 2020 00:29:25 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600993768; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0UwIbjyB0chSx2kXG1CfAG0/PqtX/jJxxt9+SS423G8=; b=INvd7znIRgLP0v9zcVkpo5YXtVVdLk3b13IEe3hSD1uxOuqW/gv0LgVoul5JalmIm+kBNz e55xJCJQVbyADHRgJdzCsYfhNAb9DkVDvwuIV9K3osF/5EJTxOtnk05KL2vmhY57oLZ9pR onmN8JCdCEXpHO2Hmgunu/2BB7qX/ig= X-MC-Unique: o-c1e57zO6KEyy1ePmlZLA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 28/47] qapi/commands.py: enable checking with mypy Date: Thu, 24 Sep 2020 20:28:41 -0400 Message-Id: <20200925002900.465855-29-jsnow@redhat.com> In-Reply-To: <20200925002900.465855-1-jsnow@redhat.com> References: <20200925002900.465855-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 23:02:20 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: John Snow Reviewed-by: Eduardo Habkost Reviewed-by: Cleber Rosa --- scripts/qapi/mypy.ini | 5 ----- 1 file changed, 5 deletions(-) diff --git a/scripts/qapi/mypy.ini b/scripts/qapi/mypy.ini index b668776d94..9da1dccef4 100644 --- a/scripts/qapi/mypy.ini +++ b/scripts/qapi/mypy.ini @@ -4,11 +4,6 @@ strict_optional =3D False disallow_untyped_calls =3D False python_version =3D 3.6 =20 -[mypy-qapi.commands] -disallow_untyped_defs =3D False -disallow_incomplete_defs =3D False -check_untyped_defs =3D False - [mypy-qapi.doc] disallow_subclassing_any =3D False disallow_untyped_defs =3D False --=20 2.26.2 From nobody Wed May 15 22:57:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600995729; cv=none; d=zohomail.com; s=zohoarc; b=ms1T0Rme6WRYzoBo/PXuRtqttkw8ENkkNkrr1cNsjHqITDlMOAtJ/L16ovT1PQOdg9rRdq8f/CcaoWrIE1uVnPhVDGauD8/h0rO58JOPRb+mjbeYesnIHZtoKJ+ot3RPmmNEeSpritTQEUOmYr7LpTVLjI4WEnjmNHvgJaH6tTA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600995729; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=B1oBsp4sWgiIW0rKGdVj0oeRmGKaF3e1BY7zosKTTTU=; b=DNZmcVSj/FKbTssZmEFobc6M5UObMwtizf1yZkTB6P9mL7v4FCnbMUpq0wfPBhgqYmFTx0bXjkjeHpD2nxLPbBKFekH8c7IEsaptz5Bx2Yn9ge3cLjayTI1hee/NERovdrk2PrrYNkgqx/ftJwCzxQjzt+vF2ilmZn5akvi2NLc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600995729945146.2991185394062; Thu, 24 Sep 2020 18:02:09 -0700 (PDT) Received: from localhost ([::1]:40374 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLc7k-00057n-9T for importer@patchew.org; Thu, 24 Sep 2020 21:02:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51396) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLbcT-0001LH-U9 for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:33144) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLbcL-0000D4-M6 for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:49 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-208-cQGkYC37MDC_ma5ZZWNUxQ-1; Thu, 24 Sep 2020 20:29:27 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D7CBC8015A5 for ; Fri, 25 Sep 2020 00:29:26 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3B0515D9DD; Fri, 25 Sep 2020 00:29:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600993769; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=B1oBsp4sWgiIW0rKGdVj0oeRmGKaF3e1BY7zosKTTTU=; b=VDJ+wCUs4Wcmx8nUhxsREYtE5kji1ykzlAzC2stUyQtOFXEgqGE1506a6DHqynqilzM3/l GL4zD13bgSt6B/f0SFHtqwbVzbR/2DsRPb1e6g9InS17oBdd2sURbt12AXm1roJeHxmaj0 zDpOQjFRwstsRtRWRTy0HmjLB+iqkbc= X-MC-Unique: cQGkYC37MDC_ma5ZZWNUxQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 29/47] qapi/source.py: add type hint annotations Date: Thu, 24 Sep 2020 20:28:42 -0400 Message-Id: <20200925002900.465855-30-jsnow@redhat.com> In-Reply-To: <20200925002900.465855-1-jsnow@redhat.com> References: <20200925002900.465855-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/24 01:10:00 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Annotations do not change runtime behavior. This commit *only* adds annotations. Signed-off-by: John Snow Reviewed-by: Eduardo Habkost Reviewed-by: Cleber Rosa Tested-by: Cleber Rosa --- scripts/qapi/mypy.ini | 5 ----- scripts/qapi/source.py | 31 ++++++++++++++++++------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/scripts/qapi/mypy.ini b/scripts/qapi/mypy.ini index 9da1dccef4..43c8bd1973 100644 --- a/scripts/qapi/mypy.ini +++ b/scripts/qapi/mypy.ini @@ -39,11 +39,6 @@ disallow_untyped_defs =3D False disallow_incomplete_defs =3D False check_untyped_defs =3D False =20 -[mypy-qapi.source] -disallow_untyped_defs =3D False -disallow_incomplete_defs =3D False -check_untyped_defs =3D False - [mypy-qapi.types] disallow_untyped_defs =3D False disallow_incomplete_defs =3D False diff --git a/scripts/qapi/source.py b/scripts/qapi/source.py index e97b9a8e15..1cc6a5b82d 100644 --- a/scripts/qapi/source.py +++ b/scripts/qapi/source.py @@ -11,37 +11,42 @@ =20 import copy import sys +from typing import List, Optional, TypeVar =20 =20 class QAPISchemaPragma: - def __init__(self): + def __init__(self) -> None: # Are documentation comments required? self.doc_required =3D False # Whitelist of commands allowed to return a non-dictionary - self.returns_whitelist =3D [] + self.returns_whitelist: List[str] =3D [] # Whitelist of entities allowed to violate case conventions - self.name_case_whitelist =3D [] + self.name_case_whitelist: List[str] =3D [] =20 =20 class QAPISourceInfo: - def __init__(self, fname, line, parent): + T =3D TypeVar('T', bound=3D'QAPISourceInfo') + + def __init__(self: T, fname: str, line: int, parent: Optional[T]): self.fname =3D fname self.line =3D line self.parent =3D parent - self.pragma =3D parent.pragma if parent else QAPISchemaPragma() - self.defn_meta =3D None - self.defn_name =3D None + self.pragma: QAPISchemaPragma =3D ( + parent.pragma if parent else QAPISchemaPragma() + ) + self.defn_meta: Optional[str] =3D None + self.defn_name: Optional[str] =3D None =20 - def set_defn(self, meta, name): + def set_defn(self, meta: str, name: str) -> None: self.defn_meta =3D meta self.defn_name =3D name =20 - def next_line(self): + def next_line(self: T) -> T: info =3D copy.copy(self) info.line +=3D 1 return info =20 - def loc(self): + def loc(self) -> str: if self.fname is None: return sys.argv[0] ret =3D self.fname @@ -49,13 +54,13 @@ def loc(self): ret +=3D ':%d' % self.line return ret =20 - def in_defn(self): + def in_defn(self) -> str: if self.defn_name: return "%s: In %s '%s':\n" % (self.fname, self.defn_meta, self.defn_name) return '' =20 - def include_path(self): + def include_path(self) -> str: ret =3D '' parent =3D self.parent while parent: @@ -63,5 +68,5 @@ def include_path(self): parent =3D parent.parent return ret =20 - def __str__(self): + def __str__(self) -> str: return self.include_path() + self.in_defn() + self.loc() --=20 2.26.2 From nobody Wed May 15 22:57:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600995404; cv=none; d=zohomail.com; s=zohoarc; b=eU8FKSdxNuCWwr3GaWwBKycciPh6koi6PUN2PR3Nze9NfMjStth1BYnBVJsfpQAfAW7vTb7OEwKmtE/HU81OHpUW3uU2zDJwi/KIzkWb4sQ/LeAxX39VWkpzy9NKQ/Lab1gMgiLoFLXye5AftuekS6u5TaOR3J8kojslRzppHy4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600995404; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=F3oa8uS+y7UmxgtPTLrlwdOiBHonaXxv0EiDuErmKbQ=; b=fQ+CskVi+WuFFvJtCX7m0Tf26eVlYMMv8WYn2Ll8o3BkRgPjoCl4fEGdY9sMRkzZpNu9zk8kZpGu66ZRHHWX8gR5OegjwkT/yygDBkI3G9HyoIPusasZ3swe8k4SJOT84VruzMhv8DCC9DFja1cJ2d/rlO8epfmEEz9iC3noIf8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600995404845699.3367776037595; Thu, 24 Sep 2020 17:56:44 -0700 (PDT) Received: from localhost ([::1]:51436 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLc2V-00062F-Ez for importer@patchew.org; Thu, 24 Sep 2020 20:56:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51456) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLbcc-0001P8-TL for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:35971) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLbcL-0000D8-N1 for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:58 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-585-jT2WcpMAORWEl-D4mGyJlw-1; Thu, 24 Sep 2020 20:29:28 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A4DDE6408A for ; Fri, 25 Sep 2020 00:29:27 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A4F45D9DD; Fri, 25 Sep 2020 00:29:26 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600993770; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=F3oa8uS+y7UmxgtPTLrlwdOiBHonaXxv0EiDuErmKbQ=; b=NBrqISRlGjv/r7H6e6bUDekHNlCFwy1NTUuSCWfUcwcNjzK2M/ooRFnktTVnuQ/Nv1jUbP Hit2yLIlocWRiPoManFiprKT0+zJ3rYEo12ROnA2NF0I2ndLXGAo8h5wqYozqTmQ1eUfR8 HXepWMa4j4nt4xFm0rs4/4pjbBsHKnA= X-MC-Unique: jT2WcpMAORWEl-D4mGyJlw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 30/47] qapi/source.py: delint with pylint Date: Thu, 24 Sep 2020 20:28:43 -0400 Message-Id: <20200925002900.465855-31-jsnow@redhat.com> In-Reply-To: <20200925002900.465855-1-jsnow@redhat.com> References: <20200925002900.465855-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 23:02:20 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Shush an error and leave a hint for future cleanups when we're allowed to use Python 3.7+. Signed-off-by: John Snow Reviewed-by: Eduardo Habkost Reviewed-by: Cleber Rosa Tested-by: Cleber Rosa --- scripts/qapi/pylintrc | 1 - scripts/qapi/source.py | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/qapi/pylintrc b/scripts/qapi/pylintrc index 6151427a51..7438806096 100644 --- a/scripts/qapi/pylintrc +++ b/scripts/qapi/pylintrc @@ -8,7 +8,6 @@ ignore-patterns=3Ddoc.py, gen.py, parser.py, schema.py, - source.py, types.py, visit.py, =20 diff --git a/scripts/qapi/source.py b/scripts/qapi/source.py index 1cc6a5b82d..ba991d798f 100644 --- a/scripts/qapi/source.py +++ b/scripts/qapi/source.py @@ -15,6 +15,9 @@ =20 =20 class QAPISchemaPragma: + # Replace with @dataclass in Python 3.7+ + # pylint: disable=3Dtoo-few-public-methods + def __init__(self) -> None: # Are documentation comments required? self.doc_required =3D False --=20 2.26.2 From nobody Wed May 15 22:57:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600995580; cv=none; d=zohomail.com; s=zohoarc; b=N91Rx/VdkAK6JkF7Z8+gV8D+AaPbtr8XJcBD/6Fs4Ii7BEXpvDpH1chWvV2WPM3lCmqOGI3U/esSn+ZgbtPOGyvadWclGqKRCj1e8ijudsWmnU1VRxkutfpKbOzAjRufiRxV/2JH0tZwPqAF9qWgixnqNLkfFLxYF5g0cp2RZJM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600995580; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=aYDugCqa8ARDjhFHje/YlYRm5kmuyuRDwsbtrSJP5v8=; b=JOiZhgPRvx5p5HbQgL+lPjro8bGYHU6vWXWAtCdlsPBYGG/qCebNfScVBCHj7oByTHD/y4fKdDT3zrINP1xji27Gwwt3EqHJS8pbBcxm0becymB+KrpOrrH2LOt/+93gRKAJJwLH0ZtReldnO+dXXuhK2bImi4C+kG6Ko02iuG0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600995580369682.8722007763462; Thu, 24 Sep 2020 17:59:40 -0700 (PDT) Received: from localhost ([::1]:34426 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLc5L-0002Pq-0Z for importer@patchew.org; Thu, 24 Sep 2020 20:59:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51432) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLbcb-0001O3-CI for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:43923) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLbcG-0000DC-TH for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:57 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-505-aIMGES82N-OBylmmNrfcEg-1; Thu, 24 Sep 2020 20:29:29 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 739531091066 for ; Fri, 25 Sep 2020 00:29:28 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id CBE5B5D9DD; Fri, 25 Sep 2020 00:29:27 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600993771; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aYDugCqa8ARDjhFHje/YlYRm5kmuyuRDwsbtrSJP5v8=; b=jTjSNz6cKbV/2YwylgQqht0utEYCOHIWr60EN4tbd4ZNmMSFNcDAqJFOKUeTbWsKvZLgGK gN5NUoCeaB01uV/G95J0GhvZbb+lI8T5TSvNQSl+qZznIEnOvIPAUMP0RvOm95iCNBnk0U W83Ds870b90TMIirOmcSAtB5C5szHxU= X-MC-Unique: aIMGES82N-OBylmmNrfcEg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 31/47] qapi/gen.py: Fix edge-case of _is_user_module Date: Thu, 24 Sep 2020 20:28:44 -0400 Message-Id: <20200925002900.465855-32-jsnow@redhat.com> In-Reply-To: <20200925002900.465855-1-jsnow@redhat.com> References: <20200925002900.465855-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 23:02:20 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The edge case is that if the name is '', this expression returns a string instead of a bool, which violates our declared type. Signed-off-by: John Snow Reviewed-by: Cleber Rosa --- scripts/qapi/gen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/qapi/gen.py b/scripts/qapi/gen.py index c1e65f2e52..75471c4cc2 100644 --- a/scripts/qapi/gen.py +++ b/scripts/qapi/gen.py @@ -250,7 +250,7 @@ def __init__(self, prefix, what, user_blurb, builtin_bl= urb, pydoc): =20 @staticmethod def _is_user_module(name): - return name and not name.startswith('./') + return bool(name and not name.startswith('./')) =20 @staticmethod def _is_builtin_module(name): --=20 2.26.2 From nobody Wed May 15 22:57:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600995241; cv=none; d=zohomail.com; s=zohoarc; b=fwAJ3W85x/G+TrXlDjHUaa0S/zhntOzYG56HSkPyReoGY5UDOiKSE5QSJAIHkMXtCXf2oD+dsHL64LpR5O6r9IA0ytN3NTCVn9HY6TnVeHd1kfKGK9nmYR76rgkp2VdHr9Wl38rnP2UyLcom22ofnrY3TEeCJ1VbEU86UdAJZCc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600995241; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=WDqQqIfse1cr3UUkBhkg3V8MPsvVxDWWvh3UfDKr3n8=; b=brA4dNwBR5iCdxAgizPWi/iwck9IK+pY+HzLXVt7urYTMrqTr+k94N4f+oqTvZix2a28j+uXp8AkqAtjqquo33slmi0c7m68Lo8Om2Lsc3Su+jMFJxnxhMt3oDAjzgnIon9NU6H5ZjFHx3OVchaSKoSFGASDua2Xowdck6bxOI8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600995241375576.5427918301133; Thu, 24 Sep 2020 17:54:01 -0700 (PDT) Received: from localhost ([::1]:42948 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLbzr-0002LX-SP for importer@patchew.org; Thu, 24 Sep 2020 20:53:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51446) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLbcc-0001P5-9f for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:35170) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLbcL-0000DN-NQ for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:58 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-13-aw-PnfqTN8OVzyoMciXeEg-1; Thu, 24 Sep 2020 20:29:30 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3C1D5109106C for ; Fri, 25 Sep 2020 00:29:29 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 99D7D5D9DD; Fri, 25 Sep 2020 00:29:28 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600993772; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WDqQqIfse1cr3UUkBhkg3V8MPsvVxDWWvh3UfDKr3n8=; b=Jx6ruRHgBk9asWdU1oo/3BNFG6123oX91nTJ9FkQ83fTUh5l8+ih4IGz8BCzorfsU6XnOd HITNB2EV523v8Cf19WxGkG1Ov/X93v3XYlq9ziYUjPvRoddm8M/jXlO20Ojh3YCJuNCOUW 4EJMcikGl6Sb+4T4zcPsehzehDhrAm0= X-MC-Unique: aw-PnfqTN8OVzyoMciXeEg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 32/47] qapi/gen.py: add type hint annotations Date: Thu, 24 Sep 2020 20:28:45 -0400 Message-Id: <20200925002900.465855-33-jsnow@redhat.com> In-Reply-To: <20200925002900.465855-1-jsnow@redhat.com> References: <20200925002900.465855-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 23:02:20 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Annotations do not change runtime behavior. This commit *only* adds annotations. Signed-off-by: John Snow Reviewed-by: Eduardo Habkost Reviewed-by: Cleber Rosa --- scripts/qapi/gen.py | 107 ++++++++++++++++++++++++-------------------- 1 file changed, 58 insertions(+), 49 deletions(-) diff --git a/scripts/qapi/gen.py b/scripts/qapi/gen.py index 75471c4cc2..eec941074b 100644 --- a/scripts/qapi/gen.py +++ b/scripts/qapi/gen.py @@ -17,7 +17,13 @@ import errno import os import re -from typing import Optional +from typing import ( + Dict, + Iterator, + List, + Optional, + Tuple, +) =20 from .common import ( c_fname, @@ -29,31 +35,31 @@ mcgen, ) from .schema import QAPISchemaObjectType, QAPISchemaVisitor +from .source import QAPISourceInfo =20 =20 class QAPIGen: - - def __init__(self, fname): + def __init__(self, fname: Optional[str]): self.fname =3D fname self._preamble =3D '' self._body =3D '' =20 - def preamble_add(self, text): + def preamble_add(self, text: str) -> None: self._preamble +=3D text =20 - def add(self, text): + def add(self, text: str) -> None: self._body +=3D text =20 - def get_content(self): + def get_content(self) -> str: return self._top() + self._preamble + self._body + self._bottom() =20 - def _top(self): + def _top(self) -> str: return '' =20 - def _bottom(self): + def _bottom(self) -> str: return '' =20 - def write(self, output_dir): + def write(self, output_dir: str) -> None: # Include paths starting with ../ are used to reuse modules of the= main # schema in specialised schemas. Don't overwrite the files that are # already generated for the main schema. @@ -78,7 +84,7 @@ def write(self, output_dir): f.close() =20 =20 -def _wrap_ifcond(ifcond, before, after): +def _wrap_ifcond(ifcond: List[str], before: str, after: str) -> str: if before =3D=3D after: return after # suppress empty #if ... #endif =20 @@ -118,40 +124,38 @@ def build_params(arg_type: Optional[QAPISchemaObjectT= ype], =20 =20 class QAPIGenCCode(QAPIGen): - - def __init__(self, fname): + def __init__(self, fname: Optional[str]): super().__init__(fname) - self._start_if =3D None + self._start_if: Optional[Tuple[List[str], str, str]] =3D None =20 - def start_if(self, ifcond): + def start_if(self, ifcond: List[str]) -> None: assert self._start_if is None self._start_if =3D (ifcond, self._body, self._preamble) =20 - def end_if(self): + def end_if(self) -> None: assert self._start_if self._wrap_ifcond() self._start_if =3D None =20 - def _wrap_ifcond(self): + def _wrap_ifcond(self) -> None: self._body =3D _wrap_ifcond(self._start_if[0], self._start_if[1], self._body) self._preamble =3D _wrap_ifcond(self._start_if[0], self._start_if[2], self._preamble) =20 - def get_content(self): + def get_content(self) -> str: assert self._start_if is None return super().get_content() =20 =20 class QAPIGenC(QAPIGenCCode): - - def __init__(self, fname, blurb, pydoc): + def __init__(self, fname: str, blurb: str, pydoc: str): super().__init__(fname) self._blurb =3D blurb self._copyright =3D '\n * '.join(re.findall(r'^Copyright .*', pydo= c, re.MULTILINE)) =20 - def _top(self): + def _top(self) -> str: return mcgen(''' /* AUTOMATICALLY GENERATED, DO NOT MODIFY */ =20 @@ -167,7 +171,7 @@ def _top(self): ''', blurb=3Dself._blurb, copyright=3Dself._copyright) =20 - def _bottom(self): + def _bottom(self) -> str: return mcgen(''' =20 /* Dummy declaration to prevent empty .o file */ @@ -177,16 +181,15 @@ def _bottom(self): =20 =20 class QAPIGenH(QAPIGenC): - - def _top(self): + def _top(self) -> str: return super()._top() + guardstart(self.fname) =20 - def _bottom(self): + def _bottom(self) -> str: return guardend(self.fname) =20 =20 @contextmanager -def ifcontext(ifcond, *args): +def ifcontext(ifcond: List[str], *args: QAPIGenCCode) -> Iterator[None]: """ A 'with' statement context manager to wrap with start_if()/end_if() =20 @@ -214,15 +217,17 @@ def ifcontext(ifcond, *args): =20 =20 class QAPIGenDoc(QAPIGen): - - def _top(self): + def _top(self) -> str: return (super()._top() + '@c AUTOMATICALLY GENERATED, DO NOT MODIFY\n\n') =20 =20 class QAPISchemaMonolithicCVisitor(QAPISchemaVisitor): - - def __init__(self, prefix, what, blurb, pydoc): + def __init__(self, + prefix: str, + what: str, + blurb: str, + pydoc: str): self._prefix =3D prefix self._what =3D what self._genc =3D QAPIGenC(self._prefix + self._what + '.c', @@ -230,38 +235,42 @@ def __init__(self, prefix, what, blurb, pydoc): self._genh =3D QAPIGenH(self._prefix + self._what + '.h', blurb, pydoc) =20 - def write(self, output_dir): + def write(self, output_dir: str) -> None: self._genc.write(output_dir) self._genh.write(output_dir) =20 =20 class QAPISchemaModularCVisitor(QAPISchemaVisitor): - - def __init__(self, prefix, what, user_blurb, builtin_blurb, pydoc): + def __init__(self, + prefix: str, + what: str, + user_blurb: str, + builtin_blurb: Optional[str], + pydoc: str): self._prefix =3D prefix self._what =3D what self._user_blurb =3D user_blurb self._builtin_blurb =3D builtin_blurb self._pydoc =3D pydoc - self._genc =3D None - self._genh =3D None - self._module =3D {} - self._main_module =3D None + self._genc: Optional[QAPIGenC] =3D None + self._genh: Optional[QAPIGenH] =3D None + self._module: Dict[Optional[str], Tuple[QAPIGenC, QAPIGenH]] =3D {} + self._main_module: Optional[str] =3D None =20 @staticmethod - def _is_user_module(name): + def _is_user_module(name: Optional[str]) -> bool: return bool(name and not name.startswith('./')) =20 @staticmethod - def _is_builtin_module(name): + def _is_builtin_module(name: Optional[str]) -> bool: return not name =20 - def _module_dirname(self, what, name): + def _module_dirname(self, what: str, name: Optional[str]) -> str: if self._is_user_module(name): return os.path.dirname(name) return '' =20 - def _module_basename(self, what, name): + def _module_basename(self, what: str, name: Optional[str]) -> str: ret =3D '' if self._is_builtin_module(name) else self._prefix if self._is_user_module(name): basename =3D os.path.basename(name) @@ -273,27 +282,27 @@ def _module_basename(self, what, name): ret +=3D re.sub(r'-', '-' + name + '-', what) return ret =20 - def _module_filename(self, what, name): + def _module_filename(self, what: str, name: Optional[str]) -> str: return os.path.join(self._module_dirname(what, name), self._module_basename(what, name)) =20 - def _add_module(self, name, blurb): + def _add_module(self, name: Optional[str], blurb: str) -> None: basename =3D self._module_filename(self._what, name) genc =3D QAPIGenC(basename + '.c', blurb, self._pydoc) genh =3D QAPIGenH(basename + '.h', blurb, self._pydoc) self._module[name] =3D (genc, genh) self._genc, self._genh =3D self._module[name] =20 - def _add_user_module(self, name, blurb): + def _add_user_module(self, name: str, blurb: str) -> None: assert self._is_user_module(name) if self._main_module is None: self._main_module =3D name self._add_module(name, blurb) =20 - def _add_system_module(self, name, blurb): + def _add_system_module(self, name: Optional[str], blurb: str) -> None: self._add_module(name and './' + name, blurb) =20 - def write(self, output_dir, opt_builtins=3DFalse): + def write(self, output_dir: str, opt_builtins: bool =3D False) -> None: for name in self._module: if self._is_builtin_module(name) and not opt_builtins: continue @@ -301,13 +310,13 @@ def write(self, output_dir, opt_builtins=3DFalse): genc.write(output_dir) genh.write(output_dir) =20 - def _begin_system_module(self, name): + def _begin_system_module(self, name: None) -> None: pass =20 - def _begin_user_module(self, name): + def _begin_user_module(self, name: str) -> None: pass =20 - def visit_module(self, name): + def visit_module(self, name: Optional[str]) -> None: if name is None: if self._builtin_blurb: self._add_system_module(None, self._builtin_blurb) @@ -321,7 +330,7 @@ def visit_module(self, name): self._add_user_module(name, self._user_blurb) self._begin_user_module(name) =20 - def visit_include(self, name, info): + def visit_include(self, name: str, info: QAPISourceInfo) -> None: relname =3D os.path.relpath(self._module_filename(self._what, name= ), os.path.dirname(self._genh.fname)) self._genh.preamble_add(mcgen(''' --=20 2.26.2 From nobody Wed May 15 22:57:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600994783; cv=none; d=zohomail.com; s=zohoarc; b=HTro68HOgFrLsFT49LElqJoev2YA6sBbaZBymPgQo2Fpx0MRFdorowZw8Fqe0WaTTV1W4wMYRod2Zu20f/I5ltSAhizGBjjtHiNq7Ruji77K2rWjTpGKXRhLvXuMYpWiRflRNXuT/H5p9BnPMWnSXdywo86naD7Q8qyKy78BrlI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600994783; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cIjB40CcYVFl3iMOrIvxEeJVWLX3mylMBB5dxrAPUNE=; b=HmKtxhiwPq5J3xliH8cfbiWTkf7Fkuki0uAR16Mksb8ES17G9esLBGL0+RJX1Mtn6QGNQtryspIK4Al2Ap0E4v1vtfVheZFnKaN6U1dTtHWIZBCIA2lc0Mk3HBvp4YQmP7UTf5D3n7m7pUe993mmdbu/ypi1gnSLUrRgrZ9chYc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600994783739689.1070388294642; Thu, 24 Sep 2020 17:46:23 -0700 (PDT) Received: from localhost ([::1]:46146 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLbsU-0000EU-7X for importer@patchew.org; Thu, 24 Sep 2020 20:46:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51320) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLbcO-0001Co-7T for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:31021) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLbcG-0000DR-Sl for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:43 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-85-I5n6w7pYPb2_CmCFnd7E5w-1; Thu, 24 Sep 2020 20:29:31 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 09FAF8015A5 for ; Fri, 25 Sep 2020 00:29:30 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 62F725D9DD; Fri, 25 Sep 2020 00:29:29 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600993773; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cIjB40CcYVFl3iMOrIvxEeJVWLX3mylMBB5dxrAPUNE=; b=CEzeAC0qGD0b4AVp90sFyV0AEahUOaitHMy3zl34gec+O8Rlptx3IKOzCEHtjlwrqsgqXs XGejIfzuCgDf0HupkYVwxrwo9XthrDDAFQmSfnPLAaFVKYUlsVrM7SpiMU4wmUbGzIeB8t stPAjOysOT2DEX5KQBDJ4iI3DqiKvzA= X-MC-Unique: I5n6w7pYPb2_CmCFnd7E5w-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 33/47] qapi/gen.py: Enable checking with mypy Date: Thu, 24 Sep 2020 20:28:46 -0400 Message-Id: <20200925002900.465855-34-jsnow@redhat.com> In-Reply-To: <20200925002900.465855-1-jsnow@redhat.com> References: <20200925002900.465855-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 23:02:20 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: John Snow Reviewed-by: Eduardo Habkost Reviewed-by: Cleber Rosa Tested-by: Cleber Rosa --- scripts/qapi/mypy.ini | 5 ----- 1 file changed, 5 deletions(-) diff --git a/scripts/qapi/mypy.ini b/scripts/qapi/mypy.ini index 43c8bd1973..dbfeda748c 100644 --- a/scripts/qapi/mypy.ini +++ b/scripts/qapi/mypy.ini @@ -19,11 +19,6 @@ disallow_untyped_defs =3D False disallow_incomplete_defs =3D False check_untyped_defs =3D False =20 -[mypy-qapi.gen] -disallow_untyped_defs =3D False -disallow_incomplete_defs =3D False -check_untyped_defs =3D False - [mypy-qapi.introspect] disallow_untyped_defs =3D False disallow_incomplete_defs =3D False --=20 2.26.2 From nobody Wed May 15 22:57:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600995163; cv=none; d=zohomail.com; s=zohoarc; b=Qs+OVn5pJqUcS+9pM8TXC+ax9ze33ebZAGf1CRU7GjWB2QdhTh+vaVad+/h6aSm+vRwrC+TB8sTp5KZsXgoM9GdPxH15PbRnTg3eTPVBOJY355C/2CYHue4A0XLf150EO8igfLMlVZJNcJNl+AJNi7GBY0h7NwBB4gUazHRp9No= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600995163; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZUJwWCFNGA6+mV8YreYmKR5QC1m5IZJw4r6/CyXQT1E=; b=COVwVIJv66/DvARFsilsTzjjLi/FY0XnvLIlp2r63W0JEB5hcGTGD3VhOfepeBP4DauvNYug2Wvr2qojnpVjY6zZUArbXz+NMpXX0tkz7FRyoMh2ObYyenO2wZ84ollG6TA2BFhW8qLemgz7bDJ5rQGRIMkBD1AJro9237GsPtI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600995163878190.824336578493; Thu, 24 Sep 2020 17:52:43 -0700 (PDT) Received: from localhost ([::1]:37550 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLbyc-00005C-IT for importer@patchew.org; Thu, 24 Sep 2020 20:52:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51420) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLbcX-0001NL-Bb for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:57463) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLbcL-0000DV-Ik for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:53 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-131-2LuE7ViFP5Sm_FmfhMXymQ-1; Thu, 24 Sep 2020 20:29:31 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C6756188C122 for ; Fri, 25 Sep 2020 00:29:30 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2F8165D9DD; Fri, 25 Sep 2020 00:29:30 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600993773; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZUJwWCFNGA6+mV8YreYmKR5QC1m5IZJw4r6/CyXQT1E=; b=Ja93vRQiOdC33LILNpPEkq6hUeVbIbw5mzRRn72iWFj/8hMpaPq54KCqcahbWBefqy17OG lzNqtckc6KHiJlMV0JRG2qlQ41ivXs8ABeT+9S9iJwv6pWqWbx8NlmP0VMF2I5PxZTUCxa V3S6ZyG2Ar/HxbXeaWoS5GpOIk+yItw= X-MC-Unique: 2LuE7ViFP5Sm_FmfhMXymQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 34/47] qapi/gen.py: Remove unused parameter Date: Thu, 24 Sep 2020 20:28:47 -0400 Message-Id: <20200925002900.465855-35-jsnow@redhat.com> In-Reply-To: <20200925002900.465855-1-jsnow@redhat.com> References: <20200925002900.465855-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 23:02:20 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" module_basename doesn't use the 'what' argument, so remove it. Signed-off-by: John Snow Reviewed-by: Eduardo Habkost Reviewed-by: Cleber Rosa --- scripts/qapi/gen.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/qapi/gen.py b/scripts/qapi/gen.py index eec941074b..ece908a058 100644 --- a/scripts/qapi/gen.py +++ b/scripts/qapi/gen.py @@ -265,7 +265,7 @@ def _is_user_module(name: Optional[str]) -> bool: def _is_builtin_module(name: Optional[str]) -> bool: return not name =20 - def _module_dirname(self, what: str, name: Optional[str]) -> str: + def _module_dirname(self, name: Optional[str]) -> str: if self._is_user_module(name): return os.path.dirname(name) return '' @@ -283,7 +283,7 @@ def _module_basename(self, what: str, name: Optional[st= r]) -> str: return ret =20 def _module_filename(self, what: str, name: Optional[str]) -> str: - return os.path.join(self._module_dirname(what, name), + return os.path.join(self._module_dirname(name), self._module_basename(what, name)) =20 def _add_module(self, name: Optional[str], blurb: str) -> None: --=20 2.26.2 From nobody Wed May 15 22:57:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600995287; cv=none; d=zohomail.com; s=zohoarc; b=RnLlerZTnR5DmZXYBtiUkQSH3dUvWrJ+eEtYiMgZ4dSx2MgsegZl2AvgKyM6A3qFwyCNE91nfqLuXDqI7u9Raqnld8lJJxRhEOXqkLYxNDgvjRHZtocQZZLZ3U+rsj/HWGgNLacvsjX3WhYAC8l9ZOL8L9CXlHEX+NdWvPnrAcs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600995287; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=81Clp/gi1N02OnIoY6vpj7MY+PSX++jNU88i6n8jQqg=; b=M3m1uKdRBiLZAvdvR5oxcgUhfE7dRtgcimBEoHrZoBwLHIzHpPkNWRK7L84PMdmzEvL3/BkStkcoxG6Tac9urHEHclgkEjD7HrJssO/d85AK9VTlvgRazjooAxrqsA5UwIFFes+SPpO2f5kKa+tNyi5ZEmBGpqAlfszoRvsLeDU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600995287577115.45107520542535; Thu, 24 Sep 2020 17:54:47 -0700 (PDT) Received: from localhost ([::1]:46064 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLc0c-0003g7-8X for importer@patchew.org; Thu, 24 Sep 2020 20:54:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51304) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLbcO-0001CC-0d for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:46522) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLbcG-0000Df-SZ for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:43 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-596-u_jXjNT0MLC4i2IpaONRxQ-1; Thu, 24 Sep 2020 20:29:32 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C6B8B188C125 for ; Fri, 25 Sep 2020 00:29:31 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id EE6BE5D9DD; Fri, 25 Sep 2020 00:29:30 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600993775; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=81Clp/gi1N02OnIoY6vpj7MY+PSX++jNU88i6n8jQqg=; b=Ed+gGenHGFIjOhzezjir+Sc0pHOXOQiIuscI4t+ha6KG4WBslO26OT0u9uyyuOQknL0IzF c0MX7w0tF1i9ccsccJ7ak9RFGah57c1mf5fmjoTU2atrXkavX6OGspbdl9GhZ0G3uj8AxV gLWxbgSOsg1HXEBk4u27jmdp4JUyjtc= X-MC-Unique: u_jXjNT0MLC4i2IpaONRxQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 35/47] qapi/gen.py: update write() to be more idiomatic Date: Thu, 24 Sep 2020 20:28:48 -0400 Message-Id: <20200925002900.465855-36-jsnow@redhat.com> In-Reply-To: <20200925002900.465855-1-jsnow@redhat.com> References: <20200925002900.465855-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/24 01:10:00 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Make the file handling here just a tiny bit more idiomatic. (I realize this is heavily subjective.) Use exist_ok=3DTrue for os.makedirs and remove the exception, use fdopen() to wrap the file descriptor in a File-like object, and use a context manager for managing the file pointer. Signed-off-by: John Snow Reviewed-by: Eduardo Habkost Reviewed-by: Cleber Rosa --- scripts/qapi/gen.py | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/scripts/qapi/gen.py b/scripts/qapi/gen.py index ece908a058..201f5af5a5 100644 --- a/scripts/qapi/gen.py +++ b/scripts/qapi/gen.py @@ -14,7 +14,6 @@ # See the COPYING file in the top-level directory. =20 from contextlib import contextmanager -import errno import os import re from typing import ( @@ -67,21 +66,18 @@ def write(self, output_dir: str) -> None: return pathname =3D os.path.join(output_dir, self.fname) odir =3D os.path.dirname(pathname) + if odir: - try: - os.makedirs(odir) - except os.error as e: - if e.errno !=3D errno.EEXIST: - raise + os.makedirs(odir, exist_ok=3DTrue) + fd =3D os.open(pathname, os.O_RDWR | os.O_CREAT, 0o666) - f =3D open(fd, 'r+', encoding=3D'utf-8') - text =3D self.get_content() - oldtext =3D f.read(len(text) + 1) - if text !=3D oldtext: - f.seek(0) - f.truncate(0) - f.write(text) - f.close() + with os.fdopen(fd, 'r+', encoding=3D'utf-8') as fp: + text =3D self.get_content() + oldtext =3D fp.read(len(text) + 1) + if text !=3D oldtext: + fp.seek(0) + fp.truncate(0) + fp.write(text) =20 =20 def _wrap_ifcond(ifcond: List[str], before: str, after: str) -> str: --=20 2.26.2 From nobody Wed May 15 22:57:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600995476; cv=none; d=zohomail.com; s=zohoarc; b=CByduImiwZs9T3xv/20w77nzTbFVNriKEeewHwZwCbF+twcTzAlJiGU8xmQr2HTLGRm5M++jJxSlqRhef0AYIImG8HrozZljg6fwOcK7Afit4AwTWG13lUF9O70/t5WFvyfPq/udXcg2/Gb8dCidk9qbfKp5Rf9lAokXfYqoiG8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600995476; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=FExXdI0eYX9zvZFr4CkJdNGgA9djcrorR1lanAz+/Ck=; b=iUPa4MxNIvhB+2uBjajQN6XWWScKlTxHfJIgYWRSztyrWmpw94VCCUBlZjAcezy/JyzCKyZhFllZowwvCDu2r7bBWnLMplP9LVaGpl/eAEPAn8scq3xq4cJQ/2RkuRAVrORr8vst3dnR8KD/C8cIMnRAj1p/tPFol3KBP0in/VE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 160099547631548.81661085586711; Thu, 24 Sep 2020 17:57:56 -0700 (PDT) Received: from localhost ([::1]:54360 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLc3e-0007KP-O5 for importer@patchew.org; Thu, 24 Sep 2020 20:57:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51384) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLbcS-0001KJ-IH for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:33923) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLbcL-0000Dm-Mh for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:48 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-241-30E7O35zOXyKd4A5p1OBFQ-1; Thu, 24 Sep 2020 20:29:34 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1C81C64091 for ; Fri, 25 Sep 2020 00:29:33 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 078C25D9DD; Fri, 25 Sep 2020 00:29:31 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600993776; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FExXdI0eYX9zvZFr4CkJdNGgA9djcrorR1lanAz+/Ck=; b=Dt9eqmqhc75I6cFMANIUA/2+v9OFJOdPuro1FJudYMS5RqjziljJ3Lb59ej9Ob2kJuyY9p Z21BSQgNYAS+dgPa9SG6nji8zewSTS48MIBV8tGs2wpG1wVrryzB/LInWJC5lu4b/XMOfW 2NMLDd+wEZxyHXNHy11nrhJUkxGRHEM= X-MC-Unique: 30E7O35zOXyKd4A5p1OBFQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 36/47] qapi/gen.py: delint with pylint Date: Thu, 24 Sep 2020 20:28:49 -0400 Message-Id: <20200925002900.465855-37-jsnow@redhat.com> In-Reply-To: <20200925002900.465855-1-jsnow@redhat.com> References: <20200925002900.465855-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 23:02:20 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" 'fp' and 'fd' are self-evident in context, add them to the list of OK names. _top and _bottom also need to stay standard methods because some users override the method and need to use `self`. Tell pylint to shush. Signed-off-by: John Snow Reviewed-by: Eduardo Habkost Reviewed-by: Cleber Rosa --- scripts/qapi/gen.py | 2 ++ scripts/qapi/pylintrc | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/qapi/gen.py b/scripts/qapi/gen.py index 201f5af5a5..bce3737d3b 100644 --- a/scripts/qapi/gen.py +++ b/scripts/qapi/gen.py @@ -53,9 +53,11 @@ def get_content(self) -> str: return self._top() + self._preamble + self._body + self._bottom() =20 def _top(self) -> str: + # pylint: disable=3Dno-self-use return '' =20 def _bottom(self) -> str: + # pylint: disable=3Dno-self-use return '' =20 def write(self, output_dir: str) -> None: diff --git a/scripts/qapi/pylintrc b/scripts/qapi/pylintrc index 7438806096..de132d03cf 100644 --- a/scripts/qapi/pylintrc +++ b/scripts/qapi/pylintrc @@ -5,7 +5,6 @@ ignore-patterns=3Ddoc.py, error.py, expr.py, - gen.py, parser.py, schema.py, types.py, @@ -46,7 +45,9 @@ good-names=3Di, k, ex, Run, - _ + _, + fp, # fp =3D open(...) + fd, # fd =3D os.open(...) =20 [VARIABLES] =20 --=20 2.26.2 From nobody Wed May 15 22:57:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600995924; cv=none; d=zohomail.com; s=zohoarc; b=j/by22u9uBhJ1q+CIFOtPCyOb/O59x2qfxIDqRRm3hOLbTA2AErUmOsAErTh/kcS/jg1TVBIkIvdgDL+TzkNHfowB8LzjzgdHgLMB7s7U2yzai+OioU6uJbR63h6SeHpf3ZrypPUoJbP08+wDNlGiEjaJwkZ9cVzBCg4v4Vf1hE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600995924; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=SHrey53os6qnMp20+cFuczxUUrMzfyIY9RQUSHKeFNs=; b=Uk2yVYC7mibzLKsDkBR7pQ4BRxLZjVXtYqY/2faQEn9epsEzeGUWU7UDIE1GB8VoowPXfUvOYrjnK0fmXq0zGyTW6mCAkFnROE9FrX1ULJ8RboRcZ/K2+ciuUG2b8V3rCayz1Atf6uXykNFoZA3E9Zu1pcBk5uuB2Z5G1pUWJTk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600995924824772.9622472102891; Thu, 24 Sep 2020 18:05:24 -0700 (PDT) Received: from localhost ([::1]:48660 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLcAt-0000DC-H7 for importer@patchew.org; Thu, 24 Sep 2020 21:05:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51458) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLbcd-0001PA-BI for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:32923) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLbcL-0000Dv-NL for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:59 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-126-74ZPjMvENeeZDQoCN1kNnA-1; Thu, 24 Sep 2020 20:29:35 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6B507807351 for ; Fri, 25 Sep 2020 00:29:34 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 62C245D9DD; Fri, 25 Sep 2020 00:29:33 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600993778; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SHrey53os6qnMp20+cFuczxUUrMzfyIY9RQUSHKeFNs=; b=GZN1MM446Rh2110zJXe8HjkiYAo0lb3MyPPeoO8mu8XuUjDUi0CgIaHajjuW2qNMKW7Jx1 mNQOBx2LNcczFoOTmTcTBjoW80l2+uNUv5d2+YsnY199Q95YkcC/8IGfqpsK/lj4GfDZM/ QkK9T4DDPM5O/Z8tKFLWtEWs6D6P8AI= X-MC-Unique: 74ZPjMvENeeZDQoCN1kNnA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 37/47] qapi/introspect.py: assert obj is a dict when features are given Date: Thu, 24 Sep 2020 20:28:50 -0400 Message-Id: <20200925002900.465855-38-jsnow@redhat.com> In-Reply-To: <20200925002900.465855-1-jsnow@redhat.com> References: <20200925002900.465855-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/24 01:10:00 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This is necessary to keep mypy passing in the next patch when we add preliminary type hints. It will be removed shortly. Signed-off-by: John Snow --- scripts/qapi/introspect.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index 2850121cbd..c0cdb6d93a 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -26,6 +26,7 @@ def _make_tree(obj, ifcond, features, extra=3DNone): if ifcond: extra['if'] =3D ifcond if features: + assert isinstance(obj, dict) obj['features'] =3D [(f.name, {'if': f.ifcond}) for f in features] if extra: return (obj, extra) --=20 2.26.2 From nobody Wed May 15 22:57:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600995584; cv=none; d=zohomail.com; s=zohoarc; b=R12pp1jZkhtc1duPiXh2p2cBuqLVuW/MaGZtd4WG8S7oIKrha23XSi9GLiWKMsdSZefXd++1GcibZYuwMXuHlyUROxTTentUJOk7Xm1OUkrkWofbiYXf7GVK6vE99I3aYUEAgOdXMK1sLLE/YDnqwY1Um+NPX1nLM/NWgdqi8o8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600995584; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=N8QWuKpsOuINn6EjDaERi6fLSNZSHejMSPrYz2frNWg=; b=gjlVkixwG9g+GCNT3Y2EohC6tVzYMVjH0EvPRVVm2ZQnBgHCF+BFzy1CtDs8jKPBt6YBufKyneO9xtHWpYjYVbchaxXgEB84b0bitW1jxt4BHokPrShsOtrcYt6zyXbhlmUwBPbxyOg3bbo3Hum8XjIQVHvNCGvTWna7RAWiejg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600995584090402.7367217665743; Thu, 24 Sep 2020 17:59:44 -0700 (PDT) Received: from localhost ([::1]:34762 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLc5O-0002Yj-Mm for importer@patchew.org; Thu, 24 Sep 2020 20:59:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51626) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLbcp-0001aX-EQ for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:30:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:60228) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLbch-0000I4-EJ for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:30:11 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-353-u0utyR3iM3OsI6OnGT57-w-1; Thu, 24 Sep 2020 20:29:36 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3920C807352 for ; Fri, 25 Sep 2020 00:29:35 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 92C305D9DD; Fri, 25 Sep 2020 00:29:34 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600993802; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=N8QWuKpsOuINn6EjDaERi6fLSNZSHejMSPrYz2frNWg=; b=GDvFuwZCoyQpB8pm685jN3YvySe2U9BfyIJcRJ7s7894GLKuJnDR9oPilT9gwFwv0m0iZL +uL/bSiWkjRzpylyBo7vIvsPAXS4etqwoWccZM96MTTr/xxeEoV8Umo42HjidUBrnsUHcb nk2MzPgxyZQ/MEK5P9b4mI2EtcfHFLs= X-MC-Unique: u0utyR3iM3OsI6OnGT57-w-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 38/47] qapi/instrospect.py: add preliminary type hint annotations Date: Thu, 24 Sep 2020 20:28:51 -0400 Message-Id: <20200925002900.465855-39-jsnow@redhat.com> In-Reply-To: <20200925002900.465855-1-jsnow@redhat.com> References: <20200925002900.465855-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 23:02:20 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" From: Eduardo Habkost The typing of _make_tree and friends is a bit involved, but it can be done with some stubbed out types and a bit of elbow grease. The forthcoming patches attempt to make some simplifications, but having the type hints in advance can aid in review. Signed-off-by: Eduardo Habkost Signed-off-by: John Snow --- scripts/qapi/introspect.py | 138 +++++++++++++++++++++++++++---------- scripts/qapi/mypy.ini | 5 -- scripts/qapi/schema.py | 2 +- 3 files changed, 102 insertions(+), 43 deletions(-) diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index c0cdb6d93a..7d4dc3f8ee 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -10,6 +10,15 @@ See the COPYING file in the top-level directory. """ =20 +from typing import ( + Dict, + List, + Optional, + Sequence, + Tuple, + Union, +) + from .common import ( c_name, gen_endif, @@ -17,10 +26,34 @@ mcgen, ) from .gen import QAPISchemaMonolithicCVisitor -from .schema import QAPISchemaArrayType, QAPISchemaBuiltinType, QAPISchema= Type +from .schema import ( + QAPISchema, + QAPISchemaArrayType, + QAPISchemaBuiltinType, + QAPISchemaEntity, + QAPISchemaEnumMember, + QAPISchemaFeature, + QAPISchemaObjectType, + QAPISchemaObjectTypeMember, + QAPISchemaType, + QAPISchemaVariant, + QAPISchemaVariants, +) +from .source import QAPISourceInfo =20 +# The correct type for TreeNode is actually: +# Union[AnnotatedNode, List[TreeNode], Dict[str, TreeNode], str, bool] +# but mypy does not support recursive types yet. +TreeNode =3D object +_DObject =3D Dict[str, object] +Extra =3D Dict[str, object] +AnnotatedNode =3D Tuple[TreeNode, Extra] =20 -def _make_tree(obj, ifcond, features, extra=3DNone): + +def _make_tree(obj: Union[_DObject, str], ifcond: List[str], + features: List[QAPISchemaFeature], + extra: Optional[Extra] =3D None + ) -> Union[TreeNode, AnnotatedNode]: if extra is None: extra =3D {} if ifcond: @@ -33,9 +66,11 @@ def _make_tree(obj, ifcond, features, extra=3DNone): return obj =20 =20 -def _tree_to_qlit(obj, level=3D0, suppress_first_indent=3DFalse): +def _tree_to_qlit(obj: TreeNode, + level: int =3D 0, + suppress_first_indent: bool =3D False) -> str: =20 - def indent(level): + def indent(level: int) -> str: return level * 4 * ' ' =20 if isinstance(obj, tuple): @@ -85,21 +120,20 @@ def indent(level): return ret =20 =20 -def to_c_string(string): +def to_c_string(string: str) -> str: return '"' + string.replace('\\', r'\\').replace('"', r'\"') + '"' =20 =20 class QAPISchemaGenIntrospectVisitor(QAPISchemaMonolithicCVisitor): - - def __init__(self, prefix, unmask): + def __init__(self, prefix: str, unmask: bool): super().__init__( prefix, 'qapi-introspect', ' * QAPI/QMP schema introspection', __doc__) self._unmask =3D unmask - self._schema =3D None - self._trees =3D [] - self._used_types =3D [] - self._name_map =3D {} + self._schema: Optional[QAPISchema] =3D None + self._trees: List[TreeNode] =3D [] + self._used_types: List[QAPISchemaType] =3D [] + self._name_map: Dict[str, str] =3D {} self._genc.add(mcgen(''' #include "qemu/osdep.h" #include "%(prefix)sqapi-introspect.h" @@ -107,10 +141,10 @@ def __init__(self, prefix, unmask): ''', prefix=3Dprefix)) =20 - def visit_begin(self, schema): + def visit_begin(self, schema: QAPISchema) -> None: self._schema =3D schema =20 - def visit_end(self): + def visit_end(self) -> None: # visit the types that are actually used for typ in self._used_types: typ.visit(self) @@ -132,18 +166,18 @@ def visit_end(self): self._used_types =3D [] self._name_map =3D {} =20 - def visit_needed(self, entity): + def visit_needed(self, entity: QAPISchemaEntity) -> bool: # Ignore types on first pass; visit_end() will pick up used types return not isinstance(entity, QAPISchemaType) =20 - def _name(self, name): + def _name(self, name: str) -> str: if self._unmask: return name if name not in self._name_map: self._name_map[name] =3D '%d' % len(self._name_map) return self._name_map[name] =20 - def _use_type(self, typ): + def _use_type(self, typ: QAPISchemaType) -> str: # Map the various integer types to plain int if typ.json_type() =3D=3D 'int': typ =3D self._schema.lookup_type('int') @@ -162,8 +196,10 @@ def _use_type(self, typ): return '[' + self._use_type(typ.element_type) + ']' return self._name(typ.name) =20 - def _gen_tree(self, name, mtype, obj, ifcond, features): - extra =3D None + def _gen_tree(self, name: str, mtype: str, obj: _DObject, + ifcond: List[str], + features: Optional[List[QAPISchemaFeature]]) -> None: + extra: Extra =3D None if mtype not in ('command', 'event', 'builtin', 'array'): if not self._unmask: # Output a comment to make it easy to map masked names @@ -174,44 +210,64 @@ def _gen_tree(self, name, mtype, obj, ifcond, feature= s): obj['meta-type'] =3D mtype self._trees.append(_make_tree(obj, ifcond, features, extra)) =20 - def _gen_member(self, member): - obj =3D {'name': member.name, 'type': self._use_type(member.type)} + def _gen_member(self, + member: QAPISchemaObjectTypeMember) -> TreeNode: + obj: _DObject =3D { + 'name': member.name, + 'type': self._use_type(member.type) + } if member.optional: obj['default'] =3D None return _make_tree(obj, member.ifcond, member.features) =20 - def _gen_variants(self, tag_name, variants): + def _gen_variants(self, tag_name: str, + variants: List[QAPISchemaVariant]) -> _DObject: return {'tag': tag_name, 'variants': [self._gen_variant(v) for v in variants]} =20 - def _gen_variant(self, variant): - obj =3D {'case': variant.name, 'type': self._use_type(variant.type= )} + def _gen_variant(self, variant: QAPISchemaVariant) -> TreeNode: + obj: _DObject =3D { + 'case': variant.name, + 'type': self._use_type(variant.type) + } return _make_tree(obj, variant.ifcond, None) =20 - def visit_builtin_type(self, name, info, json_type): + def visit_builtin_type(self, name: str, info: Optional[QAPISourceInfo], + json_type: str) -> None: self._gen_tree(name, 'builtin', {'json-type': json_type}, [], None) =20 - def visit_enum_type(self, name, info, ifcond, features, members, prefi= x): + def visit_enum_type(self, name: str, info: QAPISourceInfo, + ifcond: List[str], features: List[QAPISchemaFeatur= e], + members: List[QAPISchemaEnumMember], + prefix: Optional[str]) -> None: self._gen_tree(name, 'enum', {'values': [_make_tree(m.name, m.ifcond, None) for m in members]}, ifcond, features) =20 - def visit_array_type(self, name, info, ifcond, element_type): + def visit_array_type(self, name: str, info: Optional[QAPISourceInfo], + ifcond: List[str], + element_type: QAPISchemaType) -> None: element =3D self._use_type(element_type) self._gen_tree('[' + element + ']', 'array', {'element-type': elem= ent}, ifcond, None) =20 - def visit_object_type_flat(self, name, info, ifcond, features, - members, variants): - obj =3D {'members': [self._gen_member(m) for m in members]} + def visit_object_type_flat(self, name: str, info: Optional[QAPISourceI= nfo], + ifcond: List[str], + features: List[QAPISchemaFeature], + members: Sequence[QAPISchemaObjectTypeMembe= r], + variants: Optional[QAPISchemaVariants]) -> = None: + obj: _DObject =3D {'members': [self._gen_member(m) for m in member= s]} if variants: obj.update(self._gen_variants(variants.tag_member.name, variants.variants)) =20 self._gen_tree(name, 'object', obj, ifcond, features) =20 - def visit_alternate_type(self, name, info, ifcond, features, variants): + def visit_alternate_type(self, name: str, info: QAPISourceInfo, + ifcond: List[str], + features: List[QAPISchemaFeature], + variants: QAPISchemaVariants) -> None: self._gen_tree(name, 'alternate', {'members': [ _make_tree({'type': self._use_type(m.type)}, @@ -219,24 +275,32 @@ def visit_alternate_type(self, name, info, ifcond, fe= atures, variants): for m in variants.variants]}, ifcond, features) =20 - def visit_command(self, name, info, ifcond, features, - arg_type, ret_type, gen, success_response, boxed, - allow_oob, allow_preconfig): + def visit_command(self, name: str, info: QAPISourceInfo, ifcond: List[= str], + features: List[QAPISchemaFeature], + arg_type: QAPISchemaObjectType, + ret_type: Optional[QAPISchemaType], gen: bool, + success_response: bool, boxed: bool, allow_oob: bool, + allow_preconfig: bool) -> None: arg_type =3D arg_type or self._schema.the_empty_object_type ret_type =3D ret_type or self._schema.the_empty_object_type - obj =3D {'arg-type': self._use_type(arg_type), - 'ret-type': self._use_type(ret_type)} + obj: _DObject =3D { + 'arg-type': self._use_type(arg_type), + 'ret-type': self._use_type(ret_type) + } if allow_oob: obj['allow-oob'] =3D allow_oob self._gen_tree(name, 'command', obj, ifcond, features) =20 - def visit_event(self, name, info, ifcond, features, arg_type, boxed): + def visit_event(self, name: str, info: QAPISourceInfo, + ifcond: List[str], features: List[QAPISchemaFeature], + arg_type: QAPISchemaObjectType, boxed: bool) -> None: arg_type =3D arg_type or self._schema.the_empty_object_type self._gen_tree(name, 'event', {'arg-type': self._use_type(arg_type= )}, ifcond, features) =20 =20 -def gen_introspect(schema, output_dir, prefix, opt_unmask): +def gen_introspect(schema: QAPISchema, output_dir: str, prefix: str, + opt_unmask: bool) -> None: vis =3D QAPISchemaGenIntrospectVisitor(prefix, opt_unmask) schema.visit(vis) vis.write(output_dir) diff --git a/scripts/qapi/mypy.ini b/scripts/qapi/mypy.ini index dbfeda748c..9ce8b56f22 100644 --- a/scripts/qapi/mypy.ini +++ b/scripts/qapi/mypy.ini @@ -19,11 +19,6 @@ disallow_untyped_defs =3D False disallow_incomplete_defs =3D False check_untyped_defs =3D False =20 -[mypy-qapi.introspect] -disallow_untyped_defs =3D False -disallow_incomplete_defs =3D False -check_untyped_defs =3D False - [mypy-qapi.parser] disallow_untyped_defs =3D False disallow_incomplete_defs =3D False diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py index 483b4b68df..a26b25c5e9 100644 --- a/scripts/qapi/schema.py +++ b/scripts/qapi/schema.py @@ -28,7 +28,7 @@ class QAPISchemaEntity: meta: Optional[str] =3D None =20 - def __init__(self, name, info, doc, ifcond=3DNone, features=3DNone): + def __init__(self, name: str, info, doc, ifcond=3DNone, features=3DNon= e): assert name is None or isinstance(name, str) for f in features or []: assert isinstance(f, QAPISchemaFeature) --=20 2.26.2 From nobody Wed May 15 22:57:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600995286; cv=none; d=zohomail.com; s=zohoarc; b=JHxZh/7tK/mORH3QElcXGfTRkz20Vl98WrmnL27/W78tFrMgYPZAhiM7cC6Bb5GkTS+xiazUIutAVJhrNCrqTG801F3wCFapXr+7s7vAVoVdsYEzdiLRO+tgrUPuE4tlaI14649y1VnkCGn33GtArE+p1/bZQRvgJF2KYuOiEHY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600995286; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Jtt1teyTwpqrjeo/zCyCcq8bTpQT3nPi5ZdArBIjlNc=; b=QBOJ+zPpmSzp9CD22JaQucrFk5ZjPrGVR9XjuSp3hv1oSEra3xM2CImY4pPaxg5GQ3KI3DRh6l7nMXbpwxsuvF5KJi+XNWvsJhL/zN5y5jQ7nRnnWsjam/t97CSCZhvIqPRQepOlcNpAdOA4t+DCEgnvjox1zG1aZEadRie/ujY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600995286126950.9695634678329; Thu, 24 Sep 2020 17:54:46 -0700 (PDT) Received: from localhost ([::1]:45890 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLc0a-0003be-QW for importer@patchew.org; Thu, 24 Sep 2020 20:54:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51488) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLbce-0001Pu-G0 for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:30:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:57251) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLbcL-0000E2-PJ for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:30:00 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-406-N7v_6DHWPXukJlayTpbriw-1; Thu, 24 Sep 2020 20:29:37 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7E2E26408A for ; Fri, 25 Sep 2020 00:29:36 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 866645D9DD; Fri, 25 Sep 2020 00:29:35 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600993780; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Jtt1teyTwpqrjeo/zCyCcq8bTpQT3nPi5ZdArBIjlNc=; b=UOn3s2QCBIwGzi0ZOrAuyMIoZUNV/M7GuoIrYUPWV0G/FqX2aF2yKrgOEMm7UYxF+4fKaV 2ogFUvJoU3Y20G54Qou22f+id+UKbUZMauspx5LdMIgWoK0XnfJ8jt0r/kw5tmywyDcaKo MpCgDvY3BRnWIEjaUh0XJ3v887Gkar8= X-MC-Unique: N7v_6DHWPXukJlayTpbriw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 39/47] qapi/introspect.py: add _gen_features helper Date: Thu, 24 Sep 2020 20:28:52 -0400 Message-Id: <20200925002900.465855-40-jsnow@redhat.com> In-Reply-To: <20200925002900.465855-1-jsnow@redhat.com> References: <20200925002900.465855-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/24 01:10:00 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" _make_tree might receive a dict or some other type. Adding features information should arguably be performed by the caller at such a time when we know the type of the object and don't have to re-interrogate it. Signed-off-by: John Snow --- scripts/qapi/introspect.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index 7d4dc3f8ee..08b3783ba7 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -51,16 +51,12 @@ =20 =20 def _make_tree(obj: Union[_DObject, str], ifcond: List[str], - features: List[QAPISchemaFeature], extra: Optional[Extra] =3D None ) -> Union[TreeNode, AnnotatedNode]: if extra is None: extra =3D {} if ifcond: extra['if'] =3D ifcond - if features: - assert isinstance(obj, dict) - obj['features'] =3D [(f.name, {'if': f.ifcond}) for f in features] if extra: return (obj, extra) return obj @@ -196,6 +192,11 @@ def _use_type(self, typ: QAPISchemaType) -> str: return '[' + self._use_type(typ.element_type) + ']' return self._name(typ.name) =20 + @classmethod + def _gen_features(cls, + features: List[QAPISchemaFeature]) -> List[TreeNode]: + return [_make_tree(f.name, f.ifcond) for f in features] + def _gen_tree(self, name: str, mtype: str, obj: _DObject, ifcond: List[str], features: Optional[List[QAPISchemaFeature]]) -> None: @@ -208,7 +209,9 @@ def _gen_tree(self, name: str, mtype: str, obj: _DObjec= t, name =3D self._name(name) obj['name'] =3D name obj['meta-type'] =3D mtype - self._trees.append(_make_tree(obj, ifcond, features, extra)) + if features: + obj['features'] =3D self._gen_features(features) + self._trees.append(_make_tree(obj, ifcond, extra)) =20 def _gen_member(self, member: QAPISchemaObjectTypeMember) -> TreeNode: @@ -218,7 +221,9 @@ def _gen_member(self, } if member.optional: obj['default'] =3D None - return _make_tree(obj, member.ifcond, member.features) + if member.features: + obj['features'] =3D self._gen_features(member.features) + return _make_tree(obj, member.ifcond) =20 def _gen_variants(self, tag_name: str, variants: List[QAPISchemaVariant]) -> _DObject: @@ -230,7 +235,7 @@ def _gen_variant(self, variant: QAPISchemaVariant) -> T= reeNode: 'case': variant.name, 'type': self._use_type(variant.type) } - return _make_tree(obj, variant.ifcond, None) + return _make_tree(obj, variant.ifcond) =20 def visit_builtin_type(self, name: str, info: Optional[QAPISourceInfo], json_type: str) -> None: --=20 2.26.2 From nobody Wed May 15 22:57:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600995767; cv=none; d=zohomail.com; s=zohoarc; b=SpW2tnOibneAF4lkPo0zA73xNcCED94LRjvsvsgYHpB0aVw8uKGxcd6P3i2fRTd2EfvIYOzmhjeAJQFUzcxGNRh2DU+2b7TmmeOqsGP17mVf2ReBaadhc4E1jbCpmj5AObt+ITrjIeEpZMtGweFP4OoGlUAZ6rE5zb6L84wvlkA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600995767; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=X/ZpfNwTNqb0AFAsg65iOai2tUb8+s2unJyiP/AOrS0=; b=OCcfK60c3lkio7z8FkPIkNrG105ZvZnIopkPPgF7DO98cdvraqgPbuY+Ogv3+DImd5jgzjnmmLkTKfZhDYVgxo1rlnZYA15EEsuk0ez479v7Xt8FFl4nTHLZSlqwIc9U/KdE2ERo83GXnLG1vIPDZR6uHQMEOp3mTslKK3Nr5OA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600995767958903.2697090034768; Thu, 24 Sep 2020 18:02:47 -0700 (PDT) Received: from localhost ([::1]:43290 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLc8M-0006Md-Km for importer@patchew.org; Thu, 24 Sep 2020 21:02:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51644) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLbcr-0001bD-DA for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:30:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:39652) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLbcj-0000KN-A7 for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:30:13 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-450-z3pnQCTsNPSfCLytpASPAg-1; Thu, 24 Sep 2020 20:29:38 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 816981091071 for ; Fri, 25 Sep 2020 00:29:37 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id BE5F55D9DD; Fri, 25 Sep 2020 00:29:36 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600993804; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X/ZpfNwTNqb0AFAsg65iOai2tUb8+s2unJyiP/AOrS0=; b=JRkJ/aYAmgQbtehqugmD7foUw4sG30iTeWFrdwvqqaqIInFoT4WFVPndERhDnwM8sNSF9Q zdEG0ZZSfOG7s3kwWzrN2oTsqtRCWakGWNz3w5rGrBQTOIUnhleCIX1O+sh200Pvu9/NJh LI9oiz0OnhBVFf0KMLfU0qSg+qI5TR0= X-MC-Unique: z3pnQCTsNPSfCLytpASPAg-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 40/47] qapi/introspect.py: Unify return type of _make_tree() Date: Thu, 24 Sep 2020 20:28:53 -0400 Message-Id: <20200925002900.465855-41-jsnow@redhat.com> In-Reply-To: <20200925002900.465855-1-jsnow@redhat.com> References: <20200925002900.465855-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/24 01:10:00 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Returning a *something* or a Tuple of *something* is hard to accurately type. Let's just always return a tuple for structural consistency. Instances of the 'TreeNode' type can be replaced with the slightly more specific 'AnnotatedNode' type. Signed-off-by: John Snow --- scripts/qapi/introspect.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index 08b3783ba7..54bc75393c 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -52,14 +52,12 @@ =20 def _make_tree(obj: Union[_DObject, str], ifcond: List[str], extra: Optional[Extra] =3D None - ) -> Union[TreeNode, AnnotatedNode]: + ) -> AnnotatedNode: if extra is None: extra =3D {} if ifcond: extra['if'] =3D ifcond - if extra: - return (obj, extra) - return obj + return (obj, extra) =20 =20 def _tree_to_qlit(obj: TreeNode, @@ -127,7 +125,7 @@ def __init__(self, prefix: str, unmask: bool): ' * QAPI/QMP schema introspection', __doc__) self._unmask =3D unmask self._schema: Optional[QAPISchema] =3D None - self._trees: List[TreeNode] =3D [] + self._trees: List[AnnotatedNode] =3D [] self._used_types: List[QAPISchemaType] =3D [] self._name_map: Dict[str, str] =3D {} self._genc.add(mcgen(''' @@ -194,7 +192,8 @@ def _use_type(self, typ: QAPISchemaType) -> str: =20 @classmethod def _gen_features(cls, - features: List[QAPISchemaFeature]) -> List[TreeNode]: + features: List[QAPISchemaFeature] + ) -> List[AnnotatedNode]: return [_make_tree(f.name, f.ifcond) for f in features] =20 def _gen_tree(self, name: str, mtype: str, obj: _DObject, @@ -214,7 +213,7 @@ def _gen_tree(self, name: str, mtype: str, obj: _DObjec= t, self._trees.append(_make_tree(obj, ifcond, extra)) =20 def _gen_member(self, - member: QAPISchemaObjectTypeMember) -> TreeNode: + member: QAPISchemaObjectTypeMember) -> AnnotatedNode: obj: _DObject =3D { 'name': member.name, 'type': self._use_type(member.type) @@ -230,7 +229,7 @@ def _gen_variants(self, tag_name: str, return {'tag': tag_name, 'variants': [self._gen_variant(v) for v in variants]} =20 - def _gen_variant(self, variant: QAPISchemaVariant) -> TreeNode: + def _gen_variant(self, variant: QAPISchemaVariant) -> AnnotatedNode: obj: _DObject =3D { 'case': variant.name, 'type': self._use_type(variant.type) --=20 2.26.2 From nobody Wed May 15 22:57:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600995547; cv=none; d=zohomail.com; s=zohoarc; b=YwMpXG+qdkV/sq60CPHJTTFNB3GDY29/ArH3YXZadq/TuyOH7o5uwfMiNfqld/zFQbfErvIVL7JlXA3clpjyFeqUwKKhCr3eGoS/AT+XgQV1mGLV4nNyb90j9BygSymawZesTWcExeEXbb5506equFvvEHAsEnojhiwiQ7Acz2s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600995547; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=P0W1KPcGQhdHxAYEwHnbpFPklKlEy5OAWGuZ4jXgBJ4=; b=U/aug5CQLezk7mVYssYSapE4vXEHjNSXkTUWqLtoTkVjeT00XEwx0ywhixL760qoryTs8Ihtb/RZuoPBxlgWIa1ckctsQFDhPeamGDy6CZy6lp2kpR9eTAcjZN6+tcaIjlikpeyoCQqr/GjvvWWxFBV9Ms3A2DaFfd7gFaQCzW0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600995547628793.8317192217587; Thu, 24 Sep 2020 17:59:07 -0700 (PDT) Received: from localhost ([::1]:59858 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLc4o-0001Eh-Cc for importer@patchew.org; Thu, 24 Sep 2020 20:59:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51466) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLbcd-0001Pk-Iq for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:30:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:30752) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLbcL-0000E6-Or for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:29:59 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-346-FaIQe9EuM3yv1ISPi35Xtw-1; Thu, 24 Sep 2020 20:29:39 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5D03264091 for ; Fri, 25 Sep 2020 00:29:38 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id A846B5D9DD; Fri, 25 Sep 2020 00:29:37 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600993780; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=P0W1KPcGQhdHxAYEwHnbpFPklKlEy5OAWGuZ4jXgBJ4=; b=gMfVNQCFybLliX1y+Bd77R8ii81HHltWi34fpIi95XX1Q0fSuV6o4+igEOr/qAH+Khv+KV a2dvlPGsvJdWdpWEwX3OW7uxthtKZMjKr1X3jqCGeeGxmIOfXHLUXbe2iSNpcK6y3dTPlY DfhInWeBbEG4txpENmc0/VdplJrFmGc= X-MC-Unique: FaIQe9EuM3yv1ISPi35Xtw-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 41/47] qapi/introspect.py: replace 'extra' dict with 'comment' argument Date: Thu, 24 Sep 2020 20:28:54 -0400 Message-Id: <20200925002900.465855-42-jsnow@redhat.com> In-Reply-To: <20200925002900.465855-1-jsnow@redhat.com> References: <20200925002900.465855-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/24 01:10:00 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This is only used to pass in a dictionary with a comment already set, so skip the runaround and just accept the comment. Signed-off-by: John Snow --- scripts/qapi/introspect.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index 54bc75393c..c444214090 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -51,12 +51,11 @@ =20 =20 def _make_tree(obj: Union[_DObject, str], ifcond: List[str], - extra: Optional[Extra] =3D None - ) -> AnnotatedNode: - if extra is None: - extra =3D {} - if ifcond: - extra['if'] =3D ifcond + comment: Optional[str] =3D None) -> AnnotatedNode: + extra: Extra =3D { + 'if': ifcond, + 'comment': comment, + } return (obj, extra) =20 =20 @@ -199,18 +198,18 @@ def _gen_features(cls, def _gen_tree(self, name: str, mtype: str, obj: _DObject, ifcond: List[str], features: Optional[List[QAPISchemaFeature]]) -> None: - extra: Extra =3D None + comment: Optional[str] =3D None if mtype not in ('command', 'event', 'builtin', 'array'): if not self._unmask: # Output a comment to make it easy to map masked names # back to the source when reading the generated output. - extra =3D {'comment': '"%s" =3D %s' % (self._name(name), n= ame)} + comment =3D f'"{self._name(name)}" =3D {name}' name =3D self._name(name) obj['name'] =3D name obj['meta-type'] =3D mtype if features: obj['features'] =3D self._gen_features(features) - self._trees.append(_make_tree(obj, ifcond, extra)) + self._trees.append(_make_tree(obj, ifcond, comment)) =20 def _gen_member(self, member: QAPISchemaObjectTypeMember) -> AnnotatedNode: --=20 2.26.2 From nobody Wed May 15 22:57:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600996336; cv=none; d=zohomail.com; s=zohoarc; b=kenqUJ5vMGRJOJHH0b0xzkSrlXT9PP6HdNtL4XkkjApdlqKuLKw66a4CvPPJ6qZL1XgVniheEObhkNlmHWuL4cK4Aby/X9wFNJpwJn3hwAGV6ZtDaoABcqPbczJXGQpJj22zsswqY5gszL/DOW8xL2VDwlNv5tdLsOkFRXXQxiY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600996336; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=c4feM44XQc0TAE09TT5lNOmorTyE+zBWAge5h2hgu+Q=; b=XeYyawS+0dDIuyYSF2gJUzWsCPibdE/pXdMt3570qm3G6ebK869M2OVg2uyigqqTLidXSXeoewXWAgPF4dInWWvCksJYhNL6j5pLPT4CZaJVO+K0GGzcVAxPba/ijnrAIIM3EcrJFFu5PUMOsmZXQ4/Au0L4kQnLcQZp1N118n4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600996336331411.2705573043679; Thu, 24 Sep 2020 18:12:16 -0700 (PDT) Received: from localhost ([::1]:45430 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLcHX-0002V5-0q for importer@patchew.org; Thu, 24 Sep 2020 21:12:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51608) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLbco-0001a0-KS for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:30:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:58024) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLbcj-0000Jc-AY for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:30:10 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-209-6k3vV8uUNR2QaF5mM8sQTA-1; Thu, 24 Sep 2020 20:29:40 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A5EA21008550 for ; Fri, 25 Sep 2020 00:29:39 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id A16F25D9DD; Fri, 25 Sep 2020 00:29:38 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600993803; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=c4feM44XQc0TAE09TT5lNOmorTyE+zBWAge5h2hgu+Q=; b=PNzwIPDa7yhvgn/2ke0ACxkCfmc21SMJJhVBUYhQFyVhnubFdR7N9w/+CNeooJLW7gi8Db tLZRhkVK/9sRvy+PoB7JkLdxmmipDshpbNjCj6hxv+EoNL9dvfBM9eteW38nS8nc07GDTe 4nlxBkESuBGdJnwSzn/5/rgD1KxveZw= X-MC-Unique: 6k3vV8uUNR2QaF5mM8sQTA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 42/47] qapi/introspect.py: create a typed 'Node' data structure Date: Thu, 24 Sep 2020 20:28:55 -0400 Message-Id: <20200925002900.465855-43-jsnow@redhat.com> In-Reply-To: <20200925002900.465855-1-jsnow@redhat.com> References: <20200925002900.465855-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 23:02:20 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This replaces _make_tree with Node.__init__(), effectively. By creating it as a generic container, we can more accurately describe the exact nature of this particular Node. Signed-off-by: John Snow --- scripts/qapi/introspect.py | 77 +++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 39 deletions(-) diff --git a/scripts/qapi/introspect.py b/scripts/qapi/introspect.py index c444214090..3832edaf9d 100644 --- a/scripts/qapi/introspect.py +++ b/scripts/qapi/introspect.py @@ -12,11 +12,12 @@ =20 from typing import ( Dict, + Generic, + Iterable, List, Optional, Sequence, - Tuple, - Union, + TypeVar, ) =20 from .common import ( @@ -42,42 +43,42 @@ from .source import QAPISourceInfo =20 # The correct type for TreeNode is actually: -# Union[AnnotatedNode, List[TreeNode], Dict[str, TreeNode], str, bool] +# Union[Node[TreeNode], List[TreeNode], Dict[str, TreeNode], str, bool] # but mypy does not support recursive types yet. TreeNode =3D object +_NodeType =3D TypeVar('_NodeType', bound=3DTreeNode) _DObject =3D Dict[str, object] -Extra =3D Dict[str, object] -AnnotatedNode =3D Tuple[TreeNode, Extra] =20 =20 -def _make_tree(obj: Union[_DObject, str], ifcond: List[str], - comment: Optional[str] =3D None) -> AnnotatedNode: - extra: Extra =3D { - 'if': ifcond, - 'comment': comment, - } - return (obj, extra) +class Node(Generic[_NodeType]): + """ + Node generally contains a SchemaInfo-like type (as a dict), + But it also used to wrap comments/ifconds around leaf value types. + """ + # Remove after 3.7 adds @dataclass: + # pylint: disable=3Dtoo-few-public-methods + def __init__(self, data: _NodeType, ifcond: Iterable[str], + comment: Optional[str] =3D None): + self.data =3D data + self.comment: Optional[str] =3D comment + self.ifcond: Sequence[str] =3D tuple(ifcond) =20 =20 -def _tree_to_qlit(obj: TreeNode, - level: int =3D 0, +def _tree_to_qlit(obj: TreeNode, level: int =3D 0, suppress_first_indent: bool =3D False) -> str: =20 def indent(level: int) -> str: return level * 4 * ' ' =20 - if isinstance(obj, tuple): - ifobj, extra =3D obj - ifcond =3D extra.get('if') - comment =3D extra.get('comment') + if isinstance(obj, Node): ret =3D '' - if comment: - ret +=3D indent(level) + '/* %s */\n' % comment - if ifcond: - ret +=3D gen_if(ifcond) - ret +=3D _tree_to_qlit(ifobj, level) - if ifcond: - ret +=3D '\n' + gen_endif(ifcond) + if obj.comment: + ret +=3D indent(level) + '/* %s */\n' % obj.comment + if obj.ifcond: + ret +=3D gen_if(obj.ifcond) + ret +=3D _tree_to_qlit(obj.data, level) + if obj.ifcond: + ret +=3D '\n' + gen_endif(obj.ifcond) return ret =20 ret =3D '' @@ -124,7 +125,7 @@ def __init__(self, prefix: str, unmask: bool): ' * QAPI/QMP schema introspection', __doc__) self._unmask =3D unmask self._schema: Optional[QAPISchema] =3D None - self._trees: List[AnnotatedNode] =3D [] + self._trees: List[Node[_DObject]] =3D [] self._used_types: List[QAPISchemaType] =3D [] self._name_map: Dict[str, str] =3D {} self._genc.add(mcgen(''' @@ -191,9 +192,8 @@ def _use_type(self, typ: QAPISchemaType) -> str: =20 @classmethod def _gen_features(cls, - features: List[QAPISchemaFeature] - ) -> List[AnnotatedNode]: - return [_make_tree(f.name, f.ifcond) for f in features] + features: List[QAPISchemaFeature]) -> List[Node[str]= ]: + return [Node(f.name, f.ifcond) for f in features] =20 def _gen_tree(self, name: str, mtype: str, obj: _DObject, ifcond: List[str], @@ -209,10 +209,10 @@ def _gen_tree(self, name: str, mtype: str, obj: _DObj= ect, obj['meta-type'] =3D mtype if features: obj['features'] =3D self._gen_features(features) - self._trees.append(_make_tree(obj, ifcond, comment)) + self._trees.append(Node(obj, ifcond, comment)) =20 def _gen_member(self, - member: QAPISchemaObjectTypeMember) -> AnnotatedNode: + member: QAPISchemaObjectTypeMember) -> Node[_DObject]: obj: _DObject =3D { 'name': member.name, 'type': self._use_type(member.type) @@ -221,19 +221,19 @@ def _gen_member(self, obj['default'] =3D None if member.features: obj['features'] =3D self._gen_features(member.features) - return _make_tree(obj, member.ifcond) + return Node(obj, member.ifcond) =20 def _gen_variants(self, tag_name: str, variants: List[QAPISchemaVariant]) -> _DObject: return {'tag': tag_name, 'variants': [self._gen_variant(v) for v in variants]} =20 - def _gen_variant(self, variant: QAPISchemaVariant) -> AnnotatedNode: + def _gen_variant(self, variant: QAPISchemaVariant) -> Node[_DObject]: obj: _DObject =3D { 'case': variant.name, 'type': self._use_type(variant.type) } - return _make_tree(obj, variant.ifcond) + return Node(obj, variant.ifcond) =20 def visit_builtin_type(self, name: str, info: Optional[QAPISourceInfo], json_type: str) -> None: @@ -244,8 +244,7 @@ def visit_enum_type(self, name: str, info: QAPISourceIn= fo, members: List[QAPISchemaEnumMember], prefix: Optional[str]) -> None: self._gen_tree(name, 'enum', - {'values': [_make_tree(m.name, m.ifcond, None) - for m in members]}, + {'values': [Node(m.name, m.ifcond) for m in members= ]}, ifcond, features) =20 def visit_array_type(self, name: str, info: Optional[QAPISourceInfo], @@ -273,9 +272,9 @@ def visit_alternate_type(self, name: str, info: QAPISou= rceInfo, variants: QAPISchemaVariants) -> None: self._gen_tree(name, 'alternate', {'members': [ - _make_tree({'type': self._use_type(m.type)}, - m.ifcond, None) - for m in variants.variants]}, + Node({'type': self._use_type(m.type)}, m.ifcond) + for m in variants.variants + ]}, ifcond, features) =20 def visit_command(self, name: str, info: QAPISourceInfo, ifcond: List[= str], --=20 2.26.2 From nobody Wed May 15 22:57:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600996069; cv=none; d=zohomail.com; s=zohoarc; b=dBsC989Uq2mRcautP9mgVvANk3OuGgPcQwv+0fPN0jv5d49gjyRRc8OZehFkQ17CyyHnOEwFPlnQRTq/VY++psN7Zeg9eqYgQKDf1VFMty332iqJNc+j6RdG6NjHlhW0W7r8QfuMwRy+89OEWQQY51uQSw5f+/zfMeKDGHNnHJ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600996069; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=f3I4s027hY+ozWCqvcEkSGKNZAS5AIhk2nyKtWVfHo8=; b=laj4uGwBMQRHFg0HBTYOt8h+FYWSE5birFhNoN51d0jdumSVKtmRAYorj6NAIRl1bppNUfF8Blx3vw0BwlFtUknWI1xGImlXez7l39kSEVAizUqJM+xYjcc1oNvbB9EpART7JievX7fzGXUzo2/Ru5CNvzzrYycpVQm5+NlOQQQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600996069302814.1253187200294; Thu, 24 Sep 2020 18:07:49 -0700 (PDT) Received: from localhost ([::1]:57062 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLcDD-0003pJ-T0 for importer@patchew.org; Thu, 24 Sep 2020 21:07:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51510) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLbcg-0001SB-2S for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:30:02 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:24989) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLbcO-0000EZ-2W for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:30:01 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-530-uPPyDh2rOuWkHOWhPlDIdQ-1; Thu, 24 Sep 2020 20:29:41 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AF2BA1008548 for ; Fri, 25 Sep 2020 00:29:40 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id CDA2E5D9DD; Fri, 25 Sep 2020 00:29:39 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600993783; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=f3I4s027hY+ozWCqvcEkSGKNZAS5AIhk2nyKtWVfHo8=; b=GrwJb2n1MUhtBg0/PYYwJhKWAIAmi7c9SOHpVUCvzQ1zCr6llOpcSWn3X5FneRnQfrGCPo SHOorIdwJHJ2ycvKmGTuzFJHbd1xdnQNzr/s97aB9kIm+0v347mrOk8bvZ7khyx4jqdVLj Wv/AC46cCDTOYauKbAAGRVJpNWZrOuU= X-MC-Unique: uPPyDh2rOuWkHOWhPlDIdQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 43/47] qapi/types.py: add type hint annotations Date: Thu, 24 Sep 2020 20:28:56 -0400 Message-Id: <20200925002900.465855-44-jsnow@redhat.com> In-Reply-To: <20200925002900.465855-1-jsnow@redhat.com> References: <20200925002900.465855-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/24 01:10:00 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Annotations do not change runtime behavior. This commit *only* adds annotations. Signed-off-by: John Snow Reviewed-by: Eduardo Habkost Reviewed-by: Cleber Rosa --- scripts/qapi/mypy.ini | 5 --- scripts/qapi/types.py | 86 ++++++++++++++++++++++++++++++++----------- 2 files changed, 64 insertions(+), 27 deletions(-) diff --git a/scripts/qapi/mypy.ini b/scripts/qapi/mypy.ini index 9ce8b56f22..3babc380a8 100644 --- a/scripts/qapi/mypy.ini +++ b/scripts/qapi/mypy.ini @@ -29,11 +29,6 @@ disallow_untyped_defs =3D False disallow_incomplete_defs =3D False check_untyped_defs =3D False =20 -[mypy-qapi.types] -disallow_untyped_defs =3D False -disallow_incomplete_defs =3D False -check_untyped_defs =3D False - [mypy-qapi.visit] disallow_untyped_defs =3D False disallow_incomplete_defs =3D False diff --git a/scripts/qapi/types.py b/scripts/qapi/types.py index cc6dad4c89..b65188bac3 100644 --- a/scripts/qapi/types.py +++ b/scripts/qapi/types.py @@ -13,6 +13,8 @@ # See the COPYING file in the top-level directory. """ =20 +from typing import List, Optional + from .common import ( c_enum_const, c_name, @@ -21,14 +23,25 @@ mcgen, ) from .gen import QAPISchemaModularCVisitor, ifcontext -from .schema import QAPISchemaEnumMember, QAPISchemaObjectType +from .schema import ( + QAPISchema, + QAPISchemaEnumMember, + QAPISchemaFeature, + QAPISchemaObjectType, + QAPISchemaObjectTypeMember, + QAPISchemaType, + QAPISchemaVariants, +) +from .source import QAPISourceInfo =20 # variants must be emitted before their container; track what has already # been output objects_seen =3D set() =20 =20 -def gen_enum_lookup(name, members, prefix=3DNone): +def gen_enum_lookup(name: str, + members: List[QAPISchemaEnumMember], + prefix: Optional[str] =3D None) -> str: ret =3D mcgen(''' =20 const QEnumLookup %(c_name)s_lookup =3D { @@ -53,7 +66,9 @@ def gen_enum_lookup(name, members, prefix=3DNone): return ret =20 =20 -def gen_enum(name, members, prefix=3DNone): +def gen_enum(name: str, + members: List[QAPISchemaEnumMember], + prefix: Optional[str] =3D None) -> str: # append automatically generated _MAX value enum_members =3D members + [QAPISchemaEnumMember('_MAX', None)] =20 @@ -87,7 +102,7 @@ def gen_enum(name, members, prefix=3DNone): return ret =20 =20 -def gen_fwd_object_or_array(name): +def gen_fwd_object_or_array(name: str) -> str: return mcgen(''' =20 typedef struct %(c_name)s %(c_name)s; @@ -95,7 +110,7 @@ def gen_fwd_object_or_array(name): c_name=3Dc_name(name)) =20 =20 -def gen_array(name, element_type): +def gen_array(name: str, element_type: QAPISchemaType) -> str: return mcgen(''' =20 struct %(c_name)s { @@ -106,7 +121,7 @@ def gen_array(name, element_type): c_name=3Dc_name(name), c_type=3Delement_type.c_type()) =20 =20 -def gen_struct_members(members): +def gen_struct_members(members: List[QAPISchemaObjectTypeMember]) -> str: ret =3D '' for memb in members: ret +=3D gen_if(memb.ifcond) @@ -123,7 +138,10 @@ def gen_struct_members(members): return ret =20 =20 -def gen_object(name, ifcond, base, members, variants): +def gen_object(name: str, ifcond: List[str], + base: Optional[QAPISchemaObjectType], + members: List[QAPISchemaObjectTypeMember], + variants: Optional[QAPISchemaVariants]) -> str: if name in objects_seen: return '' objects_seen.add(name) @@ -177,7 +195,7 @@ def gen_object(name, ifcond, base, members, variants): return ret =20 =20 -def gen_upcast(name, base): +def gen_upcast(name: str, base: QAPISchemaObjectType) -> str: # C makes const-correctness ugly. We have to cast away const to let # this function work for both const and non-const obj. return mcgen(''' @@ -190,7 +208,7 @@ def gen_upcast(name, base): c_name=3Dc_name(name), base=3Dbase.c_name()) =20 =20 -def gen_variants(variants): +def gen_variants(variants: QAPISchemaVariants) -> str: ret =3D mcgen(''' union { /* union tag is @%(c_name)s */ ''', @@ -214,7 +232,7 @@ def gen_variants(variants): return ret =20 =20 -def gen_type_cleanup_decl(name): +def gen_type_cleanup_decl(name: str) -> str: ret =3D mcgen(''' =20 void qapi_free_%(c_name)s(%(c_name)s *obj); @@ -224,7 +242,7 @@ def gen_type_cleanup_decl(name): return ret =20 =20 -def gen_type_cleanup(name): +def gen_type_cleanup(name: str) -> str: ret =3D mcgen(''' =20 void qapi_free_%(c_name)s(%(c_name)s *obj) @@ -246,12 +264,12 @@ def gen_type_cleanup(name): =20 class QAPISchemaGenTypeVisitor(QAPISchemaModularCVisitor): =20 - def __init__(self, prefix): + def __init__(self, prefix: str): super().__init__( prefix, 'qapi-types', ' * Schema-defined QAPI types', ' * Built-in QAPI types', __doc__) =20 - def _begin_system_module(self, name): + def _begin_system_module(self, name: None) -> None: self._genc.preamble_add(mcgen(''' #include "qemu/osdep.h" #include "qapi/dealloc-visitor.h" @@ -262,7 +280,7 @@ def _begin_system_module(self, name): #include "qapi/util.h" ''')) =20 - def _begin_user_module(self, name): + def _begin_user_module(self, name: str) -> None: types =3D self._module_basename('qapi-types', name) visit =3D self._module_basename('qapi-visit', name) self._genc.preamble_add(mcgen(''' @@ -276,27 +294,43 @@ def _begin_user_module(self, name): #include "qapi/qapi-builtin-types.h" ''')) =20 - def visit_begin(self, schema): + def visit_begin(self, schema: QAPISchema) -> None: # gen_object() is recursive, ensure it doesn't visit the empty type objects_seen.add(schema.the_empty_object_type.name) =20 - def _gen_type_cleanup(self, name): + def _gen_type_cleanup(self, name: str) -> None: self._genh.add(gen_type_cleanup_decl(name)) self._genc.add(gen_type_cleanup(name)) =20 - def visit_enum_type(self, name, info, ifcond, features, members, prefi= x): + def visit_enum_type(self, + name: str, + info: Optional[QAPISourceInfo], + ifcond: List[str], + features: List[QAPISchemaFeature], + members: List[QAPISchemaEnumMember], + prefix: Optional[str]) -> None: with ifcontext(ifcond, self._genh, self._genc): self._genh.preamble_add(gen_enum(name, members, prefix)) self._genc.add(gen_enum_lookup(name, members, prefix)) =20 - def visit_array_type(self, name, info, ifcond, element_type): + def visit_array_type(self, + name: str, + info: Optional[QAPISourceInfo], + ifcond: List[str], + element_type: QAPISchemaType) -> None: with ifcontext(ifcond, self._genh, self._genc): self._genh.preamble_add(gen_fwd_object_or_array(name)) self._genh.add(gen_array(name, element_type)) self._gen_type_cleanup(name) =20 - def visit_object_type(self, name, info, ifcond, features, - base, members, variants): + def visit_object_type(self, + name: str, + info: Optional[QAPISourceInfo], + ifcond: List[str], + features: List[QAPISchemaFeature], + base: Optional[QAPISchemaObjectType], + members: List[QAPISchemaObjectTypeMember], + variants: Optional[QAPISchemaVariants]) -> None: # Nothing to do for the special empty builtin if name =3D=3D 'q_empty': return @@ -312,7 +346,12 @@ def visit_object_type(self, name, info, ifcond, featur= es, # implicit types won't be directly allocated/freed self._gen_type_cleanup(name) =20 - def visit_alternate_type(self, name, info, ifcond, features, variants): + def visit_alternate_type(self, + name: str, + info: QAPISourceInfo, + ifcond: List[str], + features: List[QAPISchemaFeature], + variants: QAPISchemaVariants) -> None: with ifcontext(ifcond, self._genh): self._genh.preamble_add(gen_fwd_object_or_array(name)) self._genh.add(gen_object(name, ifcond, None, @@ -321,7 +360,10 @@ def visit_alternate_type(self, name, info, ifcond, fea= tures, variants): self._gen_type_cleanup(name) =20 =20 -def gen_types(schema, output_dir, prefix, opt_builtins): +def gen_types(schema: QAPISchema, + output_dir: str, + prefix: str, + opt_builtins: bool) -> None: vis =3D QAPISchemaGenTypeVisitor(prefix) schema.visit(vis) vis.write(output_dir, opt_builtins) --=20 2.26.2 From nobody Wed May 15 22:57:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600995963; cv=none; d=zohomail.com; s=zohoarc; b=lI0KaS5TQVpEEURO20yTLy+Ktqgf2wnl9D2hpFSVEUVJnfh3VS9FjwMGPEUWHSVhEyiewfSm9ldV9d/wer8/y5dQPhKt2ia9uwaFPhOXPz2tl5p2Fj4mSIB2Zcvm/40kyWib6irGmg56aq9J8ICQ1YA7LOUoeYKGWh1O6XhojLA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600995963; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=K39UVClIFQUiElEmbP5qZD9j3jq0JdeFhVdJGULYtQU=; b=Ze8qr5lNcASjJYmbjlejRiANnEvPRrmzYY0v8HYK3DXqzKfv7stYkKKnPsIyzG5KEezmF8L1EMW9NN+uW84Xiftq7ZdhHsp2dz1A28cx+SpBEV3WzgdajDhh//OSheggImlJwjFpjB8fxUS1F4nbFvaBna8qkITRi8h5XUOVMHI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600995963606427.14932982587175; Thu, 24 Sep 2020 18:06:03 -0700 (PDT) Received: from localhost ([::1]:51376 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLcBW-0001PM-7a for importer@patchew.org; Thu, 24 Sep 2020 21:06:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51642) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLbcq-0001ai-RV for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:30:13 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:31907) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLbcn-0000Kw-Of for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:30:12 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-2-XdK7H5kBMM2SWLdeSxzhpQ-1; Thu, 24 Sep 2020 20:29:42 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CE7661091062 for ; Fri, 25 Sep 2020 00:29:41 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id E56355D9DD; Fri, 25 Sep 2020 00:29:40 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600993807; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=K39UVClIFQUiElEmbP5qZD9j3jq0JdeFhVdJGULYtQU=; b=gAyqeFDSe+CS5UVwuC9WoWz8tJuijgDXITpSE04IYY9ML2Vixdh177p2nnBLGm9PjbqMHM GBheoncLz1XiwLIH7ut4RyxayBHG8TnMh/GvO3oXUOSuXEv8P6owCL/azulSgG/Vx1mdkh 3tmQeHvKXa+tPXyiuEef0x/hnF7/KW8= X-MC-Unique: XdK7H5kBMM2SWLdeSxzhpQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 44/47] qapi/types.py: remove one-letter variables Date: Thu, 24 Sep 2020 20:28:57 -0400 Message-Id: <20200925002900.465855-45-jsnow@redhat.com> In-Reply-To: <20200925002900.465855-1-jsnow@redhat.com> References: <20200925002900.465855-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/24 01:10:00 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" "John, if pylint told you to jump off a bridge, would you?" Hey, if it looked like fun, I might. Now that this file is clean, enable pylint checks on this file. Signed-off-by: John Snow Reviewed-by: Eduardo Habkost Reviewed-by: Cleber Rosa --- scripts/qapi/pylintrc | 1 - scripts/qapi/types.py | 29 +++++++++++++++-------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/scripts/qapi/pylintrc b/scripts/qapi/pylintrc index de132d03cf..cebaf600f9 100644 --- a/scripts/qapi/pylintrc +++ b/scripts/qapi/pylintrc @@ -7,7 +7,6 @@ ignore-patterns=3Ddoc.py, expr.py, parser.py, schema.py, - types.py, visit.py, =20 =20 diff --git a/scripts/qapi/types.py b/scripts/qapi/types.py index b65188bac3..20b75c3505 100644 --- a/scripts/qapi/types.py +++ b/scripts/qapi/types.py @@ -48,14 +48,14 @@ def gen_enum_lookup(name: str, .array =3D (const char *const[]) { ''', c_name=3Dc_name(name)) - for m in members: - ret +=3D gen_if(m.ifcond) - index =3D c_enum_const(name, m.name, prefix) + for member in members: + ret +=3D gen_if(member.ifcond) + index =3D c_enum_const(name, member.name, prefix) ret +=3D mcgen(''' [%(index)s] =3D "%(name)s", ''', - index=3Dindex, name=3Dm.name) - ret +=3D gen_endif(m.ifcond) + index=3Dindex, name=3Dmember.name) + ret +=3D gen_endif(member.ifcond) =20 ret +=3D mcgen(''' }, @@ -78,13 +78,13 @@ def gen_enum(name: str, ''', c_name=3Dc_name(name)) =20 - for m in enum_members: - ret +=3D gen_if(m.ifcond) + for member in enum_members: + ret +=3D gen_if(member.ifcond) ret +=3D mcgen(''' %(c_enum)s, ''', - c_enum=3Dc_enum_const(name, m.name, prefix)) - ret +=3D gen_endif(m.ifcond) + c_enum=3Dc_enum_const(name, member.name, prefix)) + ret +=3D gen_endif(member.ifcond) =20 ret +=3D mcgen(''' } %(c_name)s; @@ -147,11 +147,12 @@ def gen_object(name: str, ifcond: List[str], objects_seen.add(name) =20 ret =3D '' - if variants: - for v in variants.variants: - if isinstance(v.type, QAPISchemaObjectType): - ret +=3D gen_object(v.type.name, v.type.ifcond, v.type.bas= e, - v.type.local_members, v.type.variants) + for variant in variants.variants if variants else (): + obj =3D variant.type + if not isinstance(obj, QAPISchemaObjectType): + continue + ret +=3D gen_object(obj.name, obj.ifcond, obj.base, + obj.local_members, obj.variants) =20 ret +=3D mcgen(''' =20 --=20 2.26.2 From nobody Wed May 15 22:57:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600996187; cv=none; d=zohomail.com; s=zohoarc; b=SRH7CuwipO29DshMFwcrRI1YHxibM5WwNbMy0mM9K1weEfmlzOv5+dN0lFKfpgd+khBA7j2xU5wUn8niAD5ZuHkAq08yswZo3M6OLv1Ryxwxoo+XeUupEWlCJ3zwa9yxoR6m1zn4wVW8OBo1CE9nutOWhzoF91+8BhREbavkWE4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600996187; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=OhcZnb/+Tcn1kp7RyJIH5SwfSB7oizUP9sPRRlnWrPk=; b=Ab39TIuKM9eG6mAVoqM7X05HAiHXGHM2YxcgGMLseHFA+h63zv1PthLt8OUARcI0Wl7NXU4L4EE/1X3TpjTd/bfo76UdY29guOqdkpiBN63/Z551TkLD4g/8OK8yMHkmUdw52FZfEZhIF2K9sdB+erqCoWBiQ5ZkMjKVChngzmE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600996187741399.01370108223466; Thu, 24 Sep 2020 18:09:47 -0700 (PDT) Received: from localhost ([::1]:37202 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLcF8-0007Lw-FQ for importer@patchew.org; Thu, 24 Sep 2020 21:09:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51544) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLbch-0001XB-R7 for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:30:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:37749) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLbcS-0000FJ-96 for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:30:03 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-527-QrOczCFjMfmF9uEnuHWcYQ-1; Thu, 24 Sep 2020 20:29:43 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 99FDC1091068 for ; Fri, 25 Sep 2020 00:29:42 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id 014D65D9DD; Fri, 25 Sep 2020 00:29:41 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600993787; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OhcZnb/+Tcn1kp7RyJIH5SwfSB7oizUP9sPRRlnWrPk=; b=Oz2GZz207tJFjuU0tZ2mDFUwRCHJtZvsD2AiwLXTBjnyde4Cf0/znxGJfz65ISX9ymg8bf m7+7qy999s7Lq8+9t/IIpVMy0LuwMqX8ywdR9Tvis+5vbEAgJxCz7n03u9u4y1+7eXxnzt zzH/807ru8F0HMHeR4kxYfgfJx0af/w= X-MC-Unique: QrOczCFjMfmF9uEnuHWcYQ-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 45/47] qapi/visit.py: assert tag_member contains a QAPISchemaEnumType Date: Thu, 24 Sep 2020 20:28:58 -0400 Message-Id: <20200925002900.465855-46-jsnow@redhat.com> In-Reply-To: <20200925002900.465855-1-jsnow@redhat.com> References: <20200925002900.465855-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 23:02:20 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This is true by design, but not presently able to be expressed in the type system. An assertion helps mypy understand our constraints. Signed-off-by: John Snow Reviewed-by: Eduardo Habkost Reviewed-by: Cleber Rosa --- scripts/qapi/visit.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/qapi/visit.py b/scripts/qapi/visit.py index 14f30c228b..4f11fd325b 100644 --- a/scripts/qapi/visit.py +++ b/scripts/qapi/visit.py @@ -22,7 +22,7 @@ mcgen, ) from .gen import QAPISchemaModularCVisitor, ifcontext -from .schema import QAPISchemaObjectType +from .schema import QAPISchemaEnumType, QAPISchemaObjectType =20 =20 def gen_visit_decl(name, scalar=3DFalse): @@ -84,15 +84,17 @@ def gen_visit_object_members(name, base, members, varia= nts): ret +=3D gen_endif(memb.ifcond) =20 if variants: + tag_member =3D variants.tag_member + assert isinstance(tag_member.type, QAPISchemaEnumType) + ret +=3D mcgen(''' switch (obj->%(c_name)s) { ''', - c_name=3Dc_name(variants.tag_member.name)) + c_name=3Dc_name(tag_member.name)) =20 for var in variants.variants: - case_str =3D c_enum_const(variants.tag_member.type.name, - var.name, - variants.tag_member.type.prefix) + case_str =3D c_enum_const(tag_member.type.name, var.name, + tag_member.type.prefix) ret +=3D gen_if(var.ifcond) if var.type.name =3D=3D 'q_empty': # valid variant and nothing to do --=20 2.26.2 From nobody Wed May 15 22:57:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600995477; cv=none; d=zohomail.com; s=zohoarc; b=YjORB7vO4Nf4NmuCCzn4zEcp0ue0jmYTKr4Ij1gbhBu3nawPmXUreD49Jy5RmBiOByjszsoHaYApbcU7huNgcp8HSNGoZuPiSgxf5LyLY4UxTS29FP8cjUvewInaOF/MIYk8EiUcemcznuRPAWSTZadkiOqIQLQCAsMXyQlwJjk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600995477; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Z5imZQmYqpwDigqgXRKzlv8okp2lZwuOGbCNeOz7txc=; b=FClDPDwIEZhXjOhq7mn5ggJgpGVv+VKRfFViyLiQuW233BQl/x3LxpfguJdYuvhPzzf0wJ4oioffXLFrO5xJHWAZNT0aOAZxQIgLMTs1eG6RnbR4O5BIxo3RVVm+RWBLcCSjSOuDwzVtpuMfbFrdAYAC4pqZ14eUBOOrk8YfA7c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600995477287515.219486539313; Thu, 24 Sep 2020 17:57:57 -0700 (PDT) Received: from localhost ([::1]:54364 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLc3f-0007KU-LJ for importer@patchew.org; Thu, 24 Sep 2020 20:57:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51528) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLbch-0001UX-1Y for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:30:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:21187) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLbcS-0000F5-8y for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:30:02 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-574-H7PwPRxdOvC75fxgDSHnJA-1; Thu, 24 Sep 2020 20:29:44 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 89DDE109106C for ; Fri, 25 Sep 2020 00:29:43 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id C2BE55D9DD; Fri, 25 Sep 2020 00:29:42 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600993786; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Z5imZQmYqpwDigqgXRKzlv8okp2lZwuOGbCNeOz7txc=; b=KZTGzs+TuoRriqXiF107MmuoRWlB/cbLbyjN+fTompGYPmKTCJBvzo74SOGeY2ISWa4OT7 aovkJiYhQH7mWJ3hVF50nXzy5UEnu4GgwMAJ6jNITQxFNTcRTuMpLpEojGxMrzSLlP1BNC +0kTn5v9mcN1U0OiUlRuqmGDXloY4bo= X-MC-Unique: H7PwPRxdOvC75fxgDSHnJA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 46/47] qapi/visit.py: remove unused parameters from gen_visit_object Date: Thu, 24 Sep 2020 20:28:59 -0400 Message-Id: <20200925002900.465855-47-jsnow@redhat.com> In-Reply-To: <20200925002900.465855-1-jsnow@redhat.com> References: <20200925002900.465855-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/24 01:10:00 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" And this fixes the pylint report for this file, so make sure we check this in the future, too. Signed-off-by: John Snow Reviewed-by: Eduardo Habkost Reviewed-by: Cleber Rosa Tested-by: Cleber Rosa --- scripts/qapi/pylintrc | 1 - scripts/qapi/visit.py | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/qapi/pylintrc b/scripts/qapi/pylintrc index cebaf600f9..581755351b 100644 --- a/scripts/qapi/pylintrc +++ b/scripts/qapi/pylintrc @@ -7,7 +7,6 @@ ignore-patterns=3Ddoc.py, expr.py, parser.py, schema.py, - visit.py, =20 =20 [MESSAGES CONTROL] diff --git a/scripts/qapi/visit.py b/scripts/qapi/visit.py index 4f11fd325b..e54694e23d 100644 --- a/scripts/qapi/visit.py +++ b/scripts/qapi/visit.py @@ -250,7 +250,7 @@ def gen_visit_alternate(name, variants): return ret =20 =20 -def gen_visit_object(name, base, members, variants): +def gen_visit_object(name): return mcgen(''' =20 bool visit_type_%(c_name)s @@ -343,7 +343,7 @@ def visit_object_type(self, name, info, ifcond, feature= s, if not name.startswith('q_'): # only explicit types need an allocating visit self._genh.add(gen_visit_decl(name)) - self._genc.add(gen_visit_object(name, base, members, varia= nts)) + self._genc.add(gen_visit_object(name)) =20 def visit_alternate_type(self, name, info, ifcond, features, variants): with ifcontext(ifcond, self._genh, self._genc): --=20 2.26.2 From nobody Wed May 15 22:57:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1600995725; cv=none; d=zohomail.com; s=zohoarc; b=ZPnhTAUWFdkKFQIuORhsE8ItbYSGuQI4OoJ3AK7NseIs/cNZgzEhH010n59U5mj/ghssL0xPfwsqgd+j6tNdLysAiFopghAgX8Q5tbuqvoRaSU1CS39hC/Oih4CpB3WnjUXNbsWc6eSDNYsa4YGjYQc2b7Ql4f2b1MZYfVY/cjA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600995725; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8PdN2Xceg+pUbHNWsceYjl+XWMYW+37uzBGhMCm/pL4=; b=liP1mCTSV3aK1Qs9ZDCt9uI1CmHcqHUzhK2s5cnMouJPMNVP6AFUcsAwRcivAJS8m+1rWeCqLHydFam4hpwwdh5l/jwofNpFrpDvtIRDOtoL2BZK2vRw0UCxOiSva++drb28fSRIVC807+yB4PzymeDbBn4hqVbc599EY5osCoI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600995725470330.1912052444201; Thu, 24 Sep 2020 18:02:05 -0700 (PDT) Received: from localhost ([::1]:40040 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLc7g-0004zP-2Y for importer@patchew.org; Thu, 24 Sep 2020 21:02:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51514) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLbcg-0001TU-Kk for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:30:02 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:35588) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kLbcS-0000FQ-DQ for qemu-devel@nongnu.org; Thu, 24 Sep 2020 20:30:02 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-259-Cb1DgBAvP3mNhaUyHHv5yA-1; Thu, 24 Sep 2020 20:29:45 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C2F488015A5 for ; Fri, 25 Sep 2020 00:29:44 +0000 (UTC) Received: from scv.redhat.com (ovpn-119-140.rdu2.redhat.com [10.10.119.140]) by smtp.corp.redhat.com (Postfix) with ESMTP id C9AE45D9DD; Fri, 25 Sep 2020 00:29:43 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600993787; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8PdN2Xceg+pUbHNWsceYjl+XWMYW+37uzBGhMCm/pL4=; b=PTmJIW25ylKiJGMP69t9hUVCXa5lbBnFtrtulk+mOryP3avW9o+52t4sK4kGOAD+mX9EM/ 9J8AyFn3oxs6LWacYu2UqzI+Y3NMdMa4RSp774cwECMovlT3SxBpr/bF8lOcVJABqZKtLp X25cASZQvNvQXPBK7FhmyXUgShUaGdE= X-MC-Unique: Cb1DgBAvP3mNhaUyHHv5yA-1 From: John Snow To: qemu-devel@nongnu.org Subject: [PATCH v3 47/47] qapi/visit.py: add type hint annotations Date: Thu, 24 Sep 2020 20:29:00 -0400 Message-Id: <20200925002900.465855-48-jsnow@redhat.com> In-Reply-To: <20200925002900.465855-1-jsnow@redhat.com> References: <20200925002900.465855-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jsnow@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=jsnow@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/22 23:02:20 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1.199, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Snow , Markus Armbruster , Eduardo Habkost , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Annotations do not change runtime behavior. This commit *only* adds annotations. Signed-off-by: John Snow Reviewed-by: Eduardo Habkost Reviewed-by: Cleber Rosa Tested-by: Cleber Rosa --- scripts/qapi/mypy.ini | 5 --- scripts/qapi/visit.py | 73 +++++++++++++++++++++++++++++++++---------- 2 files changed, 56 insertions(+), 22 deletions(-) diff --git a/scripts/qapi/mypy.ini b/scripts/qapi/mypy.ini index 3babc380a8..5ab3433c5f 100644 --- a/scripts/qapi/mypy.ini +++ b/scripts/qapi/mypy.ini @@ -28,8 +28,3 @@ check_untyped_defs =3D False disallow_untyped_defs =3D False disallow_incomplete_defs =3D False check_untyped_defs =3D False - -[mypy-qapi.visit] -disallow_untyped_defs =3D False -disallow_incomplete_defs =3D False -check_untyped_defs =3D False diff --git a/scripts/qapi/visit.py b/scripts/qapi/visit.py index e54694e23d..14d4f0b261 100644 --- a/scripts/qapi/visit.py +++ b/scripts/qapi/visit.py @@ -13,6 +13,8 @@ See the COPYING file in the top-level directory. """ =20 +from typing import List, Optional + from .common import ( c_enum_const, c_name, @@ -22,10 +24,20 @@ mcgen, ) from .gen import QAPISchemaModularCVisitor, ifcontext -from .schema import QAPISchemaEnumType, QAPISchemaObjectType +from .schema import ( + QAPISchema, + QAPISchemaEnumMember, + QAPISchemaEnumType, + QAPISchemaFeature, + QAPISchemaObjectType, + QAPISchemaObjectTypeMember, + QAPISchemaType, + QAPISchemaVariants, +) +from .source import QAPISourceInfo =20 =20 -def gen_visit_decl(name, scalar=3DFalse): +def gen_visit_decl(name: str, scalar: bool =3D False) -> str: c_type =3D c_name(name) + ' *' if not scalar: c_type +=3D '*' @@ -37,7 +49,7 @@ def gen_visit_decl(name, scalar=3DFalse): c_name=3Dc_name(name), c_type=3Dc_type) =20 =20 -def gen_visit_members_decl(name): +def gen_visit_members_decl(name: str) -> str: return mcgen(''' =20 bool visit_type_%(c_name)s_members(Visitor *v, %(c_name)s *obj, Error **er= rp); @@ -45,7 +57,10 @@ def gen_visit_members_decl(name): c_name=3Dc_name(name)) =20 =20 -def gen_visit_object_members(name, base, members, variants): +def gen_visit_object_members(name: str, + base: Optional[QAPISchemaObjectType], + members: List[QAPISchemaObjectTypeMember], + variants: Optional[QAPISchemaVariants]) -> st= r: ret =3D mcgen(''' =20 bool visit_type_%(c_name)s_members(Visitor *v, %(c_name)s *obj, Error **er= rp) @@ -125,7 +140,7 @@ def gen_visit_object_members(name, base, members, varia= nts): return ret =20 =20 -def gen_visit_list(name, element_type): +def gen_visit_list(name: str, element_type: QAPISchemaType) -> str: return mcgen(''' =20 bool visit_type_%(c_name)s(Visitor *v, const char *name, @@ -159,7 +174,7 @@ def gen_visit_list(name, element_type): c_name=3Dc_name(name), c_elt_type=3Delement_type.c_name()) =20 =20 -def gen_visit_enum(name): +def gen_visit_enum(name: str) -> str: return mcgen(''' =20 bool visit_type_%(c_name)s(Visitor *v, const char *name, @@ -174,7 +189,7 @@ def gen_visit_enum(name): c_name=3Dc_name(name)) =20 =20 -def gen_visit_alternate(name, variants): +def gen_visit_alternate(name: str, variants: QAPISchemaVariants) -> str: ret =3D mcgen(''' =20 bool visit_type_%(c_name)s @@ -250,7 +265,7 @@ def gen_visit_alternate(name, variants): return ret =20 =20 -def gen_visit_object(name): +def gen_visit_object(name: str) -> str: return mcgen(''' =20 bool visit_type_%(c_name)s @@ -285,12 +300,12 @@ def gen_visit_object(name): =20 class QAPISchemaGenVisitVisitor(QAPISchemaModularCVisitor): =20 - def __init__(self, prefix): + def __init__(self, prefix: str): super().__init__( prefix, 'qapi-visit', ' * Schema-defined QAPI visitors', ' * Built-in QAPI visitors', __doc__) =20 - def _begin_system_module(self, name): + def _begin_system_module(self, name: None) -> None: self._genc.preamble_add(mcgen(''' #include "qemu/osdep.h" #include "qapi/error.h" @@ -302,7 +317,7 @@ def _begin_system_module(self, name): =20 ''')) =20 - def _begin_user_module(self, name): + def _begin_user_module(self, name: str) -> None: types =3D self._module_basename('qapi-types', name) visit =3D self._module_basename('qapi-visit', name) self._genc.preamble_add(mcgen(''' @@ -319,18 +334,34 @@ def _begin_user_module(self, name): ''', types=3Dtypes)) =20 - def visit_enum_type(self, name, info, ifcond, features, members, prefi= x): + def visit_enum_type(self, + name: str, + info: QAPISourceInfo, + ifcond: List[str], + features: List[QAPISchemaFeature], + members: List[QAPISchemaEnumMember], + prefix: Optional[str]) -> None: with ifcontext(ifcond, self._genh, self._genc): self._genh.add(gen_visit_decl(name, scalar=3DTrue)) self._genc.add(gen_visit_enum(name)) =20 - def visit_array_type(self, name, info, ifcond, element_type): + def visit_array_type(self, + name: str, + info: Optional[QAPISourceInfo], + ifcond: List[str], + element_type: QAPISchemaType) -> None: with ifcontext(ifcond, self._genh, self._genc): self._genh.add(gen_visit_decl(name)) self._genc.add(gen_visit_list(name, element_type)) =20 - def visit_object_type(self, name, info, ifcond, features, - base, members, variants): + def visit_object_type(self, + name: str, + info: Optional[QAPISourceInfo], + ifcond: List[str], + features: List[QAPISchemaFeature], + base: Optional[QAPISchemaObjectType], + members: List[QAPISchemaObjectTypeMember], + variants: Optional[QAPISchemaVariants]) -> None: # Nothing to do for the special empty builtin if name =3D=3D 'q_empty': return @@ -345,13 +376,21 @@ def visit_object_type(self, name, info, ifcond, featu= res, self._genh.add(gen_visit_decl(name)) self._genc.add(gen_visit_object(name)) =20 - def visit_alternate_type(self, name, info, ifcond, features, variants): + def visit_alternate_type(self, + name: str, + info: QAPISourceInfo, + ifcond: List[str], + features: List[QAPISchemaFeature], + variants: QAPISchemaVariants) -> None: with ifcontext(ifcond, self._genh, self._genc): self._genh.add(gen_visit_decl(name)) self._genc.add(gen_visit_alternate(name, variants)) =20 =20 -def gen_visit(schema, output_dir, prefix, opt_builtins): +def gen_visit(schema: QAPISchema, + output_dir: str, + prefix: str, + opt_builtins: bool) -> None: vis =3D QAPISchemaGenVisitVisitor(prefix) schema.visit(vis) vis.write(output_dir, opt_builtins) --=20 2.26.2