Use nested type docstrings as default helptext for argument groups - #485
Use nested type docstrings as default helptext for argument groups#485brentyi wants to merge 2 commits into
Conversation
) The docstring fallback for group descriptions existed but was unreachable: field helptext is stored as a lazy callable for deferred docstring parsing, so it was never None even when evaluation would return None. Evaluate lazily and fall back to the nested type's class docstring only when the field has no attribute docstring or explicit help. An explicit tyro.conf.arg(help="") still suppresses the group description.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #485 +/- ##
=======================================
Coverage 99.79% 99.79%
=======================================
Files 53 53
Lines 4495 4495
=======================================
Hits 4486 4486
Misses 9 9
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Python 3.8 resolves class source code by scanning for the first matching class name in the file, so tests that reuse local class names can pick up the wrong attribute docstrings. This broke the docstring precedence test on 3.8 only.
|
Status: the pytest (3.8) failure was real and is fixed in c6939ff (Python 3.8 resolves class source by scanning for the first matching class name in the file, so the new tests needed unique local class names). The remaining ruff, mypy, and ty failures are pre-existing on main: CI runs unpinned latest linters, and all flagged locations are in files this PR does not touch. I verified locally that unmodified main fails ruff 0.16.0 with the same 18 PLR0917 errors (PLR0917 was stabilized in 0.16.0; mypy and ty failures are similar version drift in Generated by Claude Code |
Use the class docstring of nested types as the default argument group description, fixing the unreachable docstring fallback described in #483.