Skip to content

Commit 0f38c18

Browse files
committed
Switch --no-indent to use store_const
1 parent d699070 commit 0f38c18

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Lib/json/tool.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ def main():
3030
group = parser.add_mutually_exclusive_group()
3131
group.add_argument('--indent', default=4, type=int,
3232
help='Indent level for pretty-printing.')
33-
group.add_argument('--no-indent', action='store_true', default=False,
34-
help='Use compact mode.')
33+
group.add_argument('--no-indent', action='store_const', dest='indent',
34+
const=None, help='Use compact mode.')
3535
parser.add_argument('--sort-keys', action='store_true', default=False,
3636
help='sort the output of dictionaries alphabetically by key')
3737
options = parser.parse_args()
@@ -52,7 +52,7 @@ def main():
5252
outfile = options.outfile or sys.stdout
5353
with outfile:
5454
json.dump(obj, outfile,
55-
indent=None if options.no_indent else options.indent,
55+
indent=options.indent,
5656
ensure_ascii=not options.no_ensure_ascii,
5757
sort_keys=options.sort_keys,
5858
)

0 commit comments

Comments
 (0)