mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-01 03:26:52 +00:00
Run the individual methods in Application#initialize
We need to initialize part of the Application so we can set options passed by the user, but we also want to delay making things, e.g., - Formatter - Style Guide - etc. Until we have the options solidified so we don't have to do annoying things.
This commit is contained in:
parent
4d6929c8ab
commit
dc05fce516
2 changed files with 12 additions and 1 deletions
|
|
@ -11,7 +11,12 @@ LOG = logging.getLogger(__name__)
|
|||
def get_style_guide(**kwargs):
|
||||
"""Stub out the only function I'm aware of people using."""
|
||||
application = app.Application()
|
||||
application.initialize([])
|
||||
application.find_plugins()
|
||||
application.register_plugin_options()
|
||||
application.parse_configuration_and_cli([])
|
||||
# We basically want application.initialize to be called but with these
|
||||
# options set instead before we make our formatter, notifier, internal
|
||||
# style guide and file checker manager.
|
||||
options = application.options
|
||||
for key, value in kwargs.items():
|
||||
try:
|
||||
|
|
@ -19,6 +24,10 @@ def get_style_guide(**kwargs):
|
|||
setattr(options, key, value)
|
||||
except AttributeError:
|
||||
LOG.error('Could not update option "%s"', key)
|
||||
application.make_formatter()
|
||||
application.make_notifier()
|
||||
application.make_guide()
|
||||
application.make_file_checker_manager()
|
||||
return StyleGuide(application)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -270,6 +270,8 @@ class Application(object):
|
|||
This finds the plugins, registers their options, and parses the
|
||||
command-line arguments.
|
||||
"""
|
||||
# NOTE(sigmavirus24): When updating this, make sure you also update
|
||||
# our legacy API calls to these same methods.
|
||||
self.find_plugins()
|
||||
self.register_plugin_options()
|
||||
self.parse_configuration_and_cli(argv)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue