tools/lib/python: kdoc: remove unused parameters from _fill_text() and _format_usage()
PATCH v2 1/1 tools/lib/python: kdoc: remove unused parameters from _fill_text() and _format_usage()
The parameters 'width' in _fill_text() and 'usage', 'groups' in _format_usage() are not used within these methods. Use *args and **kwargs to properly handle them while maintaining the override contract with argparse.HelpFormatter.
This is a cleanup with no functional change.
--- tools/lib/python/kdoc/enrich_formatter.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/lib/python/kdoc/enrich_formatter.py +2 -2
@@ -42,14 +42,14 @@ class EnrichFormatter(argparse.HelpFormatter): lambda m: f'\033[1m{m.group(1)}\033[0m', text) return text - def _fill_text(self, text, indent): + def _fill_text(self, text, indent, *args, **kwargs): """ Enrich descriptions with markups on it. """ enriched = self.enrich_text(text) return "\n".join(indent + line for line in enriched.splitlines()) - def _format_usage(self, actions, prefix): + def _format_usage(self, actions, prefix, *args, **kwargs): """ Enrich positional arguments at usage: line. """
Signature · 1 line
2.54.0
Jonathan Corbet
maintainerQuoted 21 lines · Yash Rai
The parameters 'width' in
_fill_text()and 'usage', 'groups' in_format_usage()are not used within these methods. Use *args and **kwargs to properly handle them while maintaining the override contract with argparse.HelpFormatter.This is a cleanup with no functional change.
Signed-off-by Yash Rai <[email protected]>--- tools/lib/python/kdoc/enrich_formatter.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)tools/lib/python/kdoc/enrich_formatter.py +0
-1@@ -42,14 +42,14 @@ class EnrichFormatter(argparse.HelpFormatter): lambda m: f'\033[1m{m.group(1)}\033[0m', text) return text - def _fill_text(self, text, indent):
tools/lib/python/kdoc/enrich_formatter.py class EnrichFormatter(argparse.HelpFormatter): · line 53
Quoted 10 lines
tools/lib/python/kdoc/enrich_formatter.py +2
-1+ def _fill_text(self, text, indent, *args, **kwargs): """ Enrich descriptions with markups on it. """ enriched = self.enrich_text(text) return "\n".join(indent + line for line in enriched.splitlines()) - def _format_usage(self, actions, prefix): + def _format_usage(self, actions, prefix, *args, **kwargs): """
This patch removes no parameters, and won't apply. You are, I'm guessing, applying this on top of your previous patch? Don't do that; send a completely new patch in response to review comments.
I have to say, though, that I don't really see the value in this change; you're exchanging one set of unused parameters for a different, even more mysterious set. Why do we want to do that?
Thanks,
jon
Quoted 38 lines · Jonathan Corbet
Quoted 21 lines · Yash Rai
The parameters 'width' in
_fill_text()and 'usage', 'groups' in_format_usage()are not used within these methods. Use *args and **kwargs to properly handle them while maintaining the override contract with argparse.HelpFormatter.This is a cleanup with no functional change.
Signed-off-by Yash Rai <[email protected]>--- tools/lib/python/kdoc/enrich_formatter.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)tools/lib/python/kdoc/enrich_formatter.py +0
-1@@ -42,14 +42,14 @@ class EnrichFormatter(argparse.HelpFormatter): lambda m: f'\033[1m{m.group(1)}\033[0m', text) return text - def _fill_text(self, text, indent):tools/lib/python/kdoc/enrich_formatter.py class EnrichFormatter(argparse.HelpFormatter): · line 53
Quoted 10 lines
tools/lib/python/kdoc/enrich_formatter.py +2
-1+ def _fill_text(self, text, indent, *args, **kwargs): """ Enrich descriptions with markups on it. """ enriched = self.enrich_text(text) return "\n".join(indent + line for line in enriched.splitlines()) - def _format_usage(self, actions, prefix): + def _format_usage(self, actions, prefix, *args, **kwargs): """This patch removes no parameters, and won't apply. You are, I'm guessing, applying this on top of your previous patch? Don't do that; send a completely new patch in response to review comments.
Quoted 7 lines
I have to say, though, that I don't really see the value in this change; you're exchanging one set of unused parameters for a different, even more mysterious set. Why do we want to do that?
Thanks,
jon
sorry about that and thanks for the feedback
Reason for replacing unused parameters with *args and **kwargs is to avoid python warnings
Thanks,
yash