mirror of
https://github.com/PyCQA/flake8.git
synced 2026-03-31 03:06:53 +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.
|
||||
|
||||
The default flake8 options are registered by
|
||||
:func:`~flake8.main.cli.register_default_options`. Trying to register these
|
||||
options in plugins will result in errors.
|
||||
:func:`~flake8.main.options.register_default_options`. Trying to register
|
||||
these options in plugins will result in errors.
|
||||
|
||||
|
||||
API Documentation
|
||||
|
|
|
|||
|
|
@ -34,11 +34,10 @@ class Application(object):
|
|||
self.version = version
|
||||
#: The instance of :class:`flake8.options.manager.OptionManager` used
|
||||
#: to parse and handle the options and arguments passed by the user
|
||||
self.option_manager = None
|
||||
temp_option_manager = manager.OptionManager(
|
||||
self.option_manager = manager.OptionManager(
|
||||
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
|
||||
# printing the version until we aggregate options from config files
|
||||
|
|
@ -62,7 +61,7 @@ class Application(object):
|
|||
except ValueError:
|
||||
pass
|
||||
|
||||
preliminary_opts, _ = temp_option_manager.parse_args(args)
|
||||
preliminary_opts, _ = self.option_manager.parse_args(args)
|
||||
# Set the verbosity of the program
|
||||
flake8.configure_logging(preliminary_opts.verbose,
|
||||
preliminary_opts.output_file)
|
||||
|
|
@ -242,12 +241,7 @@ class Application(object):
|
|||
This finds the plugins, registers their options, and parses the
|
||||
command-line arguments.
|
||||
"""
|
||||
self.option_manager = manager.OptionManager(
|
||||
prog='flake8', version=flake8.__version__
|
||||
)
|
||||
self.find_plugins()
|
||||
options.register_default_options(self.option_manager,
|
||||
self.formatting_plugins.names)
|
||||
self.register_plugin_options()
|
||||
self.parse_configuration_and_cli(argv)
|
||||
self.make_formatter()
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ from flake8 import defaults
|
|||
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.
|
||||
|
||||
The default options include:
|
||||
|
|
@ -82,9 +82,12 @@ def register_default_options(option_manager, formatters=None):
|
|||
|
||||
# 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(
|
||||
'--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.',
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue