Skip to content

Commit 01cc9c1

Browse files
authored
gh-104273: Remove redundant len() calls in argparse function (#104274)
1 parent ac02062 commit 01cc9c1

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Lib/argparse.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -345,21 +345,22 @@ def _format_usage(self, usage, actions, groups, prefix):
345345
def get_lines(parts, indent, prefix=None):
346346
lines = []
347347
line = []
348+
indent_length = len(indent)
348349
if prefix is not None:
349350
line_len = len(prefix) - 1
350351
else:
351-
line_len = len(indent) - 1
352+
line_len = indent_length - 1
352353
for part in parts:
353354
if line_len + 1 + len(part) > text_width and line:
354355
lines.append(indent + ' '.join(line))
355356
line = []
356-
line_len = len(indent) - 1
357+
line_len = indent_length - 1
357358
line.append(part)
358359
line_len += len(part) + 1
359360
if line:
360361
lines.append(indent + ' '.join(line))
361362
if prefix is not None:
362-
lines[0] = lines[0][len(indent):]
363+
lines[0] = lines[0][indent_length:]
363364
return lines
364365

365366
# if prog is short, follow it with optionals or positionals

0 commit comments

Comments
 (0)