qemu-commits
[Top][All Lists]
Advanced

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

[Qemu-commits] [qemu/qemu] b8eaee: MAINTAINERS: Add Python library stanz


From: Peter Maydell
Subject: [Qemu-commits] [qemu/qemu] b8eaee: MAINTAINERS: Add Python library stanza
Date: Wed, 21 Oct 2020 03:11:03 -0700

  Branch: refs/heads/staging
  Home:   https://github.com/qemu/qemu
  Commit: b8eaee96e46663c74943b529fd173ce3b9189d46
      
https://github.com/qemu/qemu/commit/b8eaee96e46663c74943b529fd173ce3b9189d46
  Author: John Snow <jsnow@redhat.com>
  Date:   2020-10-20 (Tue, 20 Oct 2020)

  Changed paths:
    M MAINTAINERS

  Log Message:
  -----------
  MAINTAINERS: Add Python library stanza

I'm proposing that I split the actual Python library off from the other
miscellaneous python scripts we have and declare it maintained. Add
myself as a maintainer of this folder, along with Cleber.

I will be actively working to add CI style guide checks, strict typing,
and an actual package infrastructure to this folder specifically which
differentiates it from loose, miscellaneous scripts which are generally
maintained by other individuals with subject matter expertise.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Acked-by: Cleber Rosa <crosa@redhat.com>
Acked-by: Eduardo Habkost <ehabkost@redhat.com>


  Commit: 932ca4bbde5ed6c57a8ae0b9cabb6e0a1ca1047a
      
https://github.com/qemu/qemu/commit/932ca4bbde5ed6c57a8ae0b9cabb6e0a1ca1047a
  Author: John Snow <jsnow@redhat.com>
  Date:   2020-10-20 (Tue, 20 Oct 2020)

  Changed paths:
    A python/qemu/.isort.cfg
    M python/qemu/accel.py
    M python/qemu/console_socket.py
    M python/qemu/machine.py
    M python/qemu/qmp.py
    M python/qemu/qtest.py

  Log Message:
  -----------
  python/qemu: use isort to lay out imports

Borrowed from the QAPI cleanup series, use the same configuration to
standardize the way we write and sort imports.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 20201006235817.3280413-2-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>


  Commit: c4e6023f05fe6dd14d9193814679490feac546a4
      
https://github.com/qemu/qemu/commit/c4e6023f05fe6dd14d9193814679490feac546a4
  Author: John Snow <jsnow@redhat.com>
  Date:   2020-10-20 (Tue, 20 Oct 2020)

  Changed paths:
    M python/qemu/machine.py

  Log Message:
  -----------
  python/machine.py: Fix monitor address typing

Prior to this, it's difficult for mypy to intuit what the concrete type
of the monitor address is; it has difficulty inferring the type across
two variables.

Create _monitor_address as a property that always returns a valid
address to simplify static type analysis.

To preserve our ability to clean up, use a simple boolean to indicate
whether or not we should try to clean up the sock file after execution.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 20201006235817.3280413-3-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>


  Commit: c5e61a6da84397fe8c2af9e381d8a619a3e32c10
      
https://github.com/qemu/qemu/commit/c5e61a6da84397fe8c2af9e381d8a619a3e32c10
  Author: John Snow <jsnow@redhat.com>
  Date:   2020-10-20 (Tue, 20 Oct 2020)

  Changed paths:
    M python/qemu/machine.py

  Log Message:
  -----------
  python/machine.py: reorder __init__

Put the init arg handling all at the top, and mostly in order (deviating
when one is dependent on another), and put what is effectively runtime
state declaration at the bottom.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 20201006235817.3280413-4-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>


  Commit: 652809dfa665860c1ea4622c540a30fbe18dc9e7
      
https://github.com/qemu/qemu/commit/652809dfa665860c1ea4622c540a30fbe18dc9e7
  Author: John Snow <jsnow@redhat.com>
  Date:   2020-10-20 (Tue, 20 Oct 2020)

  Changed paths:
    M python/qemu/machine.py
    M python/qemu/qtest.py

  Log Message:
  -----------
  python/machine.py: Don't modify state in _base_args()

Don't append to the _remove_files list during _base_args; instead do so
during _launch. Rework _base_args as a @property to help facilitate
this impression.

This has the additional benefit of making the type of _console_address
easier to analyze statically.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 20201006235817.3280413-5-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>


  Commit: 1847a4a8c209379cd7f6788c0dcd5c17c2bf0907
      
