Skip to main content

Flake8 Small Entities Plugin

flake8-small-entities is a Flake8 plugin that encourages developers to write smaller, more manageable entities by enforcing the Object Calisthenics rule "Keep Entities Small." The plugin analyzes Python code to ensure functions, classes, and modules do not exceed predefined line limits.

Installation

To install flake8-small-entities, use pip:

pip install flake8-small-entities

Usage

Once installed, the plugin will be automatically activated alongside Flake8. To analyze your project, simply run:

flake8 your_project_directory

Violations of the line limits for functions, classes, and modules will be flagged accordingly.

Configuration

The plugin allows customization of the maximum number of lines allowed for each entity type. You can specify these settings in your Flake8 configuration file or directly via command-line options.

Command-Line Options

  • --max-fn-lines: Maximum number of lines in a function (default is 15)
  • --max-class-lines: Maximum number of lines in a class (default is 50)
  • --max-module-lines: Maximum number of lines in a module (default is 200)

Config File Example

You can also set these options in a .flake8 configuration file in your project root:

[flake8]
max-fn-lines = 20
max-class-lines = 60
max-module-lines = 300

Rules Enforced

  • FSE100: Function has too many lines
  • FSE101: Class has too many lines
  • FSE102: Module has too many lines

Each rule will indicate where the entity exceeds the specified line count, helping developers to refactor code into smaller, more focused components.

Motivation

Adhering to the "Keep Entities Small" rule improves code readability, maintainability, and facilitates easier debugging and testing. Large entities often perform too many functions, making them difficult to understand and change.

Contributing

Contributions are welcome! If you have suggestions for improvements or encounter any issues, please open an issue or submit a pull request on our GitHub repository.

License

This plugin is distributed under the MIT License. The full license text is available in the LICENSE file included with the source code.

Metadata

Release files for flake8-small-entities 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flake8-small-entities 0.1.0
File Size Uploaded
flake8_small_entities-0.1.0.tar.gz 4.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for flake8-small-entities 0.1.0
File Interpreter ABI Platform
flake8_small_entities-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 8.0 kB

Release files / flake8_small_entities-0.1.0.tar.gz

Download URL flake8_small_entities-0.1.0.tar.gz
Size 4.1 kB
Tags Source
SHA-256 checksum
How to use checksums
ed63af9380a9098ad1baf4bf788542724f63dbd039120aa9f447fb0ccf4396df
BLAKE2b-256 checksum
How to use checksums
4fa2b37ddeb12fc0314281339ea76cd48fd96084067cbea1cfcdbf6c87ef835c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.8

Release files / flake8_small_entities-0.1.0-py3-none-any.whl

Download URL flake8_small_entities-0.1.0-py3-none-any.whl
Size 3.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
326a6c028acbb038a6d29b5b49726ecef0788b95b9a1a40dac5ca9bdb704f61f
BLAKE2b-256 checksum
How to use checksums
4f777837036a0662e5d38b557dee26e83a0887e8c05cc5171edc98f4fd4249db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.8

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page