mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-12 23:54:17 +00:00
Revert silliness around setting choices for --format
If we restrict the user's ability to specify a format string, we break existing workflows.
This commit is contained in:
parent
472e7c9589
commit
18d6e6264c
3 changed files with 10 additions and 13 deletions
|
|
@ -11,8 +11,8 @@ passed by the user as early as possible so as much logging can be produced as
|
||||||
possible.
|
possible.
|
||||||
|
|
||||||
The default flake8 options are registered by
|
The default flake8 options are registered by
|
||||||
:func:`~flake8.main.cli.register_default_options`. Trying to register these
|
:func:`~flake8.main.options.register_default_options`. Trying to register
|
||||||
options in plugins will result in errors.
|
these options in plugins will result in errors.
|
||||||
|
|
||||||
|
|
||||||
API Documentation
|
API Documentation
|
||||||
|
|
|
||||||
|
|
@ -34,11 +34,10 @@ class Application(object):
|
||||||
self.version = version
|
self.version = version
|
||||||
#: The instance of :class:`flake8.options.manager.OptionManager` used
|
#: The instance of :class:`flake8.options.manager.OptionManager` used
|
||||||
#: to parse and handle the options and arguments passed by the user
|
#: to parse and handle the options and arguments passed by the user
|
||||||
self.option_manager = None
|
self.option_manager = manager.OptionManager(
|
||||||
temp_option_manager = manager.OptionManager(
|
|
||||||
prog='flake8', version=flake8.__version__
|
prog='flake8', version=flake8.__version__
|
||||||
)
|
)
|
||||||
options.register_default_options(temp_option_manager)
|
options.register_default_options(self.option_manager)
|
||||||
|
|
||||||
# We haven't found or registered our plugins yet, so let's defer
|
# We haven't found or registered our plugins yet, so let's defer
|
||||||
# printing the version until we aggregate options from config files
|
# printing the version until we aggregate options from config files
|
||||||
|
|
@ -62,7 +61,7 @@ class Application(object):
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
preliminary_opts, _ = temp_option_manager.parse_args(args)
|
preliminary_opts, _ = self.option_manager.parse_args(args)
|
||||||
# Set the verbosity of the program
|
# Set the verbosity of the program
|
||||||
flake8.configure_logging(preliminary_opts.verbose,
|
flake8.configure_logging(preliminary_opts.verbose,
|
||||||
preliminary_opts.output_file)
|
preliminary_opts.output_file)
|
||||||
|
|
@ -242,12 +241,7 @@ class Application(object):
|
||||||
This finds the plugins, registers their options, and parses the
|
This finds the plugins, registers their options, and parses the
|
||||||
command-line arguments.
|
command-line arguments.
|
||||||
"""
|
"""
|
||||||
self.option_manager = manager.OptionManager(
|
|
||||||
prog='flake8', version=flake8.__version__
|
|
||||||
)
|
|
||||||
self.find_plugins()
|
self.find_plugins()
|
||||||
options.register_default_options(self.option_manager,
|
|
||||||
self.formatting_plugins.names)
|
|
||||||
self.register_plugin_options()
|
self.register_plugin_options()
|
||||||
self.parse_configuration_and_cli(argv)
|
self.parse_configuration_and_cli(argv)
|
||||||
self.make_formatter()
|
self.make_formatter()
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ from flake8 import defaults
|
||||||
from flake8.main import vcs
|
from flake8.main import vcs
|
||||||
|
|
||||||
|
|
||||||
def register_default_options(option_manager, formatters=None):
|
def register_default_options(option_manager):
|
||||||
"""Register the default options on our OptionManager.
|
"""Register the default options on our OptionManager.
|
||||||
|
|
||||||
The default options include:
|
The default options include:
|
||||||
|
|
@ -82,9 +82,12 @@ def register_default_options(option_manager, formatters=None):
|
||||||
|
|
||||||
# TODO(sigmavirus24): Figure out --first/--repeat
|
# TODO(sigmavirus24): Figure out --first/--repeat
|
||||||
|
|
||||||
|
# NOTE(sigmavirus24): We can't use choices for this option since users can
|
||||||
|
# freely provide a format string and that will break if we restrict their
|
||||||
|
# choices.
|
||||||
add_option(
|
add_option(
|
||||||
'--format', metavar='format', default='default',
|
'--format', metavar='format', default='default',
|
||||||
parse_from_config=True, choices=(formatters or ['default']),
|
parse_from_config=True,
|
||||||
help='Format errors according to the chosen formatter.',
|
help='Format errors according to the chosen formatter.',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue