[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v9 08/14] iotests: touch up log function signature
From: |
Max Reitz |
Subject: |
Re: [PATCH v9 08/14] iotests: touch up log function signature |
Date: |
Mon, 30 Mar 2020 14:28:36 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 |
On 25.03.20 00:20, John Snow wrote:
> Representing nested, recursive data structures in mypy is notoriously
> difficult; the best we can reliably do right now is denote the atom
> types as "Any" while describing the general shape of the data.
>
> Regardless, this fully annotates the log() function.
>
> Typing notes:
>
> TypeVar is a Type variable that can optionally be constrained by a
> sequence of possible types. This variable is bound per-invocation such
> that the signature for filter=() requires that its callables take e.g. a
> str and return a str.
So it works like a generic, except that its declaration isn’t part of
and thus local to the function. Interesting. Not sure if I like it,
but, well, it’s Python. (Seems to me on the same level of “Interesting”
as the “Don’t use an empty list as a default argument” thing.[1])
> Signed-off-by: John Snow <address@hidden>
> ---
> tests/qemu-iotests/iotests.py | 14 +++++++++++---
> 1 file changed, 11 insertions(+), 3 deletions(-)
Haha. I can’t help but find it funny how my “I won’t complain, but I
feel like some people might want this to be two patches” led to this “If
I’m going to make a dedicated patch for this, I might as well go all the
way” patch. It’s quite cool.
Reviewed-by: Max Reitz <address@hidden>
[1] I just read an article on that thing again (empty lists as default
argument), which claims that this is in fact a very useful feature of
Python. This makes me want to go on another rant, but I’ve learned
enough restraint by now not to.
signature.asc
Description: OpenPGP digital signature
- [PATCH v9 05/14] iotests: add pylintrc file, (continued)
- [PATCH v9 05/14] iotests: add pylintrc file, John Snow, 2020/03/24
- [PATCH v9 06/14] iotests: alphabetize standard imports, John Snow, 2020/03/24
- [PATCH v9 07/14] iotests: drop pre-Python 3.4 compatibility code, John Snow, 2020/03/24
- [PATCH v9 08/14] iotests: touch up log function signature, John Snow, 2020/03/24
- [PATCH v9 10/14] iotests: add hmp helper with logging, John Snow, 2020/03/24
- [PATCH v9 12/14] iotest 258: use script_main, John Snow, 2020/03/24
- [PATCH v9 09/14] iotests: limit line length to 79 chars, John Snow, 2020/03/24