rich
rich copied to clipboard
🐛 Fix type annotations for `@group` decorator
Type of changes
- [x] Bug fix
- [ ] New feature
- [ ] Documentation / docstrings
- [ ] Tests
- [x] Other (type annotations)
Checklist
- [ ] I've run the latest black with default args on new code.
- [ ] I've updated CHANGELOG.md and CONTRIBUTORS.md where appropriate.
- [ ] I've added tests for new code.
- [x] I accept that @willmcgugan may be pedantic in the code review.
Description
The current type annotations for rich.console.group discard any type information in the original function.
This means that calling the function decorated with @group() doesn't get autocompletion nor inline errors for the arguments.
This is how it looks right now, notice that it should be showing an error:

And there's no autocompletion for the function parameters:

This change fixes the type annotations of the resulting function decorated with @group().
Now it shows errors:

And it shows autocompletion:

Hehe, it seems there's a discrepancy in the types, not sure. I suspect the new types caught something not completely right. It probably needs an update in the types for group() or in the types for traceback._render_syntax_error(), but I'm not sure which one of the two is wrong...
Thanks. I think we might tackle this as part of a larger review of typing. https://github.com/Textualize/rich/issues/2846