summaryrefslogtreecommitdiffstats
path: root/Lib/argparse.py
diff options
context:
space:
mode:
authorBurak Saler <59198732+buraksaler@users.noreply.github.com>2023-05-07 23:43:50 (GMT)
committerGitHub <noreply@github.com>2023-05-07 23:43:50 (GMT)
commit01cc9c1ff79bf18fe34c05c6cd573e79ff9487c3 (patch)
tree391297ff903f32c369ccdaa81fd04fd14c06ef8d /Lib/argparse.py
parentac020624b32820e8e6e272122b94883f8e75ac61 (diff)
downloadcpython-01cc9c1ff79bf18fe34c05c6cd573e79ff9487c3.zip
cpython-01cc9c1ff79bf18fe34c05c6cd573e79ff9487c3.tar.gz
cpython-01cc9c1ff79bf18fe34c05c6cd573e79ff9487c3.tar.bz2
gh-104273: Remove redundant len() calls in argparse function (#104274)
Diffstat (limited to 'Lib/argparse.py')
-rw-r--r--Lib/argparse.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/Lib/argparse.py b/Lib/argparse.py
index 68089a5..f5f44ff 100644
--- a/Lib/argparse.py
+++ b/Lib/argparse.py
@@ -345,21 +345,22 @@ class HelpFormatter(object):
def get_lines(parts, indent, prefix=None):
lines = []
line = []
+ indent_length = len(indent)
if prefix is not None:
line_len = len(prefix) - 1
else:
- line_len = len(indent) - 1
+ line_len = indent_length - 1
for part in parts:
if line_len + 1 + len(part) > text_width and line:
lines.append(indent + ' '.join(line))
line = []
- line_len = len(indent) - 1
+ line_len = indent_length - 1
line.append(part)
line_len += len(part) + 1
if line:
lines.append(indent + ' '.join(line))
if prefix is not None:
- lines[0] = lines[0][len(indent):]
+ lines[0] = lines[0][indent_length:]
return lines
# if prog is short, follow it with optionals or positionals