qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: John Snow <jsnow@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Fam Zheng" <fam@euphon.net>, "Kevin Wolf" <kwolf@redhat.com>,
	"Vladimir Sementsov-Ogievskiy" <vsementsov@virtuozzo.com>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	qemu-block@nongnu.org, "Alex Bennée" <alex.bennee@linaro.org>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Wainer dos Santos Moschetta" <wainersm@redhat.com>,
	"Max Reitz" <mreitz@redhat.com>,
	"Stefan Hajnoczi" <stefanha@redhat.com>,
	"Cleber Rosa" <crosa@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>
Subject: Re: [PATCH RFC 00/32] python/qemu: refactor as installable package
Date: Thu, 21 May 2020 14:48:38 -0400	[thread overview]
Message-ID: <f77b8215-0483-1678-25f4-1d7aee8ef02b@redhat.com> (raw)
In-Reply-To: <20200514055403.18902-1-jsnow@redhat.com>

Ping, please give this series a look-over. It looks big, but the changes
themselves are actually fairly tiny.

Here's a TOC:

Patch 1 moves files and renames import statements.
Patches 2-3 do some basic delinting.
Patches 4-5 do more basic delinting and add flake8/pylintrc cfg
Patches 6-10 add setup.py, pipfile, a readme, etc.
Patch 11 is a final bit of removing python2 isms.

Patches 12-32 (!) are all mypy typing fixes, and I have broken these out
in great care:

Patches 12-30 all fix one mypy issue each with bite-sized refactors each.

Patch 31 adds a mypy configuration to the package.

Patch 32 is a giant patch that has __NO__ runtime side-effects, it JUST
adds the remaining mypy annotations.


At the end of the series, you should find that mypy *strict*, flake8,
and pylint all pass 100%.

(Note: you MAY need specific versions of these tools to have them pass.
The pipfile included will help you target the correct versions.)

--js

On 5/14/20 1:53 AM, John Snow wrote:
> Hey, I got lost on my way to the store and I accidentally got 32 patches
> that convert our python library into something that passes pylint,
> flake8, and mypy --strict.
> 
> ...So, a few things:
> 
> 1. This is just an RFC. The actual design of these libraries really
> needs adjusted to be more pythonic. In general this means less
> Optional[T] return types and raising more exceptions. This could be
> handled later, but we ought to address it before publishing, if we do.
> 
> 2. We still need to think carefully about how we package this, if we
> even want to package it, what the license on the top-level package
> should be, etc.
> 
> 3. We should consider how to version it. For now, I'm using a lockstep
> versioning.
> 
> 4. You can install this package using pip3 or python3 setup.py to a
> virtual environment or to your real one. From there, any python code in
> the QEMU tree that imports these modules will work with no sys.path
> hacking or custom PYTHONPATH exports.
> 
> 5. You don't have to install it, though. I left all of the usual hacks
> in place in the rest of the tree so that everything will just keep
> working exactly as-is for right now. It's just that you COULD install it.
> 
> 6. Here's a cool trick if you don't know about it yet:
> 
>> cd qemu/python/qemu
>> pip3 install --user -e .
> 
> This will install the package in "develop" mode, which installs a
> forwarder package. When you update your source tree, the installed
> package stays "up to date" with the most recent edits.
> 
> Alright, have fun, stay safe!
> 
> John Snow (32):
>   python/qemu: create qemu.lib module
>   scripts/qmp: Fix shebang and imports
>   python//machine.py: remove bare except
>   python/qemu/lib: delint, add pylintrc
>   python/qemu/lib: delint; add flake8 config
>   python/qemu: formalize as package
>   python/qemu: add README.rst
>   python/qemu: Add Pipfile
>   python/qemu: add pylint to Pipfile
>   python/qemu: Add flake8 to Pipfile
>   python/qemu/lib: remove Python2 style super() calls
>   python/qemu/lib: fix socket.makefile() typing
>   python/qemu/lib: Adjust traceback typing
>   python//qmp.py: use True/False for non/blocking modes
>   python//qmp.py: Define common types
>   python//qmp.py: re-absorb MonitorResponseError
>   python//qmp.py: Do not return None from cmd_obj
>   python//qmp.py: add casts to JSON deserialization
>   python//qmp.py: add QMPProtocolError
>   python//qmp.py: assert sockfile is not None
>   python//machine.py: remove logging configuration
>   python//machine.py: Fix monitor address typing
>   python//machine.py: reorder __init__
>   python//machine.py: Don't modify state in _base_args()
>   python//machine.py: Handle None events in event_wait
>   python//machine.py: use qmp.command
>   python//machine.py: Add _qmp access shim
>   python//machine.py: fix _popen access
>   python//qtest.py: Check before accessing _qtest
>   python/qemu/lib: make 'args' style arguments immutable
>   python/qemu: add mypy to Pipfile
>   python/qemu/lib: Add mypy type annotations
> 
>  python/README.rst                         |   6 +
>  python/qemu/README.rst                    |   8 +
>  python/Pipfile                            |  14 +
>  python/Pipfile.lock                       | 187 +++++++++++++
>  python/qemu/__init__.py                   |  11 -
>  python/qemu/lib/.flake8                   |   2 +
>  python/qemu/lib/__init__.py               |  57 ++++
>  python/qemu/{ => lib}/accel.py            |  17 +-
>  python/qemu/{ => lib}/machine.py          | 320 +++++++++++++---------
>  python/qemu/lib/pylintrc                  |  58 ++++
>  python/qemu/{ => lib}/qmp.py              | 140 +++++++---
>  python/qemu/lib/qtest.py                  | 160 +++++++++++
>  python/qemu/qtest.py                      | 119 --------
>  python/setup.py                           |  50 ++++
>  scripts/device-crash-test                 |   2 +-
>  scripts/qmp/qemu-ga-client                |   2 +-
>  scripts/qmp/qmp                           |   4 +-
>  scripts/qmp/qmp-shell                     |   2 +-
>  scripts/qmp/qom-fuse                      |   4 +-
>  scripts/qmp/qom-get                       |   6 +-
>  scripts/qmp/qom-list                      |   4 +-
>  scripts/qmp/qom-set                       |   6 +-
>  scripts/qmp/qom-tree                      |   6 +-
>  scripts/render_block_graph.py             |   5 +-
>  scripts/simplebench/bench_block_job.py    |   4 +-
>  tests/acceptance/avocado_qemu/__init__.py |   2 +-
>  tests/acceptance/boot_linux.py            |   3 +-
>  tests/acceptance/virtio_check_params.py   |   2 +-
>  tests/acceptance/virtio_version.py        |   2 +-
>  tests/migration/guestperf/engine.py       |   2 +-
>  tests/qemu-iotests/235                    |   2 +-
>  tests/qemu-iotests/iotests.py             |   2 +-
>  tests/vm/basevm.py                        |   6 +-
>  33 files changed, 881 insertions(+), 334 deletions(-)
>  create mode 100644 python/README.rst
>  create mode 100644 python/qemu/README.rst
>  create mode 100644 python/Pipfile
>  create mode 100644 python/Pipfile.lock
>  delete mode 100644 python/qemu/__init__.py
>  create mode 100644 python/qemu/lib/.flake8
>  create mode 100644 python/qemu/lib/__init__.py
>  rename python/qemu/{ => lib}/accel.py (86%)
>  rename python/qemu/{ => lib}/machine.py (67%)
>  create mode 100644 python/qemu/lib/pylintrc
>  rename python/qemu/{ => lib}/qmp.py (70%)
>  create mode 100644 python/qemu/lib/qtest.py
>  delete mode 100644 python/qemu/qtest.py
>  create mode 100755 python/setup.py
> 

