{"id":13734732,"url":"https://github.com/john-hen/Flake8-pyproject","last_synced_at":"2025-05-08T11:30:48.568Z","repository":{"id":42197855,"uuid":"463584448","full_name":"john-hen/Flake8-pyproject","owner":"john-hen","description":"Flake8 plug-in loading the configuration from pyproject.toml","archived":false,"fork":false,"pushed_at":"2023-10-29T20:07:47.000Z","size":55,"stargazers_count":217,"open_issues_count":1,"forks_count":10,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-08-01T10:41:02.035Z","etag":null,"topics":["flake8","flake8-plugin","flake8-plugins","pyproject","pyproject-toml"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/Flake8-pyproject","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/john-hen.png","metadata":{"files":{"readme":"ReadMe.md","changelog":null,"contributing":null,"funding":null,"license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-02-25T15:33:46.000Z","updated_at":"2024-07-30T01:09:20.000Z","dependencies_parsed_at":"2024-01-06T09:59:44.894Z","dependency_job_id":"f6d74717-3dd7-4eff-b9e1-5b6c89adbc1d","html_url":"https://github.com/john-hen/Flake8-pyproject","commit_stats":{"total_commits":57,"total_committers":6,"mean_commits":9.5,"dds":0.1228070175438597,"last_synced_commit":"d4064f6703b113590e175817f2fe2cbb466ffdc1"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/john-hen%2FFlake8-pyproject","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/john-hen%2FFlake8-pyproject/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/john-hen%2FFlake8-pyproject/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/john-hen%2FFlake8-pyproject/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/john-hen","download_url":"https://codeload.github.com/john-hen/Flake8-pyproject/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":213758654,"owners_count":15634354,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flake8","flake8-plugin","flake8-plugins","pyproject","pyproject-toml"],"created_at":"2024-08-03T03:00:59.306Z","updated_at":"2024-08-03T03:03:57.796Z","avatar_url":"https://github.com/john-hen.png","language":"Python","funding_links":[],"categories":["Tools","Python"],"sub_categories":[],"readme":"﻿# Flake8-pyproject\r\n*Flake8 plug-in loading the configuration from `pyproject.toml`*\r\n\r\n[Flake8] cannot be configured via `pyproject.toml`, even though\r\nvirtually all other Python dev tools have adopted it as the central\r\nlocation for project configuration. The discussion of the original\r\nproposal ([#234]) was closed as \"too heated\", subsequent feature\r\nand pull requests were marked as \"spam\" ([#1332], [#1421], [#1431],\r\n[#1447], [#1501]).\r\n\r\nFlake8-pyproject also has bad manners and force-feeds Flake8 the\r\nspam it so despises. It registers itself as a Flake8 plug-in to\r\nseamlessly load the configuration from `pyproject.toml` when you\r\nrun the `flake8` command.\r\n\r\n[Flake8]: https://github.com/PyCQA/flake8\r\n[#234]:   https://github.com/PyCQA/flake8/issues/234\r\n[#1332]:  https://github.com/PyCQA/flake8/pull/1332\r\n[#1421]:  https://github.com/PyCQA/flake8/issues/1421\r\n[#1431]:  https://github.com/PyCQA/flake8/issues/1431\r\n[#1447]:  https://github.com/PyCQA/flake8/issues/1447\r\n[#1501]:  https://github.com/PyCQA/flake8/issues/1501\r\n\r\n\r\n## Usage\r\n\r\nSay your Flake8 configuration in `.flake8` (or in `tox.ini`, or\r\n`setup.cfg`) is this:\r\n```ini\r\n[flake8]\r\nignore = E231, E241\r\nper-file-ignores =\r\n    __init__.py:F401\r\nmax-line-length = 88\r\ncount = true\r\n```\r\n\r\nCopy that `[flake8]` section to `pyproject.toml`, rename it as\r\n`[tool.flake8]`, and convert the key–value pairs to the [TOML format]:\r\n```toml\r\n[tool.flake8]\r\nignore = ['E231', 'E241']\r\nper-file-ignores = [\r\n    '__init__.py:F401',\r\n]\r\nmax-line-length = 88\r\ncount = true\r\n```\r\n\r\nThen run `flake8` in the project root folder, where `pyproject.toml`\r\nis located.\r\n\r\nIn case your TOML-based configuration is contained in a different\r\nfolder, or the file has a different name, specify the location with\r\nthe `--toml-config` command-line option.\r\n\r\nFor compatibility with earlier versions of this package, and perhaps\r\nextra reliability in terms of possible future breakage of the plug-in\r\nhook, the package also provides a `flake8p` command that could be\r\ncalled alternatively to lint the code.\r\n\r\n[TOML format]: https://toml.io\r\n\r\n\r\n## Implementation\r\n\r\nFlake8 uses [`RawConfigParser`] from the standard library to parse its\r\nconfiguration files, and therefore expects them to have the [INI\r\nformat].\r\n\r\nThis library hooks into Flake8's plug-in mechanism to load the\r\nconfiguration from `pyproject.toml` instead, *if* it finds such a file\r\nin the current folder (working directory). It then creates a\r\n`RawConfigParser` instance, converting from the TOML input format,\r\nand passes it on to Flake8 while discarding configuration options that\r\nwould otherwise be sourced from elsewhere.\r\n\r\nAs of Python 3.11, a TOML parser is part of the standard library ([PEP\r\n680]). On older Python installations, we rely on [Tomli].\r\n\r\nA few very simple integration tests round out the package, making sure\r\nthat any one of the possible configuration files are in fact accepted\r\nwhen `pyproject.toml` isn't found.\r\n\r\n[`RawConfigParser`]: https://docs.python.org/3/library/configparser.html#configparser.RawConfigParser\r\n[INI format]:        https://en.wikipedia.org/wiki/INI_file#Format\r\n[Tomli]:             https://pypi.org/project/tomli/\r\n[PEP 680]:           https://www.python.org/dev/peps/pep-0680\r\n\r\n\r\n## Pre-commit hook\r\n\r\nUse the pre-commit hook for Flake8 itself and make sure this package\r\nhere is installed as well. The pre-commit configuration, in\r\n`.pre-commit-config.yaml`, would then look like so:\r\n```yaml\r\n- repo: https://github.com/pycqa/flake8\r\n  rev: 6.0.0\r\n  hooks:\r\n    - id: flake8\r\n      additional_dependencies: [Flake8-pyproject]\r\n```\r\n\r\nChange the revision to whatever is the latest release version of\r\nFlake8.\r\n\r\n\r\n[![release](\r\n    https://img.shields.io/pypi/v/Flake8-pyproject.svg?label=release)](\r\n    https://pypi.python.org/pypi/Flake8-pyproject)\r\n[![coverage](\r\n    https://img.shields.io/codecov/c/github/john-hen/Flake8-pyproject?token=30Gjak3Ksu)](\r\n    https://codecov.io/gh/john-hen/Flake8-pyproject)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohn-hen%2FFlake8-pyproject","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohn-hen%2FFlake8-pyproject","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohn-hen%2FFlake8-pyproject/lists"}