Skip to main content

flake8 plugin for check and inheritance of implementations

Project description

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.

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_one_class-0.0.1.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

flake8_one_class-0.0.1-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file flake8_one_class-0.0.1.tar.gz.

File metadata

  • Download URL: flake8_one_class-0.0.1.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.1 Linux/6.5.0-1025-azure

File hashes

Hashes for flake8_one_class-0.0.1.tar.gz
Algorithm Hash digest
SHA256 15673b02671b4889144d889e8da14dac5ac7af1f33f5633ab411739a58aefe4f
MD5 994327bb449ca0c728bcf0febfcc5036
BLAKE2b-256 a74236e0a53368178c849715bef9f07754d46133969ae71ac2464d9a1bcb140b

See more details on using hashes here.

File details

Details for the file flake8_one_class-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: flake8_one_class-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.1 Linux/6.5.0-1025-azure

File hashes

Hashes for flake8_one_class-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3c47e5ba03516891af5b77c5e231772bdf4c37ab2ce14919caacb35451e0b862
MD5 afce5bc5b7c39d04e50de5e9a4cfcd3b
BLAKE2b-256 b7bce491dfcfbffb49ee7f6e66f9be6b36cdec77102fed4184c9d83b522811e6

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