diff --git a/CHANGELOG.md b/CHANGELOG.md index bdd4f15974..bbfe8c5fc2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +### Fixed + +- Fixed `@auto` to be safe with `tuple`-valued positionals https://github.com/Textualize/rich/issues/4016 + ## [14.3.3] - 2026-02-19 ### Fixed diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 4d77a0e3ed..136bb13c79 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -100,3 +100,4 @@ The following people have contributed to the development of Rich: - [Brandon Capener](https://github.com/bcapener) - [Alex Zheng](https://github.com/alexzheng111) - [Sebastian Speitel](https://github.com/SebastianSpeitel) +- [David S.](https://github.com/finite-state-machine) diff --git a/rich/repr.py b/rich/repr.py index 95331006ee..c6e7761b4c 100644 --- a/rich/repr.py +++ b/rich/repr.py @@ -71,13 +71,13 @@ def auto_rich_repr(self: Type[T]) -> Result: signature = inspect.signature(self.__init__) for name, param in signature.parameters.items(): if param.kind == param.POSITIONAL_ONLY: - yield getattr(self, name) + yield None, getattr(self, name) elif param.kind in ( param.POSITIONAL_OR_KEYWORD, param.KEYWORD_ONLY, ): if param.default is param.empty: - yield getattr(self, param.name) + yield None, getattr(self, param.name) else: yield param.name, getattr(self, param.name), param.default except Exception as error: diff --git a/tests/test_repr.py b/tests/test_repr.py index 94fd6da1f6..4147101159 100644 --- a/tests/test_repr.py +++ b/tests/test_repr.py @@ -124,6 +124,9 @@ def test_rich_repr_auto() -> None: == f"Bird('penguin', ['fish'], another={repr(stupid_class)}, extinct={repr(not_stupid)})" ) +def test_rich_repr_auto_with_tuples() -> None: + assert repr(Egg(('hello', 'world'), egg=2)) == "Egg(('hello', 'world'), egg=2)" + def test_rich_repr_auto_angular() -> None: assert repr(AngularEgg("hello", egg=2)) == ""