Skip to content
Prev Previous commit
Next Next commit
revert accidental automatic PEP8 changes
  • Loading branch information
Franklin, Samuel Franklin, Samuel
Franklin, Samuel authored and Franklin, Samuel committed Aug 21, 2019
commit 41e22bfb726d47677fa7d06dd4cc4ef9c5605831
36 changes: 14 additions & 22 deletions Lib/argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@
# Utility functions and classes
# =============================


class _AttributeHolder(object):
"""Abstract base class that provides __repr__.

Expand Down Expand Up @@ -141,7 +140,7 @@ def _copy_items(items):
# The copy module is used only in the 'append' and 'append_const'
# actions, and it is needed only when the default value isn't a list.
# Delay its import for speeding up the common case.
if isinstance(items, list):
if type(items) is list:
return items[:]
import copy
return copy.copy(items)
Expand Down Expand Up @@ -659,8 +658,7 @@ class RawDescriptionHelpFormatter(HelpFormatter):
"""

def _fill_text(self, text, width, indent):
return ''.join(
indent + line for line in text.splitlines(keepends=True))
return ''.join(indent + line for line in text.splitlines(keepends=True))


class RawTextHelpFormatter(RawDescriptionHelpFormatter):
Expand Down Expand Up @@ -706,6 +704,7 @@ def _get_default_metavar_for_positional(self, action):
return action.type.__name__



# =====================
# Options and Arguments
# =====================
Expand All @@ -714,7 +713,7 @@ def _get_action_name(argument):
if argument is None:
return None
elif argument.option_strings:
return '/'.join(argument.option_strings)
return '/'.join(argument.option_strings)
elif argument.metavar not in (None, SUPPRESS):
return argument.metavar
elif argument.dest not in (None, SUPPRESS):
Expand Down Expand Up @@ -1161,7 +1160,6 @@ def __call__(self, parser, namespace, values, option_string=None):
vars(namespace).setdefault(_UNRECOGNIZED_ARGS_ATTR, [])
getattr(namespace, _UNRECOGNIZED_ARGS_ATTR).extend(arg_strings)


class _ExtendAction(_AppendAction):
def __call__(self, parser, namespace, values, option_string=None):
items = getattr(namespace, self.dest, None)
Expand All @@ -1173,7 +1171,6 @@ def __call__(self, parser, namespace, values, option_string=None):
# Type classes
# ==============


class FileType(object):
"""Factory for creating file object types

Expand Down Expand Up @@ -1228,7 +1225,6 @@ def __repr__(self):
# Optional and Positional Parsing
# ===========================


class Namespace(_AttributeHolder):
"""Simple object for storing attributes.

Expand Down Expand Up @@ -1329,10 +1325,10 @@ def get_default(self, dest):
return action.default
return self._defaults.get(dest, None)


# =======================
# Adding argument actions
# =======================

def add_argument(self, *args, **kwargs):
"""
add_argument(dest, ..., name=value, ...)
Expand Down Expand Up @@ -1380,8 +1376,7 @@ def add_argument(self, *args, **kwargs):
try:
self._get_formatter()._format_args(action, None)
except TypeError:
raise ValueError(
"length of metavar tuple does not match nargs")
raise ValueError("length of metavar tuple does not match nargs")

return self._add_action(action)

Expand Down Expand Up @@ -1490,8 +1485,7 @@ def _get_optional_kwargs(self, *args, **kwargs):

# strings starting with two prefix characters are long options
option_strings.append(option_string)
if len(
option_string) > 1 and option_string[1] in self.prefix_chars:
if len(option_string) > 1 and option_string[1] in self.prefix_chars:
long_option_strings.append(option_string)

# infer destination, '--foo-bar' -> 'foo_bar' and '-x' -> 'x'
Expand Down Expand Up @@ -1681,7 +1675,7 @@ def identity(string):
default_prefix = '-' if '-' in prefix_chars else prefix_chars[0]
if self.add_help:
self.add_argument(
default_prefix + 'h', default_prefix * 2 + 'help',
default_prefix+'h', default_prefix*2+'help',
action='help', default=SUPPRESS,
help=_('show this help message and exit'))

Expand Down Expand Up @@ -2025,7 +2019,7 @@ def consume_positionals(start_index):
if (action.default is not None and
isinstance(action.default, str) and
hasattr(namespace, action.dest) and
action.default is getattr(namespace, action.dest)):
action.default is getattr(namespace, action.dest)):
setattr(namespace, action.dest,
self._get_value(action, action.default))

Expand Down Expand Up @@ -2150,7 +2144,7 @@ def _parse_optional(self, arg_string):
# if multiple actions match, the option string was ambiguous
if len(option_tuples) > 1:
options = ', '.join([option_string
for action, option_string, explicit_arg in option_tuples])
for action, option_string, explicit_arg in option_tuples])
args = {'option': arg_string, 'matches': options}
msg = _('ambiguous option: %(option)s could match %(matches)s')
self.error(msg % args)
Expand Down Expand Up @@ -2294,10 +2288,10 @@ def parse_known_intermixed_args(self, args=None, namespace=None):
if action.nargs in [PARSER, REMAINDER]]
if a:
raise TypeError('parse_intermixed_args: positional arg'
' with nargs=%s' % a[0].nargs)
' with nargs=%s'%a[0].nargs)

if [action.dest for group in self._mutually_exclusive_groups
for action in group._group_actions if action in positionals]:
for action in group._group_actions if action in positionals]:
raise TypeError('parse_intermixed_args: positional in'
' mutuallyExclusiveGroup')

Expand All @@ -2319,11 +2313,9 @@ def parse_known_intermixed_args(self, args=None, namespace=None):
for action in positionals:
# remove the empty positional values from namespace
if (hasattr(namespace, action.dest)
and getattr(namespace, action.dest) == []):
and getattr(namespace, action.dest)==[]):
from warnings import warn
warn(
'Do not expect %s in %s' %
(action.dest, namespace))
warn('Do not expect %s in %s' % (action.dest, namespace))
delattr(namespace, action.dest)
finally:
# restore nargs and usage before exiting
Expand Down