Skip to content

Commit b4e5eea

Browse files
authored
Defer import of shutil which only needed for help and usage (GH-17334)
1 parent 65444cf commit b4e5eea

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Lib/argparse.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@
8787

8888
import os as _os
8989
import re as _re
90-
import shutil as _shutil
9190
import sys as _sys
9291

9392
from gettext import gettext as _, ngettext
@@ -167,7 +166,8 @@ def __init__(self,
167166

168167
# default setting for width
169168
if width is None:
170-
width = _shutil.get_terminal_size().columns
169+
import shutil
170+
width = shutil.get_terminal_size().columns
171171
width -= 2
172172

173173
self._prog = prog
@@ -264,7 +264,7 @@ def add_argument(self, action):
264264
invocations.append(get_invocation(subaction))
265265

266266
# update the maximum item length
267-
invocation_length = max([len(s) for s in invocations])
267+
invocation_length = max(map(len, invocations))
268268
action_length = invocation_length + self._current_indent
269269
self._action_max_length = max(self._action_max_length,
270270
action_length)

0 commit comments

Comments
 (0)