diff --git a/src/flake8/api/legacy.py b/src/flake8/api/legacy.py index 9fc05bb..883f0f6 100644 --- a/src/flake8/api/legacy.py +++ b/src/flake8/api/legacy.py @@ -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) diff --git a/src/flake8/main/application.py b/src/flake8/main/application.py index 35feede..c7a9741 100644 --- a/src/flake8/main/application.py +++ b/src/flake8/main/application.py @@ -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)