qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: John Snow <jsnow@redhat.com>
To: Eric Blake <eblake@redhat.com>, Kevin Wolf <kwolf@redhat.com>
Cc: Peter Krempa <pkrempa@redhat.com>,
	qemu-devel@nongnu.org,
	"open list:Block layer core" <qemu-block@nongnu.org>,
	Max Reitz <mreitz@redhat.com>
Subject: Re: [PULL 3/5] qemu-iotests: 300: Add test case for modifying persistence of bitmap
Date: Mon, 15 Feb 2021 14:00:23 -0500	[thread overview]
Message-ID: <0138182f-0e17-f225-0060-85f1776f26dc@redhat.com> (raw)
In-Reply-To: <42192dc8-329c-ef2d-d8f7-3d02ae9d2c85@redhat.com>

On 2/15/21 1:25 PM, Eric Blake wrote:
> -BlockBitmapMapping = List[Dict[str, Union[str, List[Dict[str, str]]]]]
> +BlockBitmapMapping = List[Dict[str,
> +                               Union[str,
> +                                     List[Dict[str,
> +                                               Union[str, Dict[str,
> bool]]]]]]]

That looks *very* beefy.

Is the Union because that union is valid for every key, or because every 
key has a potentially different value that is specific to that key?

if it's the latter, I'd ditch the Union and just go with:

Dict[str, object], or
Dict[str, Any]

object: will allow any type, but keeps strict checking enabled. If you 
try to use that value later on without a cast, mypy will warn you if you 
are using it in a manner not guaranteed by the "object" type. Can be 
useful if you are passing values to a function that already does RTTI to 
determine behavior.

Any: Also allows any type, but enables gradual typing. If you later 
"assume" the type of this value, mypy will say nothing. Can be useful 
when you've just got a job to do and the right tool would have been a 
recursive type or a TypedDict (unavailable in Python 3.6.)

--js



  reply	other threads:[~2021-02-15 19:02 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-12 23:21 [PULL 0/5] bitmaps patches through 2021-02-12 Eric Blake
2021-02-12 23:21 ` [PULL 1/5] migration: dirty-bitmap: Use struct for alias map inner members Eric Blake
2021-02-12 23:21 ` [PULL 2/5] migration: dirty-bitmap: Allow control of bitmap persistence Eric Blake
2021-02-12 23:21 ` [PULL 3/5] qemu-iotests: 300: Add test case for modifying persistence of bitmap Eric Blake
2021-02-15 12:31   ` Kevin Wolf
2021-02-15 16:46     ` Eric Blake
2021-02-15 17:09       ` Kevin Wolf
2021-02-15 18:25         ` Eric Blake
2021-02-15 19:00           ` John Snow [this message]
2021-02-15 20:26             ` Eric Blake
2021-02-15 21:37               ` John Snow
2021-02-12 23:21 ` [PULL 4/5] block: return status from bdrv_append and friends Eric Blake
2021-02-12 23:21 ` [PULL 5/5] block: use return status of bdrv_append() Eric Blake
2021-02-14 18:45 ` [PULL 0/5] bitmaps patches through 2021-02-12 Peter Maydell

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=0138182f-0e17-f225-0060-85f1776f26dc@redhat.com \
    --to=jsnow@redhat.com \
    --cc=eblake@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=pkrempa@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /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).