Skip to main content

Flake8 plugin to enforce a maximum number of lines per file

Project description

flake8-file-length (FLN)

A Flake8 plugin that enforces a maximum number of lines per file.

  • Plugin name: flake8-file-length
  • Version: 0.1.0
  • Error code prefix: FLN
  • Primary rule: FLN001 file too long: {count} lines (limit {limit}){suffix}
    • When any ignore option is active, the message includes a suffix with total and effective counts: — total=…, effective=….

Installation

pip install flake8-file-length

Check flake8 version to ensure the plugin is registered:

flake8 --version
7.3.0 (flake8-file-length: 0.1.0, mccabe: 0.7.0, pycodestyle: 2.14.0, pyflakes: 3.4.0) CPython 3.13.7 on Linux

Quick start

Run Flake8 selecting only this plugin on your source tree:

flake8 --select FLN path/to/code

By default, files longer than 400 lines will trigger FLN001.

Configuration

You can configure the plugin via any Flake8-supported config file (.flake8, setup.cfg, tox.ini, or pyproject.toml under the [tool.flake8] table). Options:

  • --max-file-length INT (default 400)
  • --file-length-ignore-blank (bool; default false)
  • --file-length-ignore-comments (bool; default false)
  • --file-length-ignore-shebang (bool; default true)

Example .flake8:

[flake8]
select = FLN
max-file-length = 120
file-length-ignore-blank = true
file-length-ignore-comments = true
file-length-ignore-shebang = true

Precommit hook example

To use with pre-commit, add to your .pre-commit-config.yaml:

  - repo: https://github.com/pycqa/flake8
    rev: 7.3.0
    hooks:
      - id: flake8
        additional_dependencies:
          - flake8-file-length==0.1.0 
        args:
          - --select=FLN                 
          - --max-file-length=300
          - --file-length-ignore-blank
          - --file-length-ignore-comments
          - --file-length-ignore-shebang

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_file_length-0.1.0.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

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

flake8_file_length-0.1.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file flake8_file_length-0.1.0.tar.gz.

File metadata

  • Download URL: flake8_file_length-0.1.0.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for flake8_file_length-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1fb3396d70c23151588191e928f4e1ef36bf4f99899b9521155b1fe36ab52c97
MD5 5f7cc954e16edb20198381a37cff9009
BLAKE2b-256 8659ec3bdad8161dda068bc7fba82d58d1056321ddb1c0beb135f712b532d4fc

See more details on using hashes here.

Provenance

The following attestation bundles were made for flake8_file_length-0.1.0.tar.gz:

Publisher: release.yaml on elterrien/flake8-file-length

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file flake8_file_length-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for flake8_file_length-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 17b0b88f5fe432238ec8a30fb73118c2d774840a681ee9114f7bf1fd3df6f700
MD5 1e95b371cd74fe24b94baec9ae7ec507
BLAKE2b-256 8b381f6f094052698ab03118772f785f61037a58fbfc10740ab5e97dd460c532

See more details on using hashes here.

Provenance

The following attestation bundles were made for flake8_file_length-0.1.0-py3-none-any.whl:

Publisher: release.yaml on elterrien/flake8-file-length

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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