Describe the bug
The Live class's __enter__ method has an improperly annotated return type.
The method returns "Live", which causes improper type information when using context managers on subclasses of Live
In the example below, the live object returned by the context manager would be typed as an instance of Live instead of CustomLive by most type checkers.
from rich.live import Live
class CustomLive(Live):
pass
with CustomLive() as live:
...
Suggested Fix
Replace the return type of the __enter__ method with typing.Self
from typing import Self
class Live(JupyterMixin, RenderHook):
def __enter__(self) -> Self:
self.start(refresh=self._renderable is not None)
return self```