Esempio n. 1
0
    def _unexpected_token():  # type: () -> exceptions.ExecutionError
        def _indent(s):  # type: (str) -> str
            return "    " + s.strip().replace("\n", "\n    ")

        return exceptions.ExecutionError(
            "Expected `per-file-ignores` to be a mapping from file exclude "
            "patterns to ignore codes.\n\n"
            "Configured `per-file-ignores` setting:\n\n{}".format(
                _indent(value)))
Esempio n. 2
0
    def formatter_for(self, formatter_plugin_name):
        """Retrieve the formatter class by plugin name."""
        try:
            default_formatter = self.formatting_plugins['default']
        except KeyError:
            raise exceptions.ExecutionError(
                "The 'default' Flake8 formatting plugin is unavailable. "
                "This usually indicates that your setuptools is too old. "
                "Please upgrade setuptools. If that does not fix the issue"
                " please file an issue.")

        formatter_plugin = self.formatting_plugins.get(formatter_plugin_name)
        if formatter_plugin is None:
            LOG.warning(
                '"%s" is an unknown formatter. Falling back to default.',
                formatter_plugin_name,
            )
            formatter_plugin = default_formatter

        return formatter_plugin.execute
Esempio n. 3
0
 def _unexpected_token() -> exceptions.ExecutionError:
     return exceptions.ExecutionError(
         f"Expected `per-file-ignores` to be a mapping from file exclude "
         f"patterns to ignore codes.\n\n"
         f"Configured `per-file-ignores` setting:\n\n"
         f"{textwrap.indent(value.strip(), '    ')}")