Skip to main content

flake8-one-class

test codecov Python Version wemake-python-styleguide

Background

In Python modules, having multiple classes in a single file can often indicate overly complex code or an unclear separation of concerns. The flake8-one-class plugin enforces a single public class per module to encourage modular and maintainable code design. Private (internal) classes are allowed but are intended for module-level encapsulation only.

Installation

Install flake8-one-class using pip:

pip install flake8-one-class

Usage

After installation, flake8-one-class will automatically run with flake8:

flake8 your_project_directory

This plugin checks each module for multiple public class definitions. If more than one public class is detected, an error is raised.

Example

Given the following Python code:

class Animal:
    pass

class Plant:
    pass

Running flake8 will produce the following error:

your_file.py:1:1: FOC100 found module with more than one public class

Using only one public class in the module will resolve the error:

class Animal:
    pass

class _Helper:  # private class is allowed
    pass

License

MIT

Credits

This project was generated with wemake-python-package. Current template version is: 9899cb192f754a566da703614227e6d63227b933. See what is updated since then.

Release files for flake8-one-class 0.0.1

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-one-class 0.0.1
File Size Uploaded
flake8_one_class-0.0.1.tar.gz 3.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for flake8-one-class 0.0.1
File Interpreter ABI Platform
flake8_one_class-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 11.1 kB

Release files / flake8_one_class-0.0.1.tar.gz

Download URL flake8_one_class-0.0.1.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
15673b02671b4889144d889e8da14dac5ac7af1f33f5633ab411739a58aefe4f
BLAKE2b-256 checksum
How to use checksums
a74236e0a53368178c849715bef9f07754d46133969ae71ac2464d9a1bcb140b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.4 CPython/3.12.1 Linux/6.5.0-1025-azure

Release files / flake8_one_class-0.0.1-py3-none-any.whl

Download URL flake8_one_class-0.0.1-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3c47e5ba03516891af5b77c5e231772bdf4c37ab2ce14919caacb35451e0b862
BLAKE2b-256 checksum
How to use checksums
b7bce491dfcfbffb49ee7f6e66f9be6b36cdec77102fed4184c9d83b522811e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.4 CPython/3.12.1 Linux/6.5.0-1025-azure

Release history Release notifications | RSS feed

This release

0.0.1 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