Skip to content

Self typing #3783

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 24, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions rich/live.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from __future__ import annotations

import sys
from threading import Event, RLock, Thread
from types import TracebackType
from typing import IO, Any, Callable, List, Optional, TextIO, Type, cast
from typing import IO, TYPE_CHECKING, Any, Callable, List, Optional, TextIO, Type, cast

from . import get_console
from .console import Console, ConsoleRenderable, Group, RenderableType, RenderHook
Expand All @@ -12,6 +14,10 @@
from .screen import Screen
from .text import Text

if TYPE_CHECKING:
# Can be replaced with `from typing import Self` in Python 3.11+
from typing_extensions import Self # pragma: no cover


class _RefreshThread(Thread):
"""A thread that calls refresh() at regular intervals."""
Expand Down Expand Up @@ -170,7 +176,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

Expand Down
Loading