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.
Release files for flake8-override 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| flake8_override-0.1.0.tar.gz | 3.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| flake8_override-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.4 kB
Release files / flake8_override-0.1.0.tar.gz
| Download URL | flake8_override-0.1.0.tar.gz |
|---|---|
| Size | 3.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ed95f36b1aa96c7cfc6c8f1b76f32287403491f003a443d9f2ccc03d19cd7313
|
|
BLAKE2b-256 checksum How to use checksums |
0ef57316c0a58ab0f81cd5e228891970a8acdbfe4a96e1af435376d960aa66c0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.0 CPython/3.13.1 Linux/6.11.0-1018-azure
|
Release files / flake8_override-0.1.0-py3-none-any.whl
| Download URL | flake8_override-0.1.0-py3-none-any.whl |
|---|---|
| Size | 6.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3e3d7b9e90b71923ae539fd7fb2b8c4f7254a0835ccc932ac34af361691cd15f
|
|
BLAKE2b-256 checksum How to use checksums |
abb622c2bdd16bba777345c3292d53b6e3267fa276d121d51becbc956044ec65
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.0 CPython/3.13.1 Linux/6.11.0-1018-azure
|