Skip to content

Commit 710f804

Browse files
committed
Get subparser formatter class from top-level parser
Set a single source of truth.
1 parent 1b110b7 commit 710f804

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

augur/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,10 @@
5252

5353
def make_parser():
5454
parser = argparse.ArgumentParser(
55-
prog = "augur",
56-
description = "Augur: A bioinformatics toolkit for phylogenetic analysis.")
55+
prog = "augur",
56+
description = "Augur: A bioinformatics toolkit for phylogenetic analysis.",
57+
formatter_class = argparse.ArgumentDefaultsHelpFormatter,
58+
)
5759

5860
add_default_command(parser)
5961
add_version_alias(parser)

augur/argparse_.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Custom helpers for the argparse standard library.
33
"""
44
import argparse
5-
from argparse import Action, ArgumentDefaultsHelpFormatter
5+
from argparse import Action
66

77

88
# Include this in an argument help string to suppress the automatic appending
@@ -58,9 +58,8 @@ def register_commands(parser: argparse.ArgumentParser, commands, command_attribu
5858
if command_attribute:
5959
subparser.set_defaults(**{command_attribute: command})
6060

61-
# Use the same formatting class for every command for consistency.
62-
# Set here to avoid repeating it in every command's register_parser().
63-
subparser.formatter_class = ArgumentDefaultsHelpFormatter
61+
# Ensure all subparsers format like the top-level parser
62+
subparser.formatter_class = parser.formatter_class
6463

6564
if not subparser.description and command.__doc__:
6665
subparser.description = command.__doc__

0 commit comments

Comments
 (0)