https://github.com/qemu/qemu/commit/1847a4a8c209379cd7f6788c0dcd5c17c2bf0907
  Author: John Snow <jsnow@redhat.com>
  Date:   2020-10-20 (Tue, 20 Oct 2020)

  Changed paths:
    M python/qemu/machine.py

  Log Message:
  -----------
  python/machine.py: Handle None events in events_wait

If the timeout is 0, we can get None back. Handle this explicitly.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 20201006235817.3280413-6-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>


  Commit: aaa81ec6093b2d45d5a318227db82fa71680a871
      
https://github.com/qemu/qemu/commit/aaa81ec6093b2d45d5a318227db82fa71680a871
  Author: John Snow <jsnow@redhat.com>
  Date:   2020-10-20 (Tue, 20 Oct 2020)

  Changed paths:
    M python/qemu/machine.py

  Log Message:
  -----------
  python/machine.py: use qmp.command

machine.py and qmp.py both do the same thing here; refactor machine.py
to use qmp.py's functionality more directly.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-id: 20201006235817.3280413-7-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>


  Commit: be1183e52f49cd0f9c1a855afe4c4a5455f966d1
      
https://github.com/qemu/qemu/commit/be1183e52f49cd0f9c1a855afe4c4a5455f966d1
  Author: John Snow <jsnow@redhat.com>
  Date:   2020-10-20 (Tue, 20 Oct 2020)

  Changed paths:
    M python/qemu/machine.py

  Log Message:
  -----------
  python/machine.py: Add _qmp access shim

Like many other Optional[] types, it's not always a given that this
object will be set. Wrap it in a type-shim that raises a meaningful
error and will always return a concrete type.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 20201006235817.3280413-8-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>


  Commit: 9223fda464690b83a2b1f1487163f50602454c2e
      
https://github.com/qemu/qemu/commit/9223fda464690b83a2b1f1487163f50602454c2e
  Author: John Snow <jsnow@redhat.com>
  Date:   2020-10-20 (Tue, 20 Oct 2020)

  Changed paths:
    M python/qemu/machine.py

  Log Message:
  -----------
  python/machine.py: fix _popen access

As always, Optional[T] causes problems with unchecked access. Add a
helper that asserts the pipe is present before we attempt to talk with
it.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 20201006235817.3280413-9-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>


  Commit: aad3f3bb6c8b63b33db30911748fe32928b7b4bd
      
https://github.com/qemu/qemu/commit/aad3f3bb6c8b63b33db30911748fe32928b7b4bd
  Author: John Snow <jsnow@redhat.com>
  Date:   2020-10-20 (Tue, 20 Oct 2020)

  Changed paths:
    M python/qemu/machine.py
    M python/qemu/qtest.py

  Log Message:
  -----------
  python/qemu: make 'args' style arguments immutable

These arguments don't need to be mutable and aren't really used as
such. Clarify their types as immutable and adjust code to match where
necessary.

In general, It's probably best not to accept a user-defined mutable
object and store it as internal object state unless there's a strong
justification for doing so. Instead, try to use generic types as input
with empty tuples as the default, and coerce to list where necessary.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-id: 20201006235817.3280413-10-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>


  Commit: 090744d552e18e600bf6d3c896a52d4846aa3e53
      
https://github.com/qemu/qemu/commit/090744d552e18e600bf6d3c896a52d4846aa3e53
  Author: John Snow <jsnow@redhat.com>
  Date:   2020-10-20 (Tue, 20 Oct 2020)

  Changed paths:
    M tests/qemu-iotests/iotests.py

  Log Message:
  -----------
  iotests.py: Adjust HMP kwargs typing

mypy wants to ensure there's consistency between the kwargs arguments
types and any unspecified keyword arguments. In this case, conv_keys is
a bool, but the remaining keys are Any type. Mypy (correctly) infers the
**kwargs type to be **Dict[str, str], which is not compatible with
conv_keys: bool.

Because QMP typing is a little fraught right now anyway, re-type kwargs
to Dict[str, Any] which has the benefit of silencing this check right
now.

A future re-design might type these more aggressively, but this will
give us a baseline to work from with minimal disruption.

(Thanks Kevin Wolf for the debugging assist here)

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 20201006235817.3280413-11-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>


  Commit: f12a282ff4728c8b66435eaddde589db41745beb
      
https://github.com/qemu/qemu/commit/f12a282ff4728c8b66435eaddde589db41745beb
  Author: John Snow <jsnow@redhat.com>
  Date:   2020-10-20 (Tue, 20 Oct 2020)

  Changed paths:
    M python/qemu/accel.py
    M python/qemu/machine.py
    M python/qemu/qmp.py
    M python/qemu/qtest.py

  Log Message:
  -----------
  python/qemu: Add mypy type annotations

