From 46969eda5192833c75f24086eda30706de394792 Mon Sep 17 00:00:00 2001 From: Patrick Arminio Date: Tue, 20 Aug 2024 16:09:24 +0200 Subject: [PATCH] Change return type of Live's contextmanager to `Self` --- rich/live.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/rich/live.py b/rich/live.py index f0529a781..9d2262d19 100644 --- a/rich/live.py +++ b/rich/live.py @@ -3,6 +3,12 @@ from types import TracebackType from typing import IO, Any, Callable, List, Optional, TextIO, Type, cast +if sys.version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self # pragma: no cover + + from . import get_console from .console import Console, ConsoleRenderable, RenderableType, RenderHook from .control import Control @@ -162,7 +168,7 @@ def stop(self) -> None: if self.ipy_widget is not None and self.transient: self.ipy_widget.close() # pragma: no cover - def __enter__(self) -> "Live": + def __enter__(self) -> Self: self.start(refresh=self._renderable is not None) return self