Skip to main content

Configure flake8 via pyproject.toml. Supports local plugins.

Project description

Configure flake8 via pyproject.toml. Supports local plugins.


This flake8 plugin adds support for loading the flake8 configuration from pyproject.toml files, including loading local plugins.

The plugin will automatically find a pyproject.toml file in the current working directory where flake8 is run from. It also overrides the --config CLI option so that a TOML file can be specified to load the config from:

flake8 --config custom.toml

flake8-toml-config will respect the --isolated flag.

Note that this plugin replaces flake8’s built-in support for other config file formats. While the plugin is installed, config can only be read from TOML files.

Table of contents

Configuration translation

Below is an example of a flake8 configuration as it would appear in a .flake8 file:

[flake8]
max-line-length = 80
extend-select = B950
extend-ignore = E203,E501,E701

[flake8:local-plugins]
paths = ./assets/flake8
extension =
    CL1 = custom_repo_linter:Plugin1
    CL2 = custom_repo_linter:Plugin2
reporter =
    CR = custom_repo_reporter:Plugin

Below is the equivalent configuration, suitable for use in a pyproject.toml file. Note that the flake8:local-plugins section requires quotes in the TOML format:

[tool.flake8]
max-line-length = 80
extend-select = ["B950"]
extend-ignore = ["E203", "E501", "E701"]

[tool."flake8:local-plugins"]
paths = ["./assets/flake8"]
extension.CL1 = "custom_repo_linter:Plugin1"
extension.CL2 = "custom_repo_linter:Plugin2"
reporter.CR = "custom_repo_reporter:Plugin"

Alternatively, multi-line TOML strings can be used for clearer config parity:

# ...
[tool."flake8:local-plugins"]
paths = ["./assets/flake8"]
extension = """
    CL1 = custom_repo_linter:Plugin1
    CL2 = custom_repo_linter:Plugin2
"""
reporter = """
    CR = custom_repo_reporter:Plugin
"""

pipx usage

If flake8 is installed using pipx, you can inject this plugin:

pipx inject flake8 flake8-toml-config

pre-commit usage

Add this plugin as an additional dependency:

- repo: "https://github.com/pycqa/flake8"
  rev: "7.3.0"
  hooks:
    - id: "flake8"
      additional_dependencies:
        - "flake8-toml-config==1.0.0"

Note that the pre-commit autoupdate command, and pre-commit.ci, do not update additional dependencies. Consider using upadup to auto-update additional dependencies as needed.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flake8_toml_config-1.0.0.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flake8_toml_config-1.0.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file flake8_toml_config-1.0.0.tar.gz.

File metadata

  • Download URL: flake8_toml_config-1.0.0.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for flake8_toml_config-1.0.0.tar.gz
Algorithm Hash digest
SHA256 6665039caf44339ea12d83e61ba00a698039f5ae1e20c0202a96caa9d0963773
MD5 66b4944a828783af06d15f72bec19226
BLAKE2b-256 6569df6e0524e3f6eb0dd2d4e6ce58eed7a54c6b6054adeec82b1e352eec3fe2

See more details on using hashes here.

File details

Details for the file flake8_toml_config-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for flake8_toml_config-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 009251427c3137df8409bc58adee83d473b5e693765725fafbfb9f647e929982
MD5 e564b09af61d775ec616155e8655f790
BLAKE2b-256 dfda70bf88772f1668300ce0b8cab3e90d4c7ec94c830fc3a4eb0859206467e7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page