Implementation inheritance can lead to brittle and hard-to-maintain code. By enforcing the use of the @final
decorator, this plugin aims to encourage composition over inheritance, promoting better software design principles.
To install flake8-final
, you can use pip
:
pip install flake8-final
After installing the plugin, flake8 will automatically use it when you run the following command:
bash
flake8 your_project_directory
The plugin will check each class definition to ensure it has a @final decorator. If a class is missing the @final decorator, an error will be reported.
Given the following Python code:
class MyClass:
pass
Running flake8 will produce the following error:
your_file.py:1:1: FIN100 class must be final
Adding the @final
decorator will resolve the error:
from typing import final
@final
class MyClass:
pass
This project was generated with wemake-python-package
. Current template version is: 9899cb192f754a566da703614227e6d63227b933. See what is updated since then.