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.9.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.9.0.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

flake8_max_function_length-0.9.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for flake8_max_function_length-0.9.0.tar.gz
Algorithm Hash digest
SHA256 031d47724cb853fecc16483e6b3445fb1dec620283e568b845eb8c64835d8f73
MD5 26c1fc6ab8b982ed7b0429fb20548b0b
BLAKE2b-256 7a952b086991c3f584b4a2646539b8505121e5071d60102fec416d98664efbc2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for flake8_max_function_length-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6493eed66d95a22a6cf0fd8b38c99f4a58cec4269f0187453544639351a54e02
MD5 b8b2dbcabeaf5dcb33ab3ce5560134cb
BLAKE2b-256 2c043823fb0a564b571048b5a9f6cec9e5e3dac68a6edd7e2ee3cd14aab6e513

See more details on using hashes here.

Supported by

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