-- 
—js



      parent reply	other threads:[~2020-05-21 18:49 UTC|newest]

Thread overview: 85+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-14  5:53 [PATCH RFC 00/32] python/qemu: refactor as installable package John Snow
2020-05-14  5:53 ` [PATCH RFC 01/32] python/qemu: create qemu.lib module John Snow
2020-05-18 18:14   ` Vladimir Sementsov-Ogievskiy
2020-05-18 18:23     ` John Snow
2020-05-18 19:33       ` Vladimir Sementsov-Ogievskiy
2020-05-19  0:27         ` John Snow
2020-05-19 10:54           ` Vladimir Sementsov-Ogievskiy
2020-05-26 15:07             ` Philippe Mathieu-Daudé
2020-06-02 11:15               ` Vladimir Sementsov-Ogievskiy
2020-05-26 15:22           ` Daniel P. Berrangé
2020-05-26 15:23             ` Philippe Mathieu-Daudé
2020-05-26 15:25               ` Daniel P. Berrangé
2020-05-27 14:28                 ` John Snow
2020-05-27 14:31                   ` Daniel P. Berrangé
2020-06-02 10:08   ` Kevin Wolf
2020-06-02 16:44     ` John Snow
2020-06-03  9:00       ` Kevin Wolf
2020-06-03 14:09         ` John Snow
2020-05-14  5:53 ` [PATCH RFC 02/32] scripts/qmp: Fix shebang and imports John Snow
2020-05-26 15:55   ` Philippe Mathieu-Daudé
2020-05-14  5:53 ` [PATCH RFC 03/32] python//machine.py: remove bare except John Snow
2020-05-14 13:55   ` Eric Blake
2020-05-14 14:26     ` John Snow
2020-05-26 15:08       ` Philippe Mathieu-Daudé
2020-05-26 15:09   ` Philippe Mathieu-Daudé
2020-06-02 11:01   ` Kevin Wolf
2020-06-02 16:47     ` John Snow
2020-05-14  5:53 ` [PATCH RFC 04/32] python/qemu/lib: delint, add pylintrc John Snow
2020-05-26 15:57   ` Philippe Mathieu-Daudé
2020-05-14  5:53 ` [PATCH RFC 05/32] python/qemu/lib: delint; add flake8 config John Snow
2020-05-26 15:58   ` Philippe Mathieu-Daudé
2020-05-31  9:57   ` Philippe Mathieu-Daudé
2020-05-14  5:53 ` [PATCH RFC 06/32] python/qemu: formalize as package John Snow
2020-05-26 16:00   ` Philippe Mathieu-Daudé
2020-05-14  5:53 ` [PATCH RFC 07/32] python/qemu: add README.rst John Snow
2020-05-14  5:53 ` [PATCH RFC 08/32] python/qemu: Add Pipfile John Snow
2020-05-14  5:53 ` [PATCH RFC 09/32] python/qemu: add pylint to Pipfile John Snow
2020-05-14  5:53 ` [PATCH RFC 10/32] python/qemu: Add flake8 " John Snow
2020-05-14  5:53 ` [PATCH RFC 11/32] python/qemu/lib: remove Python2 style super() calls John Snow
2020-05-14  6:01   ` Philippe Mathieu-Daudé
2020-05-31  9:58   ` Philippe Mathieu-Daudé
2020-05-14  5:53 ` [PATCH RFC 12/32] python/qemu/lib: fix socket.makefile() typing John Snow
2020-05-31  9:59   ` Philippe Mathieu-Daudé
2020-05-14  5:53 ` [PATCH RFC 13/32] python/qemu/lib: Adjust traceback typing John Snow
2020-05-26 16:01   ` Philippe Mathieu-Daudé
2020-05-31 10:01   ` Philippe Mathieu-Daudé
2020-05-14  5:53 ` [PATCH RFC 14/32] python//qmp.py: use True/False for non/blocking modes John Snow
2020-05-14  6:02   ` Philippe Mathieu-Daudé
2020-05-31 10:01   ` Philippe Mathieu-Daudé
2020-05-14  5:53 ` [PATCH RFC 15/32] python//qmp.py: Define common types John Snow
2020-05-14  5:53 ` [PATCH RFC 16/32] python//qmp.py: re-absorb MonitorResponseError John Snow
2020-05-14  6:03   ` Philippe Mathieu-Daudé
2020-05-14  5:53 ` [PATCH RFC 17/32] python//qmp.py: Do not return None from cmd_obj John Snow
2020-05-14  5:53 ` [PATCH RFC 18/32] python//qmp.py: add casts to JSON deserialization John Snow
2020-05-26 16:03   ` Philippe Mathieu-Daudé
2020-05-14  5:53 ` [PATCH RFC 19/32] python//qmp.py: add QMPProtocolError John Snow
2020-05-14  6:05   ` Philippe Mathieu-Daudé
2020-05-14  5:53 ` [PATCH RFC 20/32] python//qmp.py: assert sockfile is not None John Snow
2020-05-26 16:03   ` Philippe Mathieu-Daudé
2020-05-26 16:05     ` Philippe Mathieu-Daudé
2020-05-31 10:02   ` Philippe Mathieu-Daudé
2020-05-14  5:53 ` [PATCH RFC 21/32] python//machine.py: remove logging configuration John Snow
2020-05-14  6:06   ` Philippe Mathieu-Daudé
2020-05-31 10:03   ` Philippe Mathieu-Daudé
2020-05-14  5:53 ` [PATCH RFC 22/32] python//machine.py: Fix monitor address typing John Snow
2020-05-14  5:53 ` [PATCH RFC 23/32] python//machine.py: reorder __init__ John Snow
2020-05-14  6:08   ` Philippe Mathieu-Daudé
2020-05-14  5:53 ` [PATCH RFC 24/32] python//machine.py: Don't modify state in _base_args() John Snow
2020-05-14  5:53 ` [PATCH RFC 25/32] python//machine.py: Handle None events in event_wait John Snow
2020-05-14  5:53 ` [PATCH RFC 26/32] python//machine.py: use qmp.command John Snow
2020-05-29  0:18   ` John Snow
2020-06-02 10:18     ` Kevin Wolf
2020-06-02 10:26       ` Kevin Wolf
2020-06-02 20:11         ` John Snow
2020-05-14  5:53 ` [PATCH RFC 27/32] python//machine.py: Add _qmp access shim John Snow
2020-05-14  5:53 ` [PATCH RFC 28/32] python//machine.py: fix _popen access John Snow
2020-05-14  5:54 ` [PATCH RFC 29/32] python//qtest.py: Check before accessing _qtest John Snow
2020-05-14  6:13   ` Philippe Mathieu-Daudé
2020-05-31 10:04   ` Philippe Mathieu-Daudé
2020-05-14  5:54 ` [PATCH RFC 30/32] python/qemu/lib: make 'args' style arguments immutable John Snow
2020-05-14  5:54 ` [PATCH RFC 31/32] python/qemu: add mypy to Pipfile John Snow
2020-05-14  5:54 ` [PATCH RFC 32/32] python/qemu/lib: Add mypy type annotations John Snow
2020-05-18 12:41 ` [PATCH RFC 00/32] python/qemu: refactor as installable package Philippe Mathieu-Daudé
2020-05-18 14:15   ` John Snow
2020-05-21 18:48 ` John Snow [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f77b8215-0483-1678-25f4-1d7aee8ef02b@redhat.com \
    --to=jsnow@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=armbru@redhat.com \
    --cc=crosa@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=fam@euphon.net \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=philmd@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=vsementsov@virtuozzo.com \
    --cc=wainersm@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).