This is how python package should look like!
Project description
flake8-override
flake8-override 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-override via pip:
pip install flake8-override
Usage
To use flake8-override, 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
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flake8_override-0.1.0.tar.gz.
File metadata
- Download URL: flake8_override-0.1.0.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.0 CPython/3.13.1 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed95f36b1aa96c7cfc6c8f1b76f32287403491f003a443d9f2ccc03d19cd7313
|
|
| MD5 |
e866a8db63b28d88a36dc6b5190329ff
|
|
| BLAKE2b-256 |
0ef57316c0a58ab0f81cd5e228891970a8acdbfe4a96e1af435376d960aa66c0
|
File details
Details for the file flake8_override-0.1.0-py3-none-any.whl.
File metadata
- Download URL: flake8_override-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.0 CPython/3.13.1 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e3d7b9e90b71923ae539fd7fb2b8c4f7254a0835ccc932ac34af361691cd15f
|
|
| MD5 |
bead85a06a8286e0e9183047c7a18068
|
|
| BLAKE2b-256 |
abb622c2bdd16bba777345c3292d53b6e3267fa276d121d51becbc956044ec65
|