These should all be purely annotations with no changes in behavior at
all. You need to be in the python folder, but you should be able to
confirm that these annotations are correct (or at least self-consistent)
by running `mypy --strict qemu`.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 20201006235817.3280413-12-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>


  Commit: ff3513e6329ee0c2e7ea4a862c615cdb9c1ffc1b
      
https://github.com/qemu/qemu/commit/ff3513e6329ee0c2e7ea4a862c615cdb9c1ffc1b
  Author: John Snow <jsnow@redhat.com>
  Date:   2020-10-20 (Tue, 20 Oct 2020)

  Changed paths:
    M python/qemu/console_socket.py

  Log Message:
  -----------
  python/qemu/console_socket.py: Correct type of recv()

The type and parameter names of recv() should match socket.socket().

OK, easy enough, but in the cases we don't pass straight through to the
real socket implementation, we probably can't accept such flags. OK, for
now, assert that we don't receive flags in such cases.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 20201006235817.3280413-13-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>


  Commit: 6cf4cce7cb489fb5ed7eb72124f6b0c422155ebc
      
https://github.com/qemu/qemu/commit/6cf4cce7cb489fb5ed7eb72124f6b0c422155ebc
  Author: John Snow <jsnow@redhat.com>
  Date:   2020-10-20 (Tue, 20 Oct 2020)

  Changed paths:
    M python/qemu/console_socket.py

  Log Message:
  -----------
  python/qemu/console_socket.py: fix typing of settimeout

The types and names of the parameters must match the socket.socket interface.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 20201006235817.3280413-14-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>


  Commit: 714ac05a1996c0adf2740bce935f790d8824ea9e
      
https://github.com/qemu/qemu/commit/714ac05a1996c0adf2740bce935f790d8824ea9e
  Author: John Snow <jsnow@redhat.com>
  Date:   2020-10-20 (Tue, 20 Oct 2020)

  Changed paths:
    M python/qemu/console_socket.py

  Log Message:
  -----------
  python/qemu/console_socket.py: Clarify type of drain_thread

Mypy needs just a little help to guess the type here.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 20201006235817.3280413-15-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>


  Commit: e35c13826768cf4224b4f9c6884b08f3a7ed887e
      
https://github.com/qemu/qemu/commit/e35c13826768cf4224b4f9c6884b08f3a7ed887e
  Author: John Snow <jsnow@redhat.com>
  Date:   2020-10-20 (Tue, 20 Oct 2020)

  Changed paths:
    M python/qemu/console_socket.py

  Log Message:
  -----------
  python/qemu/console_socket.py: Add type hint annotations

Finish the typing of console_socket.py with annotations and no code
changes.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 20201006235817.3280413-16-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>


  Commit: af0db8825400ea8c79fd77ed4ba6fb6699bd0855
      
https://github.com/qemu/qemu/commit/af0db8825400ea8c79fd77ed4ba6fb6699bd0855
  Author: John Snow <jsnow@redhat.com>
  Date:   2020-10-20 (Tue, 20 Oct 2020)

  Changed paths:
    M python/qemu/console_socket.py

  Log Message:
  -----------
  python/qemu/console_socket.py: avoid encoding to/from string

We can work directly in bytes instead of translating back and forth to
string, which removes the question of which encodings to use.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 20201006235817.3280413-17-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>


  Commit: d2b08b79b0d0f1f794b9ed8f3b8fbcbfdfb9e142
      
https://github.com/qemu/qemu/commit/d2b08b79b0d0f1f794b9ed8f3b8fbcbfdfb9e142
  Author: John Snow <jsnow@redhat.com>
  Date:   2020-10-20 (Tue, 20 Oct 2020)

  Changed paths:
    M python/qemu/qmp.py

  Log Message:
  -----------
  python/qemu/qmp.py: Preserve error context on re-raise

Use the "from ..." phrasing when re-raising errors to preserve their
initial context, to help aid debugging when things go wrong.

This also silences a pylint 2.6.0+ error.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 20201006235817.3280413-18-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>


  Commit: c3a404d3be115f2429a6608a1bbd74623db294bb
      
https://github.com/qemu/qemu/commit/c3a404d3be115f2429a6608a1bbd74623db294bb
  Author: John Snow <jsnow@redhat.com>
  Date:   2020-10-20 (Tue, 20 Oct 2020)

  Changed paths:
    A python/mypy.ini

  Log Message:
  -----------
  python: add mypy config

