Flake8 Return Plugin
flake8-return is a Flake8 plugin that provides a set of checks related to return values and unnecessary control flow. It aims to improve code readability and eliminate redundant statements. The current version is 1.2.0, with active development and regular releases addressing bug fixes and new checks.
Warnings
- breaking Version 1.2.0 introduced new checks (R505, R506, R507, R508) ported from Pylint (no-else-break, no-else-continue, no-else-raise, no-else-return). These will likely flag new warnings in existing codebases that previously passed linting.
- gotcha The R504 check ('Unnecessary assignment') has undergone multiple fixes and refinements across versions (e.g., v1.1.2, v1.2.0). This means its behavior, including false positives or negatives, might have changed, leading to different linting results for the same code across versions.
- gotcha The R503 check ('Unnecessary else statement') can be opinionated. While often promoting cleaner code, some developers prefer explicit `else` blocks for certain control flow patterns, leading to desired code being flagged.
Install
-
pip install flake8-return
Imports
- Checker
from flake8_return.checker import Checker
Quickstart
# 1. Install Flake8 (if not already installed) pip install flake8 # 2. Install flake8-return pip install flake8-return # 3. Run Flake8 in your project directory # flake8 will automatically discover and load flake8-return flake8 .