Flake8-pyproject is a Flake8 plugin that enables Flake8 to load its configuration from `pyproject.toml` files, a feature not natively supported by Flake8. It registers itself as a plugin, allowing the standard `flake8` command to seamlessly use `pyproject.toml` when present in the current directory. The library also provides an alternative `flake8p` command. It is currently at version 1.2.4 and receives updates primarily for Flake8 compatibility and new configuration options.
pip install Flake8-pyprojectNo compatibility data collected yet for this library.
This quickstart demonstrates how to install `flake8-pyproject`, configure Flake8 via `pyproject.toml`, and then run the `flake8` command to apply those configurations. The `flake8` command will automatically pick up the `[tool.flake8]` section from your `pyproject.toml`.
Check the release notes for `Flake8-pyproject` to determine the compatible `flake8` version. Downgrade/upgrade `flake8-pyproject` or `flake8` accordingly (e.g., `pip install 'Flake8-pyproject<1.0.0'` for Flake8 4.x, or `pip install 'Flake8-pyproject>=1.0.0'` for Flake8 5.x+).
Place `pyproject.toml` in the project root, or use `flake8 --toml-config /path/to/my_config.toml`.
Convert INI-style lists and comma-separated values to TOML arrays and lists, respectively. Example: `ignore = E231, E241` becomes `ignore = ['E231', 'E241']`.
Ensure `tomli` is installed for Python < 3.11. No action needed for Python 3.11+.
Review any custom scripts or tools that call `flake8` with `flake8-pyproject` installed and ensure they only pass `--toml-config` for custom `pyproject.toml` paths, or other arguments directly handled by Flake8 itself.
Be aware that major updates to Flake8 or Python might require corresponding updates to `flake8-pyproject` for continued compatibility.
Ensure your Flake8 configuration is under the `[tool.flake8]` section in `pyproject.toml` and formatted correctly. Verify `flake8-pyproject` is installed in the same environment as `flake8` and run `flake8` directly (or `flake8p`). If the `pyproject.toml` is not in the current directory, use `flake8 --toml-config /path/to/pyproject.toml`.
Ensure that the directory containing Python scripts for your environment (e.g., `.venv/bin` on Linux/macOS or `Scripts` in a virtual environment on Windows) is added to your system's PATH. You may need to reinstall `flake8-pyproject` or activate your virtual environment.
Change the format of list-based configuration options in `pyproject.toml` from a comma-separated string to a TOML array. For example, `per-file-ignores = ['__init__.py:F401', 'setup.py:E402']` instead of `per-file-ignores = '__init__.py:F401,setup.py:E402'`.