How to use the flake8.options.config.get_local_plugins function in flake8

To help you get started, we’ve selected a few flake8 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PyCQA / flake8 / tests / unit / test_get_local_plugins.py View on Github external
def test_get_local_plugins():
    """Verify get_local_plugins returns expected plugins."""
    config_fixture_path = 'tests/fixtures/config_files/local-plugin.ini'
    config_finder = config.ConfigFileFinder('flake8', [])

    with mock.patch.object(config_finder, 'local_config_files') as localcfs:
        localcfs.return_value = [config_fixture_path]
        local_plugins = config.get_local_plugins(config_finder)

    assert local_plugins.extension == ['XE = test_plugins:ExtensionTestPlugin']
    assert local_plugins.report == ['XR = test_plugins:ReportTestPlugin']
github PyCQA / flake8 / tests / unit / test_get_local_plugins.py View on Github external
def test_get_local_plugins_uses_cli_config():
    """Verify behaviour of get_local_plugins with a specified config."""
    config_obj = mock.Mock()
    config_finder = mock.MagicMock()
    config_finder.cli_config.return_value = config_obj
    config_obj.get.return_value = ''

    config.get_local_plugins(config_finder, cli_config='foo.ini')

    config_finder.cli_config.assert_called_once_with('foo.ini')
github PyCQA / flake8 / src / flake8 / main / application.py View on Github external
def find_plugins(self):
        # type: () -> None
        """Find and load the plugins for this application.

        If :attr:`check_plugins`, or :attr:`formatting_plugins` are ``None``
        then this method will update them with the appropriate plugin manager
        instance. Given the expense of finding plugins (via :mod:`entrypoints`)
        we want this to be idempotent and so only update those attributes if
        they are ``None``.
        """
        if self.local_plugins is None:
            self.local_plugins = config.get_local_plugins(
                self.config_finder,
                self.prelim_opts.config,
                self.prelim_opts.isolated,
            )

        sys.path.extend(self.local_plugins.paths)

        if self.check_plugins is None:
            self.check_plugins = plugin_manager.Checkers(
                self.local_plugins.extension
            )

        if self.formatting_plugins is None:
            self.formatting_plugins = plugin_manager.ReportFormatters(
                self.local_plugins.report
            )
github life4 / flakehell / flakehell / _patched / _app.py View on Github external
def find_plugins(self, config_finder) -> None:
        local_plugins = get_local_plugins(config_finder)
        sys.path.extend(local_plugins.paths)
        self.check_plugins = FlakeHellCheckers(local_plugins.extension)  # this line is changed
        self.formatting_plugins = ReportFormatters(local_plugins.report)
        self.check_plugins.load_plugins()
        self.formatting_plugins.load_plugins()
github PyCQA / flake8 / src / flake8 / main / application.py View on Github external
# type: (config.ConfigFileFinder, Optional[str], bool) -> None
        """Find and load the plugins for this application.

        Set the :attr:`check_plugins` and :attr:`formatting_plugins` attributes
        based on the discovered plugins found.

        :param config.ConfigFileFinder config_finder:
            The finder for finding and reading configuration files.
        :param str config_file:
            The optional configuraiton file to override all other configuration
            files (i.e., the --config option).
        :param bool ignore_config_files:
            Determine whether to parse configuration files or not. (i.e., the
            --isolated option).
        """
        local_plugins = config.get_local_plugins(
            config_finder, config_file, ignore_config_files
        )

        sys.path.extend(local_plugins.paths)

        self.check_plugins = plugin_manager.Checkers(local_plugins.extension)

        self.formatting_plugins = plugin_manager.ReportFormatters(
            local_plugins.report
        )

        self.check_plugins.load_plugins()
        self.formatting_plugins.load_plugins()
github zrzka / blackmamba / blackmamba / lib / flake8 / main / application.py View on Github external
def find_plugins(self):
        # type: () -> NoneType
        """Find and load the plugins for this application.

        If :attr:`check_plugins`, :attr:`listening_plugins`, or
        :attr:`formatting_plugins` are ``None`` then this method will update
        them with the appropriate plugin manager instance. Given the expense
        of finding plugins (via :mod:`pkg_resources`) we want this to be
        idempotent and so only update those attributes if they are ``None``.
        """
        if self.local_plugins is None:
            self.local_plugins = config.get_local_plugins(
                self.config_finder,
                self.prelim_opts.config,
                self.prelim_opts.isolated,
            )

        if self.check_plugins is None:
            self.check_plugins = plugin_manager.Checkers(
                self.local_plugins.extension)

        if self.listening_plugins is None:
            self.listening_plugins = plugin_manager.Listeners()

        if self.formatting_plugins is None:
            self.formatting_plugins = plugin_manager.ReportFormatters(
                self.local_plugins.report)