Formalize the options used for checking the python library. You can run
mypy from the directory that mypy.ini is in by typing `mypy qemu/`.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 20201009175123.249009-2-jsnow@redhat.com
[Edit: Added newline; thanks Bin Meng --js]
Signed-off-by: John Snow <jsnow@redhat.com>


  Commit: d5cca076c3a1ac55f25792fae4fae2b0b1f71e8e
      
https://github.com/qemu/qemu/commit/d5cca076c3a1ac55f25792fae4fae2b0b1f71e8e
  Author: John Snow <jsnow@redhat.com>
  Date:   2020-10-20 (Tue, 20 Oct 2020)

  Changed paths:
    M python/qemu/qmp.py

  Log Message:
  -----------
  python/qemu/qmp.py: re-raise OSError when encountered

Nested if conditions don't change when the exception block fires; we
need to explicitly re-raise the error if we didn't intend to capture and
suppress it.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-id: 20201009175123.249009-3-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>


  Commit: 39cf73c3494045b4418c9c1db8e803640e2150dc
      
https://github.com/qemu/qemu/commit/39cf73c3494045b4418c9c1db8e803640e2150dc
  Author: John Snow <jsnow@redhat.com>
  Date:   2020-10-20 (Tue, 20 Oct 2020)

  Changed paths:
    M python/qemu/qmp.py

  Log Message:
  -----------
  python/qemu/qmp.py: Fix settimeout operation

We enabled callers to interface directly with settimeout, but this
reacts poorly with blocking/nonblocking operation; as they are using the
same internal mechanism.

1. Whenever we change the blocking mechanism temporarily, always set it
back to what it was afterwards.

2. Disallow callers from setting a timeout of "0", which means
Non-blocking mode. This is going to create more weird problems than
anybody wants, so just forbid it.

I opt not to coerce '0' to 'None' to maintain the principal of least
surprise in mirroring the semantics of Python's interface.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-id: 20201009175123.249009-4-jsnow@redhat.com
Signed-off-by: John Snow <jsnow@redhat.com>


  Commit: 67e8498937866b49b513e3acadef985c15f44fb5
      
https://github.com/qemu/qemu/commit/67e8498937866b49b513e3acadef985c15f44fb5
  Author: Peter Maydell <peter.maydell@linaro.org>
  Date:   2020-10-21 (Wed, 21 Oct 2020)

  Changed paths:
    M MAINTAINERS
    A python/mypy.ini
    A python/qemu/.isort.cfg
    M python/qemu/accel.py
    M python/qemu/console_socket.py
    M python/qemu/machine.py
    M python/qemu/qmp.py
    M python/qemu/qtest.py
    M tests/qemu-iotests/iotests.py

  Log Message:
  -----------
  Merge remote-tracking branch 'remotes/jsnow-gitlab/tags/python-pull-request' 
into staging

Pull request

# gpg: Signature made Tue 20 Oct 2020 20:04:54 BST
# gpg:                using RSA key F9B7ABDBBCACDF95BE76CBD07DEF8106AAFC390E
# gpg: Good signature from "John Snow (John Huston) <jsnow@redhat.com>" [full]
# Primary key fingerprint: FAEB 9711 A12C F475 812F  18F2 88A9 064D 1835 61EB
#      Subkey fingerprint: F9B7 ABDB BCAC DF95 BE76  CBD0 7DEF 8106 AAFC 390E

* remotes/jsnow-gitlab/tags/python-pull-request: (21 commits)
  python/qemu/qmp.py: Fix settimeout operation
  python/qemu/qmp.py: re-raise OSError when encountered
  python: add mypy config
  python/qemu/qmp.py: Preserve error context on re-raise
  python/qemu/console_socket.py: avoid encoding to/from string
  python/qemu/console_socket.py: Add type hint annotations
  python/qemu/console_socket.py: Clarify type of drain_thread
  python/qemu/console_socket.py: fix typing of settimeout
  python/qemu/console_socket.py: Correct type of recv()
  python/qemu: Add mypy type annotations
  iotests.py: Adjust HMP kwargs typing
  python/qemu: make 'args' style arguments immutable
  python/machine.py: fix _popen access
  python/machine.py: Add _qmp access shim
  python/machine.py: use qmp.command
  python/machine.py: Handle None events in events_wait
  python/machine.py: Don't modify state in _base_args()
  python/machine.py: reorder __init__
  python/machine.py: Fix monitor address typing
  python/qemu: use isort to lay out imports
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>


Compare: https://github.com/qemu/qemu/compare/ac793156f650...67e849893786



reply via email to

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