Skip to main content

A configurable flake8 plugin to enforce a maximum function/method length.

Project description

flake8-max-function-length

A configurable flake8 plugin to enforce a maximum function/method length.

GitHub Workflow Status PyPI PyPI PyPI - License Code style: black

Installation

Install with pip

pip install flake8-max-function-length

Configuration Options

The package has only one rule MFL000 to check that function length is equal or lower to a maximum value. By default, the function length should be lower than 50 lines and is calculated based on its content ignoring its docstring, comments and empty lines. Still, you have the ability to customize that based on the following options:

  • --max-function-length=n: Maximum allowed function length. (Default: 50)
  • --mfl-include-function-definition: Include the function definition line(s) when calculating the function length. (Default: disabled)
  • --mfl-include-docstring: Include the length of the docstring when calculating the function length. (Default: disabled)
  • --mfl-include-empty-lines: Include empty lines inside the function when calculating the function length. (Default: disabled)
  • --mfl-include-comment-lines: Include comment lines when calculating the function length. (Default: disabled)

Usage with pre-commit

repos:
  - repo: https://github.com/pycqa/flake8
    rev: '6.0.0'
    hooks:
      - id: flake8
        #args: [ --max-function-length, '100', --mfl-include-docstring, --mfl-include-comment-lines ]
        additional_dependencies: [ "flake8-max-function-length==0.8.0" ]

Similar tools

License

This project is MIT licensed.

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_max_function_length-0.8.0.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file flake8_max_function_length-0.8.0.tar.gz.

File metadata

File hashes

Hashes for flake8_max_function_length-0.8.0.tar.gz
Algorithm Hash digest
SHA256 a459c128dd0895fe771010e0edcca5a594afc220c0b183d7a467cb8994990aea
MD5 98063cb0093390e2e819e4901f10107e
BLAKE2b-256 3d86eefa1220568491fb29feb764b530a7fd9b8f0aff9e6bfca32b60ae2543a5

See more details on using hashes here.

File details

Details for the file flake8_max_function_length-0.8.0-py3-none-any.whl.

File metadata

File hashes

Hashes for flake8_max_function_length-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b1c39ff7e2de38e598594599f68b82e3e45a3dd4230c416101e62ec015d0c1a2
MD5 5cb7f09ba193e1f6932d6812ab522add
BLAKE2b-256 5892ec56693dc8be0b2a1a5b139c54090f6509619e2c5abb034cf4ec6b602437

See more details on using hashes here.

Supported by

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