Skip to content

Commit

Permalink
Defer import of shutil which only needed for help and usage (pythonGH…
Browse files Browse the repository at this point in the history
  • Loading branch information
rhettinger authored Nov 22, 2019
1 parent 65444cf commit b4e5eea
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Lib/argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@

import os as _os
import re as _re
import shutil as _shutil
import sys as _sys

from gettext import gettext as _, ngettext
Expand Down Expand Up @@ -167,7 +166,8 @@ def __init__(self,

# 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
Expand Down Expand Up @@ -264,7 +264,7 @@ def add_argument(self, action):
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)
Expand Down

0 comments on commit b4e5eea

Please sign in to comment.