rich icon indicating copy to clipboard operation
rich copied to clipboard

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

Open patrick91 opened this issue 1 year ago • 1 comments

Type of changes

  • [ ] Bug fix
  • [ ] New feature
  • [ ] Documentation / docstrings
  • [ ] Tests
  • [x] Other

Checklist

  • [ ] I've run the latest black with default args on new code.
  • [x] I've updated CHANGELOG.md and CONTRIBUTORS.md where appropriate.
  • [x] I've added tests for new code.
  • [x] I accept that @willmcgugan may be pedantic in the code review.

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 avatar Aug 20 '24 14:08 patrick91

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)

patrick91 avatar Aug 20 '24 14:08 patrick91

Looks that like was done in another PR!

willmcgugan avatar Sep 30 '24 14:09 willmcgugan