https://github.com/bigbuildbench/john-hen_flake8-pyproject

https://github.com/bigbuildbench/john-hen_flake8-pyproject

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.3%) to scientific vocabulary
Last synced: 10 months ago · JSON representation

Repository

Basic Info
  • Host: GitHub
  • Owner: BigBuildBench
  • License: mit
  • Language: Python
  • Default Branch: master
  • Size: 10.7 KB
Statistics
  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Created over 1 year ago · Last pushed over 1 year ago
Metadata Files
Readme License

ReadMe.md

Flake8-pyproject

Flake8 plug-in loading the configuration from pyproject.toml

Flake8 cannot be configured via pyproject.toml, even though virtually all other Python dev tools have adopted it as the central location for project configuration. The discussion of the original proposal (#234) was closed as "too heated", subsequent feature and pull requests were marked as "spam" (#1332, #1421, #1431, #1447, #1501).

Flake8-pyproject also has bad manners and force-feeds Flake8 the spam it so despises. It registers itself as a Flake8 plug-in to seamlessly load the configuration from pyproject.toml when you run the flake8 command.

Usage

Say your Flake8 configuration in .flake8 (or in tox.ini, or setup.cfg) is this: ini [flake8] ignore = E231, E241 per-file-ignores = __init__.py:F401 max-line-length = 88 count = true

Copy that [flake8] section to pyproject.toml, rename it as [tool.flake8], and convert the key–value pairs to the TOML format: toml [tool.flake8] ignore = ['E231', 'E241'] per-file-ignores = [ '__init__.py:F401', ] max-line-length = 88 count = true

Then run flake8 in the project root folder, where pyproject.toml is located.

In case your TOML-based configuration is contained in a different folder, or the file has a different name, specify the location with the --toml-config command-line option.

For compatibility with earlier versions of this package, and perhaps extra reliability in terms of possible future breakage of the plug-in hook, the package also provides a flake8p command that could be called alternatively to lint the code.

Implementation

Flake8 uses RawConfigParser from the standard library to parse its configuration files, and therefore expects them to have the INI format.

This library hooks into Flake8's plug-in mechanism to load the configuration from pyproject.toml instead, if it finds such a file in the current folder (working directory). It then creates a RawConfigParser instance, converting from the TOML input format, and passes it on to Flake8 while discarding configuration options that would otherwise be sourced from elsewhere.

As of Python 3.11, a TOML parser is part of the standard library (PEP 680). On older Python installations, we rely on Tomli.

A few very simple integration tests round out the package, making sure that any one of the possible configuration files are in fact accepted when pyproject.toml isn't found.

Pre-commit hook

Use the pre-commit hook for Flake8 itself and make sure this package here is installed as well. The pre-commit configuration, in .pre-commit-config.yaml, would then look like so: yaml - repo: https://github.com/pycqa/flake8 rev: 6.0.0 hooks: - id: flake8 additional_dependencies: [Flake8-pyproject]

Change the revision to whatever is the latest release version of Flake8.

release coverage

Owner

  • Name: BigBuildBench
  • Login: BigBuildBench
  • Kind: organization

abbr. B3, benchmarking the repo-level understanding capability of your LLMs by reconstructing project build-file.

GitHub Events

Total
  • Create event: 4
Last Year
  • Create event: 4

Dependencies

.github/workflows/commit.yml actions
  • actions/checkout v4 composite
  • actions/setup-python v4 composite
.github/workflows/coverage.yml actions
  • actions/checkout v4 composite
  • actions/setup-python v4 composite
  • codecov/codecov-action v3 composite
.github/workflows/scheduled.yml actions
  • actions/checkout v4 composite
  • actions/setup-python v4 composite
pyproject.toml pypi
tests/fixtures/config_mixed/pyproject.toml pypi
tests/fixtures/config_pyproject/pyproject.toml pypi
tests/fixtures/empty_pyproject/pyproject.toml pypi
tests/fixtures/empty_tool_section/pyproject.toml pypi