This is how python package should look like!
Project description
flake8-no-private-methods
flake8-no-private-methods
is a Flake8 plugin designed to enforce a coding standard where every method in a class must have the @override decorator. This ensures that all public methods implement their counterparts from an interface, promoting better design practices, easier mocking in unit tests, and simpler extension via decoration.
Seven Virtues of a Good Object. Part 2
Installation
You can install flake8-no-private-methods via pip:
pip install flake8-no-private-methods
Usage
To use flake8-no-private-methods, simply include it in your Flake8 configuration. You can run Flake8 as usual, and the plugin will check for the presence of the @override decorator on each method.
flake8 your_code_directory
Example
Input code
class Dog:
def sound(self):
print('bark')
Expected code
from typing import Protocol, override
class Animal(Protocol):
def sount(self): ...
class Dog(Animal):
@override
def sound(self):
print('bark')
Rationale
The primary motivation for this plugin is to ensure that objects adhere to contracts as specified by interfaces. This has two main benefits:
- Easier Mocking in Unit Tests: Objects that work by contract are easier to mock in unit tests because their behavior is predictable and defined by interfaces.
- Simpler Extension via Decoration: Objects designed with clear contracts are easier to extend and decorate, promoting better software design and maintenance.
License
Credits
This project was generated with wemake-python-package
. Current template version is: 864a62ecb432655249d071e263ac51f053448659. See what is updated since then.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file flake8_no_private_methods-0.0.1.tar.gz
.
File metadata
- Download URL: flake8_no_private_methods-0.0.1.tar.gz
- Upload date:
- Size: 4.0 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7cf9bbd191a879e3ebd9654f0eb97f04a02a3da60754e545320008bcc4f73d64 |
|
MD5 | 89682cec26a423974839363fe7c89fb5 |
|
BLAKE2b-256 | 9c73ef916bd82c6c0f0749595349034a4d03738062c14851146c366ab546c247 |
File details
Details for the file flake8_no_private_methods-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: flake8_no_private_methods-0.0.1-py3-none-any.whl
- Upload date:
- Size: 7.0 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 224bccd71b245b0069c694b95d267aede04eb757614b2ecd644fc5418e3f10c3 |
|
MD5 | e5d40c362acc8973169d344a588c26e2 |
|
BLAKE2b-256 | 8a9778c4fdc8927251dc91e9398cf729500429c7e3d87801d8b7743ceef2cad4 |