summaryrefslogtreecommitdiffstats
path: root/Lib/argparse.py
diff options
context:
space:
mode:
authorRaymond Hettinger <rhettinger@users.noreply.github.com>2019-11-22 06:51:45 (GMT)
committerGitHub <noreply@github.com>2019-11-22 06:51:45 (GMT)
commitb4e5eeac267c436bb60776dc5be771d3259bd298 (patch)
tree6fb1b74341f9e3355167f53d0a6a0958ab7616fc /Lib/argparse.py
parent65444cf7fe84d8ca1f9b51c7f5992210751e08bb (diff)
downloadcpython-b4e5eeac267c436bb60776dc5be771d3259bd298.zip
cpython-b4e5eeac267c436bb60776dc5be771d3259bd298.tar.gz
cpython-b4e5eeac267c436bb60776dc5be771d3259bd298.tar.bz2
Defer import of shutil which only needed for help and usage (GH-17334)
Diffstat (limited to 'Lib/argparse.py')
-rw-r--r--Lib/argparse.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/Lib/argparse.py b/Lib/argparse.py
index 5a8eff2..5d3ce2a 100644
--- a/Lib/argparse.py
+++ b/Lib/argparse.py
@@ -87,7 +87,6 @@ __all__ = [
import os as _os
import re as _re
-import shutil as _shutil
import sys as _sys
from gettext import gettext as _, ngettext
@@ -167,7 +166,8 @@ class HelpFormatter(object):
# default setting for width
if width is None:
- width = _shutil.get_terminal_size().columns
+ import shutil
+ width = shutil.get_terminal_size().columns
width -= 2
self._prog = prog
@@ -264,7 +264,7 @@ class HelpFormatter(object):
invocations.append(get_invocation(subaction))
# update the maximum item length
- invocation_length = max([len(s) for s in invocations])
+ invocation_length = max(map(len, invocations))
action_length = invocation_length + self._current_indent
self._action_max_length = max(self._action_max_length,
action_length)