* [PATCH] qapi/parser: Mollify mypy
@ 2025-11-05 15:22 Markus Armbruster
2025-11-06 8:22 ` Vladimir Sementsov-Ogievskiy
2025-11-10 10:58 ` Richard Henderson
0 siblings, 2 replies; 4+ messages in thread
From: Markus Armbruster @ 2025-11-05 15:22 UTC (permalink / raw)
To: qemu-devel; +Cc: richard.henderson, vsementsov
re.match(r'^ *', ...) can't fail, but mypy doesn't know that and
complains:
scripts/qapi/parser.py:444: error: Item "None" of "Match[str] | None" has no attribute "end" [union-attr]
Work around by using must_match() instead.
Fixes: 8107ba47fd78 (qapi: Add documentation format validation)
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
scripts/qapi/parser.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py
index 1bb1af7051..c3cf33904e 100644
--- a/scripts/qapi/parser.py
+++ b/scripts/qapi/parser.py
@@ -441,7 +441,7 @@ def get_doc_line(self) -> Optional[str]:
self._literal_mode = True
self._literal_mode_indent = 0
elif self._literal_mode and line:
- indent = re.match(r'^ *', line).end()
+ indent = must_match(r'\s*', line).end()
if self._literal_mode_indent == 0:
self._literal_mode_indent = indent
elif indent < self._literal_mode_indent:
--
2.49.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] qapi/parser: Mollify mypy
2025-11-05 15:22 [PATCH] qapi/parser: Mollify mypy Markus Armbruster
@ 2025-11-06 8:22 ` Vladimir Sementsov-Ogievskiy
2025-11-10 10:58 ` Richard Henderson
1 sibling, 0 replies; 4+ messages in thread
From: Vladimir Sementsov-Ogievskiy @ 2025-11-06 8:22 UTC (permalink / raw)
To: Markus Armbruster, qemu-devel; +Cc: richard.henderson
On 05.11.25 18:22, Markus Armbruster wrote:
> re.match(r'^ *', ...) can't fail, but mypy doesn't know that and
> complains:
>
> scripts/qapi/parser.py:444: error: Item "None" of "Match[str] | None" has no attribute "end" [union-attr]
>
> Work around by using must_match() instead.
>
> Fixes: 8107ba47fd78 (qapi: Add documentation format validation)
> Signed-off-by: Markus Armbruster<armbru@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
--
Best regards,
Vladimir
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] qapi/parser: Mollify mypy
2025-11-05 15:22 [PATCH] qapi/parser: Mollify mypy Markus Armbruster
2025-11-06 8:22 ` Vladimir Sementsov-Ogievskiy
@ 2025-11-10 10:58 ` Richard Henderson
2025-11-10 11:20 ` Markus Armbruster
1 sibling, 1 reply; 4+ messages in thread
From: Richard Henderson @ 2025-11-10 10:58 UTC (permalink / raw)
To: Markus Armbruster, qemu-devel; +Cc: vsementsov
On 11/5/25 16:22, Markus Armbruster wrote:
> re.match(r'^ *', ...) can't fail, but mypy doesn't know that and
> complains:
>
> scripts/qapi/parser.py:444: error: Item "None" of "Match[str] | None" has no attribute "end" [union-attr]
>
> Work around by using must_match() instead.
>
> Fixes: 8107ba47fd78 (qapi: Add documentation format validation)
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
> scripts/qapi/parser.py | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py
> index 1bb1af7051..c3cf33904e 100644
> --- a/scripts/qapi/parser.py
> +++ b/scripts/qapi/parser.py
> @@ -441,7 +441,7 @@ def get_doc_line(self) -> Optional[str]:
> self._literal_mode = True
> self._literal_mode_indent = 0
> elif self._literal_mode and line:
> - indent = re.match(r'^ *', line).end()
> + indent = must_match(r'\s*', line).end()
> if self._literal_mode_indent == 0:
> self._literal_mode_indent = indent
> elif indent < self._literal_mode_indent:
Thanks. I'm going to queue this so that it's in the next CI run.
r~
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] qapi/parser: Mollify mypy
2025-11-10 10:58 ` Richard Henderson
@ 2025-11-10 11:20 ` Markus Armbruster
0 siblings, 0 replies; 4+ messages in thread
From: Markus Armbruster @ 2025-11-10 11:20 UTC (permalink / raw)
To: Richard Henderson; +Cc: qemu-devel, vsementsov
Richard Henderson <richard.henderson@linaro.org> writes:
> On 11/5/25 16:22, Markus Armbruster wrote:
>> re.match(r'^ *', ...) can't fail, but mypy doesn't know that and
>> complains:
>> scripts/qapi/parser.py:444: error: Item "None" of "Match[str] | None" has no attribute "end" [union-attr]
>> Work around by using must_match() instead.
>> Fixes: 8107ba47fd78 (qapi: Add documentation format validation)
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>> ---
>> scripts/qapi/parser.py | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>> diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py
>> index 1bb1af7051..c3cf33904e 100644
>> --- a/scripts/qapi/parser.py
>> +++ b/scripts/qapi/parser.py
>> @@ -441,7 +441,7 @@ def get_doc_line(self) -> Optional[str]:
>> self._literal_mode = True
>> self._literal_mode_indent = 0
>> elif self._literal_mode and line:
>> - indent = re.match(r'^ *', line).end()
>> + indent = must_match(r'\s*', line).end()
>> if self._literal_mode_indent == 0:
>> self._literal_mode_indent = indent
>> elif indent < self._literal_mode_indent:
>
> Thanks. I'm going to queue this so that it's in the next CI run.
Yes, please!
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-11-10 11:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-05 15:22 [PATCH] qapi/parser: Mollify mypy Markus Armbruster
2025-11-06 8:22 ` Vladimir Sementsov-Ogievskiy
2025-11-10 10:58 ` Richard Henderson
2025-11-10 11:20 ` Markus Armbruster
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).