Fix the --no-python flag for git cl format.

The current behavior of the --no-python flag doesn't disable formatting
for python files. Instead, it has the same effect as the --python flag.

Change-Id: I26024d3030b9c873180b488d00351676c37c9492
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1985785
Commit-Queue: Garrett Beaty <gbeaty@chromium.org>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
diff --git a/git_cl.py b/git_cl.py
index d41f483..7f87417 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -5140,12 +5140,11 @@
   parser.add_option(
       '--no-python',
       action='store_true',
-      dest='python',
+      default=False,
       help='Disables python formatting on all python files. '
-      'Takes precedence over --python. '
-      'If neither --python or --no-python are set, python '
-      'files that have a .style.yapf file in an ancestor '
-      'directory will be formatted.')
+      'If neither --python or --no-python are set, python files that have a '
+      '.style.yapf file in an ancestor directory will be formatted. '
+      'It is an error to set both.')
   parser.add_option('--js', action='store_true',
                     help='Format javascript code with clang-format.')
   parser.add_option('--diff', action='store_true',
@@ -5154,6 +5153,11 @@
                     help='Used when running the script from a presubmit.')
   opts, args = parser.parse_args(args)
 
+  if opts.python is not None and opts.no_python:
+    raise parser.error('Cannot set both --python and --no-python')
+  if opts.no_python:
+    opts.python = False
+
   # Normalize any remaining args against the current path, so paths relative to
   # the current directory are still resolved as expected.
   args = [os.path.join(os.getcwd(), arg) for arg in args]