@ -5140,12 +5140,11 @@ def CMDformat(parser, args):
parser . add_option (
parser . add_option (
' --no-python ' ,
' --no-python ' ,
action = ' store_true ' ,
action = ' store_true ' ,
de st= ' python ' ,
de fault= False ,
help = ' Disables python formatting on all python files. '
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 '
' If neither --python or --no-python are set, python '
' .style.yapf file in an ancestor directory will be formatted. '
' files that have a .style.yapf file in an ancestor '
' It is an error to set both. ' )
' directory will be formatted. ' )
parser . add_option ( ' --js ' , action = ' store_true ' ,
parser . add_option ( ' --js ' , action = ' store_true ' ,
help = ' Format javascript code with clang-format. ' )
help = ' Format javascript code with clang-format. ' )
parser . add_option ( ' --diff ' , action = ' store_true ' ,
parser . add_option ( ' --diff ' , action = ' store_true ' ,
@ -5154,6 +5153,11 @@ def CMDformat(parser, args):
help = ' Used when running the script from a presubmit. ' )
help = ' Used when running the script from a presubmit. ' )
opts , args = parser . parse_args ( args )
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
# Normalize any remaining args against the current path, so paths relative to
# the current directory are still resolved as expected.
# the current directory are still resolved as expected.
args = [ os . path . join ( os . getcwd ( ) , arg ) for arg in args ]
args = [ os . path . join ( os . getcwd ( ) , arg ) for arg in args ]