Troubleshooting

FlakeHeaven has flake8 deep in its core but they are different. So, when migrating from flake8 there are some details that can be unexpected from your previous experience. So, let’s talk how to turn such details from your enemies to your best friends.

Flake8 configurations are ignored

FlakeHeaven reads flake8 configs and supports most of the options. However, some options (like ignore and select) ignored by design. The motivation is to get rid of over-complicated and unstable way how flake8 select and deselect plugins and provide a better way to do so. See ignored options for details.

It is slow

First of all, let’s talk why FlakeHeaven is fast:

  1. It caches results. Cache invalidates after 24 hours or if the configuration was changed.

  2. It doesn’t run plugins against files without code blocks or against empty *.py files.

  3. It doesn’t create temporary files for linting non-python files, all the magic is done on the fly.

  4. It runs only explicitly specified plugins. If a plugin is not specified in the config, it won’t be run.

And now, why it can be slow:

  1. We use the same plugins-discovery mechanic as flake8 does, and it is slow. It requires to scan all installed libraries on every run. As a solution, keep FlakeHeaven in a separate virtual environment. There are a few tools that can help with it: poetry, pipsi, pipx.

  2. FlakeHeaven lints not only *.py files but also *.md, *.rst and a few more. See parsers section for the details. If you don’t need it, tune ignore to exclude specific files or directories, or filename to exclude extensions.

Some plugins are ignored

There are few requirements for a plugin to be run:

  1. It must be installed in the same venv as FlakeHeaven.

  2. It must be explicitly specified in plugins section in config.

Use missed command to see selected but not installed plugins and plugins command to see installed but not selected plugins.

By default, FlakeHeaven runs only pyflakes and pycodestyle. If you want just run every plugin in the environment (don’t do this), there is a trick how to select everything:

[tool.flakeheaven.plugins]
"*" = ["+*"]

My IDE fails

Flake8 plugin for IDE expects output to be in a specific format. However, FlakeHeaven uses different, human-friendly, output format. Add --format=default option to use default flake8 output format. Also, there is --format=json for, you know, JSON output per-line.

I don’t want to have pyproject.toml

pyproject.toml is a new configuration format for Python tools. It was introduced in PEP 518 and is widely supported by many tools. And that’s a good thing that helps to clean-up the project root for a lot of separate config for different tools. So, it’s a new way-to-go for all the Python tooling, give it a try.

It must be flake8 compatible

Every detail that is not flake8 compatible was added in FlakeHeaven only to make it better. However, if you, by some reason, still want to use FlakeHeaven and Flake8 in the same project, it is easy to have done. FlakeHeaven doesn’t monkey patch anything in Flake8, so it will work as expected. The only thing you should make is to provide tool.flakeheaven.plugins section in pyproject.toml.