Skip to contentSkip to conversation

tools/lib/python: kdoc: remove unused parameters from _fill_text() and _format_usage()

PATCH Superseded Yash Rai 3 participants 3 messages May 14 Documentation

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Yash Rai

author
#0 lore raw

PATCH 1/1 tools/lib/python: kdoc: remove unused parameters from _fill_text() and _format_usage()

The parameter 'width' in _fill_text() and 'usage' and 'groups' in _format_usage() are not used in enrich_formatter.py.

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
index d1be4e5e1962..7e0f09f5ccea 100644
@@ -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, width, indent):
+    def _fill_text(self, text, indent):
         """
         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, usage, actions, groups, prefix):
+    def _format_usage(self, actions, prefix):
         """
         Enrich positional arguments at usage: line.
         """
Signature · 1 line
2.53.0
maintainer
#1 lore raw
Quoted 21 lines · Yash Rai

The parameter 'width' in _fill_text() and 'usage' and 'groups' in _format_usage() are not used in enrich_formatter.py.

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 +1 -1
index d1be4e5e1962..7e0f09f5ccea 100644
@@ -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, width, indent):
+    def _fill_text(self, text, indent):
         """

tools/lib/python/kdoc/enrich_formatter.py class EnrichFormatter(argparse.HelpFormatter): · line 55

Quoted 10 lines
tools/lib/python/kdoc/enrich_formatter.py +1 -1
         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, usage, actions, groups, prefix):
+    def _format_usage(self, actions, prefix):
         """
         Enrich positional arguments at usage: line.
         """

Looking at this patch, my immediate response is that you didn't change any callers. That is ... because there are no callers. So, rather than tweak the argument lists, is there a reason to not just delete these functions altogether?

Thanks,

jon

#2 lore raw
Quoted 28 lines · On Thu, 14 May 2026 10:13:20 -0600 Jonathan Corbet <[email protected]> wrote:
Quoted 26 lines · Yash Rai

The parameter 'width' in _fill_text() and 'usage' and 'groups' in _format_usage() are not used in enrich_formatter.py.

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 +1 -1
index d1be4e5e1962..7e0f09f5ccea 100644
@@ -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, width, indent):
+    def _fill_text(self, text, indent):
         """
         Enrich descriptions with markups on it.
         """
         enriched = self.enrich_text(text)
         return "\n".join(indent + line for line in enriched.splitlines())
 
Quoted 10 lines

tools/lib/python/kdoc/enrich_formatter.py class EnrichFormatter(argparse.HelpFormatter): · line 55

Quoted 5 lines
tools/lib/python/kdoc/enrich_formatter.py +1 -1
-    def _format_usage(self, usage, actions, groups, prefix):
+    def _format_usage(self, actions, prefix):
         """
         Enrich positional arguments at usage: line.
         """  

Looking at this patch, my immediate response is that you didn't change any callers. That is ... because there are no callers. So, rather than tweak the argument lists, is there a reason to not just delete these functions altogether?

Such functions are indirectly called by argparse.HelpFormatter. You may remove the unused arguments with either * (positional args) and/or ** (keyword arguments), to avoid python errors/warnings, but if you drop the functions, EnrichFormatter won't be doing what it is expected.

Thanks,
Mauro