Removed parser.add_arguments() arguments that match the defaults.

This commit is contained in:
Claude Paroz 2018-07-02 23:54:57 +02:00 committed by Tim Graham
parent 4009e1f2ab
commit eac9ab7ebb
31 changed files with 87 additions and 90 deletions

View File

@ -26,7 +26,7 @@ class Command(BaseCommand):
help='Username to change password for; by default, it\'s the current username.',
)
parser.add_argument(
'--database', action='store', dest='database',
'--database',
default=DEFAULT_DB_ALIAS,
help='Specifies the database to use. Default is "default".',
)

View File

@ -30,7 +30,6 @@ class Command(BaseCommand):
def add_arguments(self, parser):
parser.add_argument(
'--%s' % self.UserModel.USERNAME_FIELD,
dest=self.UserModel.USERNAME_FIELD, default=None,
help='Specifies the login for the superuser.',
)
parser.add_argument(
@ -44,13 +43,13 @@ class Command(BaseCommand):
),
)
parser.add_argument(
'--database', action='store', dest='database',
'--database',
default=DEFAULT_DB_ALIAS,
help='Specifies the database to use. Default is "default".',
)
for field in self.UserModel.REQUIRED_FIELDS:
parser.add_argument(
'--%s' % field, dest=field, default=None,
'--%s' % field,
help='Specifies the %s for the superuser.' % field,
)

View File

@ -15,7 +15,7 @@ class Command(BaseCommand):
help='Tells Django to NOT prompt the user for input of any kind.',
)
parser.add_argument(
'--database', action='store', dest='database', default=DEFAULT_DB_ALIAS,
'--database', default=DEFAULT_DB_ALIAS,
help='Nominates the database to use. Defaults to the "default" database.',
)

View File

@ -43,21 +43,21 @@ class Command(BaseCommand):
parser.add_argument('data_source', help='Path to the data source.')
parser.add_argument('model_name', help='Name of the model to create.')
parser.add_argument(
'--blank', dest='blank',
'--blank',
action=ListOptionAction, default=False,
help='Use a comma separated list of OGR field names to add '
'the `blank=True` option to the field definition. Set to `true` '
'to apply to all applicable fields.',
)
parser.add_argument(
'--decimal', dest='decimal',
'--decimal',
action=ListOptionAction, default=False,
help='Use a comma separated list of OGR float fields to '
'generate `DecimalField` instead of the default '
'`FloatField`. Set to `true` to apply to all OGR float fields.',
)
parser.add_argument(
'--geom-name', dest='geom_name', default='geom',
'--geom-name', default='geom',
help='Specifies the model name for the Geometry Field (defaults to `geom`)'
)
parser.add_argument(
@ -68,11 +68,11 @@ class Command(BaseCommand):
'an integer or a string identifier for the layer.',
)
parser.add_argument(
'--multi-geom', action='store_true', dest='multi_geom',
'--multi-geom', action='store_true',
help='Treat the geometry in the data source as a geometry collection.',
)
parser.add_argument(
'--name-field', dest='name_field',
'--name-field',
help='Specifies a field name to return for the __str__() method.',
)
parser.add_argument(
@ -80,18 +80,18 @@ class Command(BaseCommand):
help='Do not include `from django.contrib.gis.db import models` statement.',
)
parser.add_argument(
'--null', dest='null', action=ListOptionAction, default=False,
'--null', action=ListOptionAction, default=False,
help='Use a comma separated list of OGR field names to add '
'the `null=True` option to the field definition. Set to `true` '
'to apply to all applicable fields.',
)
parser.add_argument(
'--srid', dest='srid',
'--srid',
help='The SRID to use for the Geometry Field. If it can be '
'determined, the SRID of the data source is used.',
)
parser.add_argument(
'--mapping', action='store_true', dest='mapping',
'--mapping', action='store_true',
help='Generate mapping dictionary for use with `LayerMapping`.',
)

View File

@ -6,7 +6,7 @@ class Command(BaseCommand):
help = "Ping Google with an updated sitemap, pass optional url of sitemap"
def add_arguments(self, parser):
parser.add_argument('sitemap_url', nargs='?', default=None)
parser.add_argument('sitemap_url', nargs='?')
def handle(self, *args, **options):
ping_google(sitemap_url=options['sitemap_url'])

View File

@ -51,16 +51,16 @@ class Command(BaseCommand):
"pattern. Use multiple times to ignore more.",
)
parser.add_argument(
'-n', '--dry-run', action='store_true', dest='dry_run',
'-n', '--dry-run', action='store_true',
help="Do everything except modify the filesystem.",
)
parser.add_argument(
'-c', '--clear', action='store_true', dest='clear',
'-c', '--clear', action='store_true',
help="Clear the existing files using the storage "
"before trying to copy or link the original file.",
)
parser.add_argument(
'-l', '--link', action='store_true', dest='link',
'-l', '--link', action='store_true',
help="Create a symbolic link to each file instead of copying.",
)
parser.add_argument(

View File

@ -259,7 +259,7 @@ class BaseCommand:
)
parser.add_argument('--version', action='version', version=self.get_version())
parser.add_argument(
'-v', '--verbosity', action='store', dest='verbosity', default=1,
'-v', '--verbosity', default=1,
type=int, choices=[0, 1, 2, 3],
help='Verbosity level; 0=minimal output, 1=normal output, 2=verbose output, 3=very verbose output',
)
@ -277,7 +277,7 @@ class BaseCommand:
)
parser.add_argument('--traceback', action='store_true', help='Raise on CommandError exceptions')
parser.add_argument(
'--no-color', action='store_true', dest='no_color',
'--no-color', action='store_true',
help="Don't colorize the command output.",
)
self.add_arguments(parser)

View File

@ -16,18 +16,17 @@ class Command(BaseCommand):
help='Run only checks labeled with given tag.',
)
parser.add_argument(
'--list-tags', action='store_true', dest='list_tags',
'--list-tags', action='store_true',
help='List available tags.',
)
parser.add_argument(
'--deploy', action='store_true', dest='deploy',
'--deploy', action='store_true',
help='Check deployment settings.',
)
parser.add_argument(
'--fail-level',
default='ERROR',
choices=['CRITICAL', 'ERROR', 'WARNING', 'INFO', 'DEBUG'],
dest='fail_level',
help=(
'Message level that will cause the command to exit with a '
'non-zero status. Default is ERROR.'

View File

@ -34,12 +34,12 @@ class Command(BaseCommand):
def add_arguments(self, parser):
parser.add_argument(
'--locale', '-l', dest='locale', action='append', default=[],
'--locale', '-l', action='append', default=[],
help='Locale(s) to process (e.g. de_AT). Default is to process all. '
'Can be used multiple times.',
)
parser.add_argument(
'--exclude', '-x', dest='exclude', action='append', default=[],
'--exclude', '-x', action='append', default=[],
help='Locales to exclude. Default is none. Can be used multiple times.',
)
parser.add_argument(

View File

@ -19,13 +19,13 @@ class Command(BaseCommand):
help='Optional table names. Otherwise, settings.CACHES is used to find cache tables.',
)
parser.add_argument(
'--database', action='store', dest='database',
'--database',
default=DEFAULT_DB_ALIAS,
help='Nominates a database onto which the cache tables will be '
'installed. Defaults to the "default" database.',
)
parser.add_argument(
'--dry-run', action='store_true', dest='dry_run',
'--dry-run', action='store_true',
help='Does not create the table, just prints the SQL that would be run.',
)

View File

@ -12,7 +12,7 @@ class Command(BaseCommand):
def add_arguments(self, parser):
parser.add_argument(
'--database', action='store', dest='database', default=DEFAULT_DB_ALIAS,
'--database', default=DEFAULT_DB_ALIAS,
help='Nominates a database onto which to open a shell. Defaults to the "default" database.',
)

View File

@ -14,21 +14,21 @@ class Command(BaseCommand):
def add_arguments(self, parser):
parser.add_argument(
'--all', action='store_true', dest='all',
'--all', action='store_true',
help=(
'Display all settings, regardless of their value. In "hash" '
'mode, default values are prefixed by "###".'
),
)
parser.add_argument(
'--default', dest='default', metavar='MODULE', default=None,
'--default', metavar='MODULE',
help=(
"The settings module to compare the current settings against. Leave empty to "
"compare against Django's default settings."
),
)
parser.add_argument(
'--output', default='hash', choices=('hash', 'unified'), dest='output',
'--output', default='hash', choices=('hash', 'unified'),
help=(
"Selects the output format. 'hash' mode displays each changed "
"setting, with the settings that don't appear in the defaults "

View File

@ -24,21 +24,21 @@ class Command(BaseCommand):
help='Restricts dumped data to the specified app_label or app_label.ModelName.',
)
parser.add_argument(
'--format', default='json', dest='format',
'--format', default='json',
help='Specifies the output serialization format for fixtures.',
)
parser.add_argument(
'--indent', default=None, dest='indent', type=int,
'--indent', type=int,
help='Specifies the indent level to use when pretty-printing output.',
)
parser.add_argument(
'--database', action='store', dest='database',
'--database',
default=DEFAULT_DB_ALIAS,
help='Nominates a specific database to dump fixtures from. '
'Defaults to the "default" database.',
)
parser.add_argument(
'-e', '--exclude', dest='exclude', action='append', default=[],
'-e', '--exclude', action='append', default=[],
help='An app_label or app_label.ModelName to exclude '
'(use multiple --exclude to exclude multiple apps/models).',
)
@ -61,7 +61,7 @@ class Command(BaseCommand):
"list of keys. This option only works when you specify one model.",
)
parser.add_argument(
'-o', '--output', default=None, dest='output',
'-o', '--output',
help='Specifies file to which the output is written.'
)

View File

@ -20,7 +20,7 @@ class Command(BaseCommand):
help='Tells Django to NOT prompt the user for input of any kind.',
)
parser.add_argument(
'--database', action='store', dest='database', default=DEFAULT_DB_ALIAS,
'--database', default=DEFAULT_DB_ALIAS,
help='Nominates a database to flush. Defaults to the "default" database.',
)

View File

@ -15,11 +15,11 @@ class Command(BaseCommand):
def add_arguments(self, parser):
parser.add_argument(
'table', action='store', nargs='*', type=str,
'table', nargs='*', type=str,
help='Selects what tables or views should be introspected.',
)
parser.add_argument(
'--database', action='store', dest='database', default=DEFAULT_DB_ALIAS,
'--database', default=DEFAULT_DB_ALIAS,
help='Nominates a database to introspect. Defaults to using the "default" database.',
)
parser.add_argument(

View File

@ -39,11 +39,11 @@ class Command(BaseCommand):
def add_arguments(self, parser):
parser.add_argument('args', metavar='fixture', nargs='+', help='Fixture labels.')
parser.add_argument(
'--database', action='store', dest='database', default=DEFAULT_DB_ALIAS,
'--database', default=DEFAULT_DB_ALIAS,
help='Nominates a specific database to load fixtures into. Defaults to the "default" database.',
)
parser.add_argument(
'--app', action='store', dest='app_label', default=None,
'--app', dest='app_label',
help='Only look for fixtures in the specified app.',
)
parser.add_argument(
@ -52,11 +52,11 @@ class Command(BaseCommand):
'currently exist on the model.',
)
parser.add_argument(
'-e', '--exclude', dest='exclude', action='append', default=[],
'-e', '--exclude', action='append', default=[],
help='An app_label or app_label.ModelName to exclude. Can be used multiple times.',
)
parser.add_argument(
'--format', action='store', dest='format', default=None,
'--format',
help='Format of serialized data when reading from stdin.',
)

View File

@ -216,20 +216,20 @@ class Command(BaseCommand):
def add_arguments(self, parser):
parser.add_argument(
'--locale', '-l', default=[], dest='locale', action='append',
'--locale', '-l', default=[], action='append',
help='Creates or updates the message files for the given locale(s) (e.g. pt_BR). '
'Can be used multiple times.',
)
parser.add_argument(
'--exclude', '-x', default=[], dest='exclude', action='append',
'--exclude', '-x', default=[], action='append',
help='Locales to exclude. Default is none. Can be used multiple times.',
)
parser.add_argument(
'--domain', '-d', default='django', dest='domain',
'--domain', '-d', default='django',
help='The domain of the message files (default: "django").',
)
parser.add_argument(
'--all', '-a', action='store_true', dest='all',
'--all', '-a', action='store_true',
help='Updates the message files for all existing locales.',
)
parser.add_argument(
@ -239,7 +239,7 @@ class Command(BaseCommand):
'commas, or use -e multiple times.',
)
parser.add_argument(
'--symlinks', '-s', action='store_true', dest='symlinks',
'--symlinks', '-s', action='store_true',
help='Follows symlinks to directories when examining source code '
'and templates for translation strings.',
)
@ -254,15 +254,15 @@ class Command(BaseCommand):
help="Don't ignore the common glob-style patterns 'CVS', '.*', '*~' and '*.pyc'.",
)
parser.add_argument(
'--no-wrap', action='store_true', dest='no_wrap',
'--no-wrap', action='store_true',
help="Don't break long message lines into several lines.",
)
parser.add_argument(
'--no-location', action='store_true', dest='no_location',
'--no-location', action='store_true',
help="Don't write '#: filename:line' lines.",
)
parser.add_argument(
'--add-location', dest='add_location',
'--add-location',
choices=('full', 'file', 'never'), const='full', nargs='?',
help=(
"Controls '#: filename:line' lines. If the option is 'full' "
@ -273,11 +273,11 @@ class Command(BaseCommand):
),
)
parser.add_argument(
'--no-obsolete', action='store_true', dest='no_obsolete',
'--no-obsolete', action='store_true',
help="Remove obsolete message strings.",
)
parser.add_argument(
'--keep-pot', action='store_true', dest='keep_pot',
'--keep-pot', action='store_true',
help="Keep .pot file after making messages. Useful when debugging.",
)

View File

@ -29,15 +29,15 @@ class Command(BaseCommand):
help='Specify the app label(s) to create migrations for.',
)
parser.add_argument(
'--dry-run', action='store_true', dest='dry_run',
'--dry-run', action='store_true',
help="Just show what migrations would be made; don't actually write them.",
)
parser.add_argument(
'--merge', action='store_true', dest='merge',
'--merge', action='store_true',
help="Enable fixing of migration conflicts.",
)
parser.add_argument(
'--empty', action='store_true', dest='empty',
'--empty', action='store_true',
help="Create an empty migration.",
)
parser.add_argument(
@ -45,7 +45,7 @@ class Command(BaseCommand):
help='Tells Django to NOT prompt the user for input of any kind.',
)
parser.add_argument(
'-n', '--name', action='store', dest='name', default=None,
'-n', '--name',
help="Use this name for migration file(s).",
)
parser.add_argument(

View File

@ -36,22 +36,22 @@ class Command(BaseCommand):
help='Tells Django to NOT prompt the user for input of any kind.',
)
parser.add_argument(
'--database', action='store', dest='database',
'--database',
default=DEFAULT_DB_ALIAS,
help='Nominates a database to synchronize. Defaults to the "default" database.',
)
parser.add_argument(
'--fake', action='store_true', dest='fake',
'--fake', action='store_true',
help='Mark migrations as run without actually running them.',
)
parser.add_argument(
'--fake-initial', action='store_true', dest='fake_initial',
'--fake-initial', action='store_true',
help='Detect if tables already exist and fake-apply initial migrations if so. Make sure '
'that the current database schema matches your initial migration before using this '
'flag. Django will only check for an existing table name.',
)
parser.add_argument(
'--run-syncdb', action='store_true', dest='run_syncdb',
'--run-syncdb', action='store_true',
help='Creates tables for apps without migrations.',
)

View File

@ -15,11 +15,11 @@ class Command(BaseCommand):
help='One or more email addresses to send a test email to.',
)
parser.add_argument(
'--managers', action='store_true', dest='managers',
'--managers', action='store_true',
help='Send a test email to the addresses specified in settings.MANAGERS.',
)
parser.add_argument(
'--admins', action='store_true', dest='admins',
'--admins', action='store_true',
help='Send a test email to the addresses specified in settings.ADMINS.',
)

View File

@ -19,15 +19,15 @@ class Command(BaseCommand):
def add_arguments(self, parser):
parser.add_argument(
'--no-startup', action='store_true', dest='no_startup',
'--no-startup', action='store_true',
help='When using plain Python, ignore the PYTHONSTARTUP environment variable and ~/.pythonrc.py script.',
)
parser.add_argument(
'-i', '--interface', choices=self.shells, dest='interface',
'-i', '--interface', choices=self.shells,
help='Specify an interactive interpreter interface. Available options: "ipython", "bpython", and "python"',
)
parser.add_argument(
'-c', '--command', dest='command',
'-c', '--command',
help='Instead of opening an interactive shell, run a command as Django and exit.',
)

View File

@ -12,7 +12,7 @@ class Command(BaseCommand):
help='App labels of applications to limit the output to.',
)
parser.add_argument(
'--database', action='store', dest='database', default=DEFAULT_DB_ALIAS,
'--database', default=DEFAULT_DB_ALIAS,
help='Nominates a database to synchronize. Defaults to the "default" database.',
)

View File

@ -18,7 +18,7 @@ class Command(BaseCommand):
help='Nominates a database to create SQL for. Defaults to the "default" database.',
)
parser.add_argument(
'--backwards', action='store_true', dest='backwards',
'--backwards', action='store_true',
help='Creates SQL to unapply the migration, rather than to apply it',
)

View File

@ -18,7 +18,7 @@ class Command(BaseCommand):
help='App label of the application to squash migrations for.',
)
parser.add_argument(
'start_migration_name', default=None, nargs='?',
'start_migration_name', nargs='?',
help='Migrations will be squashed starting from and including this migration.',
)
parser.add_argument(
@ -26,7 +26,7 @@ class Command(BaseCommand):
help='Migrations will be squashed until and including this migration.',
)
parser.add_argument(
'--no-optimize', action='store_true', dest='no_optimize',
'--no-optimize', action='store_true',
help='Do not try to optimize the squashed operations.',
)
parser.add_argument(
@ -34,7 +34,7 @@ class Command(BaseCommand):
help='Tells Django to NOT prompt the user for input of any kind.',
)
parser.add_argument(
'--squashed-name', dest='squashed_name',
'--squashed-name',
help='Sets the name of the new squashed migration.',
)

View File

@ -35,11 +35,11 @@ class Command(BaseCommand):
help='Tells Django to NOT prompt the user for input of any kind.',
)
parser.add_argument(
'--failfast', action='store_true', dest='failfast',
'--failfast', action='store_true',
help='Tells Django to stop running the test suite after first failed test.',
)
parser.add_argument(
'--testrunner', action='store', dest='testrunner',
'--testrunner',
help='Tells Django to use specified test runner class instead of '
'the one specified by the TEST_RUNNER setting.',
)

View File

@ -422,31 +422,31 @@ class DiscoverRunner:
@classmethod
def add_arguments(cls, parser):
parser.add_argument(
'-t', '--top-level-directory', action='store', dest='top_level', default=None,
'-t', '--top-level-directory', dest='top_level',
help='Top level of project for unittest discovery.',
)
parser.add_argument(
'-p', '--pattern', action='store', dest='pattern', default="test*.py",
'-p', '--pattern', default="test*.py",
help='The test matching pattern. Defaults to test*.py.',
)
parser.add_argument(
'-k', '--keepdb', action='store_true', dest='keepdb',
'-k', '--keepdb', action='store_true',
help='Preserves the test DB between runs.'
)
parser.add_argument(
'-r', '--reverse', action='store_true', dest='reverse',
'-r', '--reverse', action='store_true',
help='Reverses test cases order.',
)
parser.add_argument(
'--debug-mode', action='store_true', dest='debug_mode',
'--debug-mode', action='store_true',
help='Sets settings.DEBUG to True.',
)
parser.add_argument(
'-d', '--debug-sql', action='store_true', dest='debug_sql',
'-d', '--debug-sql', action='store_true',
help='Prints logged SQL queries on failure.',
)
parser.add_argument(
'--parallel', dest='parallel', nargs='?', default=1, type=int,
'--parallel', nargs='?', default=1, type=int,
const=default_test_processes(), metavar='N',
help='Run tests using up to N parallel processes.',
)

View File

@ -103,7 +103,6 @@ options can be added in the :meth:`~BaseCommand.add_arguments` method like this:
parser.add_argument(
'--delete',
action='store_true',
dest='delete',
help='Delete poll instead of closing it',
)

View File

@ -3,7 +3,7 @@ from django.core.management.base import BaseCommand
class Command(BaseCommand):
def add_arguments(self, parser):
parser.add_argument("--list", action="store_true", dest="list", help="Print all options")
parser.add_argument("--list", action="store_true", help="Print all options")
def handle(self, *args, **options):
pass

View File

@ -405,11 +405,11 @@ if __name__ == "__main__":
help='Tells Django to NOT prompt the user for input of any kind.',
)
parser.add_argument(
'--failfast', action='store_true', dest='failfast',
'--failfast', action='store_true',
help='Tells Django to stop running the test suite after first failed test.',
)
parser.add_argument(
'-k', '--keepdb', action='store_true', dest='keepdb',
'-k', '--keepdb', action='store_true',
help='Tells Django to preserve the test database between runs.',
)
parser.add_argument(
@ -433,15 +433,15 @@ if __name__ == "__main__":
'test side effects not apparent with normal execution lineup.',
)
parser.add_argument(
'--selenium', dest='selenium', action=ActionSelenium, metavar='BROWSERS',
'--selenium', action=ActionSelenium, metavar='BROWSERS',
help='A comma-separated list of browsers to run the Selenium tests against.',
)
parser.add_argument(
'--debug-sql', action='store_true', dest='debug_sql',
'--debug-sql', action='store_true',
help='Turn on the SQL query logger within tests.',
)
parser.add_argument(
'--parallel', dest='parallel', nargs='?', default=0, type=int,
'--parallel', nargs='?', default=0, type=int,
const=default_test_processes(), metavar='N',
help='Run tests using up to N parallel processes.',
)

View File

@ -12,9 +12,9 @@ class CustomOptionsTestRunner(DiscoverRunner):
@classmethod
def add_arguments(cls, parser):
parser.add_argument('--option_a', '-a', action='store', dest='option_a', default='1'),
parser.add_argument('--option_b', '-b', action='store', dest='option_b', default='2'),
parser.add_argument('--option_c', '-c', action='store', dest='option_c', default='3'),
parser.add_argument('--option_a', '-a', default='1'),
parser.add_argument('--option_b', '-b', default='2'),
parser.add_argument('--option_c', '-c', default='3'),
def run_tests(self, test_labels, extra_tests=None, **kwargs):
print("%s:%s:%s" % (self.option_a, self.option_b, self.option_c))

View File

@ -6,7 +6,7 @@ class Command(BaseCommand):
def add_arguments(self, parser):
parser.add_argument('args', metavar='app_label', nargs='*', help='Specify the app label(s) to works on.')
parser.add_argument('--empty', action='store_true', dest='empty', help="Do nothing.")
parser.add_argument('--empty', action='store_true', help="Do nothing.")
def handle(self, *app_labels, **options):
app_labels = set(app_labels)