Skip to content

Commit 974dc99

Browse files
Use un-underscored names
1 parent c29e163 commit 974dc99

2 files changed

Lines changed: 18 additions & 14 deletions

File tree

Lib/argparse.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,12 @@
9090
import sys as _sys
9191

9292
lazy import _colorize
93-
lazy import copy as _copy
94-
lazy import difflib as _difflib
93+
lazy import copy
94+
lazy import difflib
9595
lazy import re as _re
96-
lazy import shutil as _shutil
97-
lazy import textwrap as _textwrap
98-
lazy import warnings as _warnings
96+
lazy import shutil
97+
lazy import textwrap
98+
lazy import warnings
9999
lazy from gettext import gettext as _
100100
lazy from gettext import ngettext
101101

@@ -150,7 +150,7 @@ def _copy_items(items):
150150
# actions, and it is needed only when the default value isn't a list.
151151
if type(items) is list:
152152
return items[:]
153-
return _copy.copy(items)
153+
return copy.copy(items)
154154

155155

156156
def _identity(value):
@@ -189,7 +189,7 @@ def __init__(
189189
):
190190
# default setting for width
191191
if width is None:
192-
width = _shutil.get_terminal_size().columns
192+
width = shutil.get_terminal_size().columns
193193
width -= 2
194194

195195
self._prog = prog
@@ -775,11 +775,11 @@ def _iter_indented_subactions(self, action):
775775

776776
def _split_lines(self, text, width):
777777
text = self._whitespace_matcher.sub(' ', text).strip()
778-
return _textwrap.wrap(text, width)
778+
return textwrap.wrap(text, width)
779779

780780
def _fill_text(self, text, width, indent):
781781
text = self._whitespace_matcher.sub(' ', text).strip()
782-
return _textwrap.fill(text, width,
782+
return textwrap.fill(text, width,
783783
initial_indent=indent,
784784
subsequent_indent=indent)
785785

@@ -1456,7 +1456,7 @@ class FileType(object):
14561456
"""
14571457

14581458
def __init__(self, mode='r', bufsize=-1, encoding=None, errors=None):
1459-
_warnings.warn(
1459+
warnings.warn(
14601460
"FileType is deprecated. Simply open files after parsing arguments.",
14611461
category=PendingDeprecationWarning,
14621462
stacklevel=2
@@ -1866,7 +1866,7 @@ def __init__(self, container, title=None, description=None, **kwargs):
18661866
"The use of the undocumented 'prefix_chars' parameter in "
18671867
"ArgumentParser.add_argument_group() is deprecated."
18681868
)
1869-
_warnings.warn(depr_msg, DeprecationWarning, stacklevel=3)
1869+
warnings.warn(depr_msg, DeprecationWarning, stacklevel=3)
18701870

18711871
# add any missing keyword arguments by checking the container
18721872
update = kwargs.setdefault
@@ -2792,7 +2792,7 @@ def _check_value(self, action, value):
27922792

27932793
if self.suggest_on_error and isinstance(value, str):
27942794
if all(isinstance(choice, str) for choice in action.choices):
2795-
suggestions = _difflib.get_close_matches(value, action.choices, 1)
2795+
suggestions = difflib.get_close_matches(value, action.choices, 1)
27962796
if suggestions:
27972797
args['closest'] = suggestions[0]
27982798
msg = _('invalid choice: %(value)r, maybe you meant %(closest)r? '
@@ -2931,6 +2931,6 @@ def _warning(self, message):
29312931

29322932
def __getattr__(name):
29332933
if name == "__version__":
2934-
_warnings._deprecated("__version__", remove=(3, 20))
2934+
warnings._deprecated("__version__", remove=(3, 20))
29352935
return "1.1" # Do not change
29362936
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")

Lib/test/test_argparse.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import sys
1313
import textwrap
1414
import tempfile
15+
import types
1516
import unittest
1617
import argparse
1718
import warnings
@@ -7100,7 +7101,10 @@ def test_all_exports_everything_but_modules(self):
71007101
name
71017102
for name, value in vars(argparse).items()
71027103
if not (name.startswith("_") or name == 'ngettext')
7103-
if not inspect.ismodule(value)
7104+
if not (
7105+
inspect.ismodule(value)
7106+
or isinstance(value, types.LazyImportType)
7107+
)
71047108
]
71057109
self.assertEqual(sorted(items), sorted(argparse.__all__))
71067110

0 commit comments

Comments
 (0)