Textualize / rich

Rich is a Python library for rich text and beautiful formatting in the terminal.
https://rich.readthedocs.io/en/latest/
MIT License
49.69k stars 1.73k forks source link

Change return type of `Live`'s contextmanager to `Self` #3462

Closed patrick91 closed 1 month ago

patrick91 commented 3 months ago

Type of changes

Checklist

Description

When subclassing Live and using the new class a contextmanager I don't get the proper type hints, since __enter__ returns Live and not my subclass, this PR fixes that 😊

patrick91 commented 3 months ago

Ah, the CI error is due to mypy being less than v1.0: https://github.com/python/mypy/blob/master/CHANGELOG.md#support-the-self-type

happy to update that if that's ok (I'd do another since there might be other CI issues with the update)

willmcgugan commented 1 month ago

Looks that like was done in another PR!