From a04dfddfe403cd59e3764aef16a990d7dd4efece Mon Sep 17 00:00:00 2001 From: Brent Yi Date: Tue, 4 Oct 2022 18:22:07 -0700 Subject: [PATCH] Consider indentation for help positions --- dcargs/_argparse_formatter.py | 5 +++-- pyproject.toml | 2 +- tests/test_helptext.py | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/dcargs/_argparse_formatter.py b/dcargs/_argparse_formatter.py index ecef2537..e1a311b6 100644 --- a/dcargs/_argparse_formatter.py +++ b/dcargs/_argparse_formatter.py @@ -293,12 +293,13 @@ def _dcargs_format_root(self): def _format_action(self, action: argparse.Action): invocation = self.formatter._format_action_invocation(action) + indent = self.formatter._current_indent help_position = min( - self.formatter._action_max_length + 4, self.formatter._max_help_position + self.formatter._action_max_length + 4 + indent, + self.formatter._max_help_position, ) if self.formatter._fixed_help_position: help_position = 4 - indent = self.formatter._current_indent item_parts: List[RenderableType] = [] diff --git a/pyproject.toml b/pyproject.toml index 89a20155..1d259f78 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "dcargs" -version = "0.3.19" +version = "0.3.20" description = "Strongly typed, zero-effort CLI interfaces" authors = ["brentyi "] include = ["./dcargs/**/*"] diff --git a/tests/test_helptext.py b/tests/test_helptext.py index 2246f110..0fb6b1c9 100644 --- a/tests/test_helptext.py +++ b/tests/test_helptext.py @@ -609,7 +609,8 @@ def main2(x: Callable = nn.ReLU): helptext = _get_helptext(main2) assert "--x {fixed}" in helptext - assert "(fixed to: