Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

python: Elide default=None for argparse arguments.

Anders Kaseorg1f2ac1962fab
diff --git a/puppet/zulip/files/nagios_plugins/zulip_app_frontend/check_send_receive_time b/puppet/zulip/files/nagios_plugins/zulip_app_frontend/check_send_receive_time
index 7dc69da9dcd..6cdb6a4455a 100755
--- a/puppet/zulip/files/nagios_plugins/zulip_app_frontend/check_send_receive_time
+++ b/puppet/zulip/files/nagios_plugins/zulip_app_frontend/check_send_receive_time
@@ -45,7 +45,7 @@ parser.add_argument('--insecure',
parser.add_argument('--munin',
action='store_true')
-parser.add_argument('config', nargs='?', default=None)
+parser.add_argument('config', nargs='?')
options = parser.parse_args()
diff --git a/scripts/lib/queue_workers.py b/scripts/lib/queue_workers.py
index 0f57253ec8c..fe90f2f7cd4 100755
--- a/scripts/lib/queue_workers.py
+++ b/scripts/lib/queue_workers.py
@@ -18,7 +18,7 @@ from zerver.worker.queue_processors import get_active_worker_queues
if __name__ == "__main__":
parser = argparse.ArgumentParser()
- parser.add_argument('--queue-type', action='store', default=None,
+ parser.add_argument('--queue-type', action='store',
help="Specify which types of queues to list")
args = parser.parse_args()
diff --git a/tools/run-dev.py b/tools/run-dev.py
index 4752d2c5599..8c4101bb0d7 100755
--- a/tools/run-dev.py
+++ b/tools/run-dev.py
@@ -49,7 +49,7 @@ parser.add_argument('--minify',
help='Minifies assets for testing in dev')
parser.add_argument('--interface',
action='store',
- default=None, help='Set the IP or hostname for the proxy to listen on')
+ help='Set the IP or hostname for the proxy to listen on')
parser.add_argument('--no-clear-memcached',
action='store_false', dest='clear_memcached',
help='Do not clear memcached')
diff --git a/zerver/management/commands/backup.py b/zerver/management/commands/backup.py
index 9a76c7935e5..18a259d48c9 100644
--- a/zerver/management/commands/backup.py
+++ b/zerver/management/commands/backup.py
@@ -22,7 +22,7 @@ class Command(ZulipBaseCommand):
return parser
def add_arguments(self, parser: ArgumentParser) -> None:
- parser.add_argument("--output", default=None, help="Filename of output tarball")
+ parser.add_argument("--output", help="Filename of output tarball")
parser.add_argument("--skip-db", action='store_true', help="Skip database backup")
parser.add_argument("--skip-uploads", action='store_true', help="Skip uploads backup")
diff --git a/zerver/management/commands/convert_gitter_data.py b/zerver/management/commands/convert_gitter_data.py
index f2384adbef9..16239b716bf 100644
--- a/zerver/management/commands/convert_gitter_data.py
+++ b/zerver/management/commands/convert_gitter_data.py
@@ -18,7 +18,7 @@ class Command(BaseCommand):
help="Gitter data in json format")
parser.add_argument('--output', dest='output_dir',
- action="store", default=None,
+ action="store",
help='Directory to write exported data to.')
parser.add_argument('--threads',
diff --git a/zerver/management/commands/convert_slack_data.py b/zerver/management/commands/convert_slack_data.py
index 0bea8e30e40..79b4f016338 100644
--- a/zerver/management/commands/convert_slack_data.py
+++ b/zerver/management/commands/convert_slack_data.py
@@ -21,7 +21,7 @@ class Command(BaseCommand):
type=str, help='Slack legacy token of the organsation')
parser.add_argument('--output', dest='output_dir',
- action="store", default=None,
+ action="store",
help='Directory to write exported data to.')
parser.add_argument('--threads',
diff --git a/zerver/management/commands/export.py b/zerver/management/commands/export.py
index c8cbb2e2ae1..15231d1457a 100644
--- a/zerver/management/commands/export.py
+++ b/zerver/management/commands/export.py
@@ -80,7 +80,6 @@ class Command(ZulipBaseCommand):
parser.add_argument('--output',
dest='output_dir',
action="store",
- default=None,
help='Directory to write exported data to.')
parser.add_argument('--threads',
action="store",
@@ -94,7 +93,6 @@ class Command(ZulipBaseCommand):
help='Deactivate the realm immediately before exporting')
parser.add_argument('--consent-message-id',
action="store",
- default=None,
type=int,
help='ID of the message advertising users to react with thumbs up')
parser.add_argument('--upload',
diff --git a/zerver/management/commands/export_single_user.py b/zerver/management/commands/export_single_user.py
index fbef9983f7a..f786db52ae3 100644
--- a/zerver/management/commands/export_single_user.py
+++ b/zerver/management/commands/export_single_user.py
@@ -24,7 +24,6 @@ class Command(ZulipBaseCommand):
parser.add_argument('--output',
dest='output_dir',
action="store",
- default=None,
help='Directory to write exported data to.')
self.add_realm_args(parser)
diff --git a/zerver/management/commands/export_usermessage_batch.py b/zerver/management/commands/export_usermessage_batch.py
index 621d5caeaca..900897c4363 100644
--- a/zerver/management/commands/export_usermessage_batch.py
+++ b/zerver/management/commands/export_usermessage_batch.py
@@ -16,15 +16,12 @@ class Command(BaseCommand):
def add_arguments(self, parser: ArgumentParser) -> None:
parser.add_argument('--path',
action="store",
- default=None,
help='Path to find messages.json archives')
parser.add_argument('--thread',
action="store",
- default=None,
help='Thread ID')
parser.add_argument('--consent-message-id',
action="store",
- default=None,
type=int,
help='ID of the message advertising users to react with thumbs up')
diff --git a/zerver/management/commands/fill_memcached_caches.py b/zerver/management/commands/fill_memcached_caches.py
index ad084e95911..685ed305696 100644
--- a/zerver/management/commands/fill_memcached_caches.py
+++ b/zerver/management/commands/fill_memcached_caches.py
@@ -8,7 +8,7 @@ from zerver.lib.cache_helpers import cache_fillers, fill_remote_cache
class Command(BaseCommand):
def add_arguments(self, parser: ArgumentParser) -> None:
- parser.add_argument('--cache', default=None,
+ parser.add_argument('--cache',
help="Populate the memcached cache of messages.")
def handle(self, *args: Any, **options: Optional[str]) -> None:
diff --git a/zerver/management/commands/purge_queue.py b/zerver/management/commands/purge_queue.py
index 77388ed4352..1491535f15e 100644
--- a/zerver/management/commands/purge_queue.py
+++ b/zerver/management/commands/purge_queue.py
@@ -11,7 +11,7 @@ from zerver.worker.queue_processors import get_active_worker_queues
class Command(BaseCommand):
def add_arguments(self, parser: ArgumentParser) -> None:
parser.add_argument(dest="queue_name", type=str, nargs='?',
- help="queue to purge", default=None)
+ help="queue to purge")
parser.add_argument('--all', action="store_true",
help="purge all queues")
diff --git a/zerver/management/commands/realm_filters.py b/zerver/management/commands/realm_filters.py
index 9bd14e834fb..6d2774adbea 100644
--- a/zerver/management/commands/realm_filters.py
+++ b/zerver/management/commands/realm_filters.py
@@ -27,7 +27,7 @@ Example: ./manage.py realm_filters --realm=zulip --op=show
type=str,
default="show",
help='What operation to do (add, show, remove).')
- parser.add_argument('pattern', metavar='<pattern>', type=str, nargs='?', default=None,
+ parser.add_argument('pattern', metavar='<pattern>', type=str, nargs='?',
help="regular expression to match")
parser.add_argument('url_format_string', metavar='<url pattern>', type=str, nargs='?',
help="format string to substitute")
diff --git a/zilencer/management/commands/populate_db.py b/zilencer/management/commands/populate_db.py
index 4e1de6dfcc0..bdf551468ed 100644
--- a/zilencer/management/commands/populate_db.py
+++ b/zilencer/management/commands/populate_db.py
@@ -186,7 +186,6 @@ class Command(BaseCommand):
parser.add_argument('--max-topics',
type=int,
- default=None,
help='The number of maximum topics to create')
parser.add_argument('--huddles',