From a2e51ab6c3e5d44b289173de18ef7c54f9127627 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Fri, 18 Feb 2022 18:08:26 +0200 Subject: [PATCH 1/3] Uniform TaskGroup.__repr__ --- Lib/asyncio/taskgroups.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/Lib/asyncio/taskgroups.py b/Lib/asyncio/taskgroups.py index 57b0eafefc16fe..b2fe007567321d 100644 --- a/Lib/asyncio/taskgroups.py +++ b/Lib/asyncio/taskgroups.py @@ -9,6 +9,7 @@ from . import exceptions from . import tasks + class TaskGroup: def __init__(self): @@ -25,19 +26,20 @@ def __init__(self): self._on_completed_fut = None def __repr__(self): - msg = f'' async def __aenter__(self): if self._entered: From 0248f31b95583387b5597db39103cd8c3c0fdb67 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Fri, 18 Feb 2022 21:09:08 +0200 Subject: [PATCH 2/3] Replace : with = --- Lib/asyncio/taskgroups.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Lib/asyncio/taskgroups.py b/Lib/asyncio/taskgroups.py index b2fe007567321d..23a830c3084501 100644 --- a/Lib/asyncio/taskgroups.py +++ b/Lib/asyncio/taskgroups.py @@ -28,11 +28,11 @@ def __init__(self): def __repr__(self): info = [] if self._tasks: - info.append(f'tasks:{len(self._tasks)}') + info.append(f'tasks={len(self._tasks)}') if self._unfinished_tasks: - info.append(f'unfinished:{self._unfinished_tasks}') + info.append(f'unfinished={self._unfinished_tasks}') if self._errors: - info.append(f'errors:{len(self._errors)}') + info.append(f'errors={len(self._errors)}') if self._aborting: info.append('cancelling') elif self._entered: From eee2cc9b1917210369a1bb8d1e3e047ff5cf6f97 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Fri, 18 Feb 2022 23:36:03 +0200 Subject: [PATCH 3/3] Init repr's info as [''] --- Lib/asyncio/taskgroups.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/asyncio/taskgroups.py b/Lib/asyncio/taskgroups.py index 23a830c3084501..756fc551e013d9 100644 --- a/Lib/asyncio/taskgroups.py +++ b/Lib/asyncio/taskgroups.py @@ -26,7 +26,7 @@ def __init__(self): self._on_completed_fut = None def __repr__(self): - info = [] + info = [''] if self._tasks: info.append(f'tasks={len(self._tasks)}') if self._unfinished_tasks: @@ -38,7 +38,7 @@ def __repr__(self): elif self._entered: info.append('entered') - info_str = ' ' + ' '.join(info) + info_str = ' '.join(info) return f'' async def __aenter__(self):