flake8-return
Flake8 plugin that checks return values
What it is and what it does
flake8-return is a flake8 plugin that enforces consistent and clean return statement patterns in Python code. It detects eight categories of return-related issues: explicit None returns when unnecessary, implicit None returns in functions that can return non-None values, missing explicit returns at function end, unnecessary variable assignments before returns, and redundant else blocks after return, raise, continue, or break statements. The plugin also supports asyncio coroutines.
You install it alongside flake8, and it runs automatically during linting without requiring separate configuration. It flags violations with error codes R501 through R508, each targeting a specific anti-pattern. The plugin depends on flake8-plugin-utils for its implementation and works with Python versions from 3.6 onward.
Use it for:
- Enforce consistent return behavior across a codebase to catch functions that sometimes return None implicitly and sometimes explicitly.
- Simplify control flow by detecting and removing unnecessary else blocks after return or raise statements.
- Catch unnecessary intermediate variable assignments that serve no purpose before a return.
- Ensure all code paths in a function that can return a value have an explicit return statement.
- Maintain code style consistency in teams by automatically flagging return-related anti-patterns during CI/CD linting.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A flake8 plugin that detects and flags problematic return statement patterns in Python functions, including unnecessary assignments, redundant else blocks after control flow statements, and inconsistent None handling.
Yes, if you use flake8 and want to enforce return statement consistency. The plugin is low-friction to install, has no known vulnerabilities, and covers a useful gap in standard flake8 checks. The aging maintenance status is a minor concern—last release was 2022-10-28—but the repository remains active and the plugin's scope is narrow enough that it is unlikely to break with minor Python or flake8 updates. Install it if your team values clean return patterns; skip it if you already enforce these rules through code review or a different linter.
Install
flake8-return on PyPI
pip
pip install flake8-returnuv
uv add flake8-returnpoetry
poetry add flake8-returnInstalling flake8-return
Before you install
Low friction installation with a single lightweight runtime dependency. The package is aging—last release was 2022-10-28—but the repository remains active with recent commits and no archived status, suggesting maintenance continues despite infrequent version bumps.
License in practice
MIT license (permissive) places no restrictions on use, modification, or distribution in proprietary or open-source projects.
Quickstart
pip install flake8-return
# Then run flake8 on your code; the plugin activates automatically
flake8 your_file.py
# Example: this will trigger R501
def example(x):
if not x:
return
return None
Requires flake8 to be installed and configured; the plugin integrates into flake8's linting pipeline and does not work standalone.
Verify before relying
- Whether the aging maintenance status (last release 2022-10-28, 1386 days ago) affects compatibility with recent Python or flake8 versions.
- Performance impact on large codebases or whether there are known false positives beyond those documented in the changelog.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.6,<4.0) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — flake8-plugin-utils |
| Maintenance | aging — 1,386 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 603,124/month — #5,812 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: flake8_return-1.2.0-py3-none-any.whl
Keywords: flake8, plugin, return
Tags
More Quality Assurance packages
Coverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
ruffRuff is a Python linter and code formatter…
permissive · top 1,000 on PyPI
pexpectPexpect spawns and controls interactive console…
permissive · top 1,000 on PyPI
blackBlack reformats Python source code to a…
permissive · top 1,000 on PyPI
pytest-xdistpytest-xdist distributes pytest tests across…
permissive · top 1,000 on PyPI
cfn-lintValidates AWS CloudFormation templates in YAML…
permissive · top 1,000 on PyPI
flake8-pieA flake8 plugin that detects code quality…
permissive · top 15,000 on PyPI
flake8-plugin-utilsProvides base classes and utilities for writing…
permissive · top 5,000 on PyPI
flake8-pytest-styleA flake8 plugin that detects and reports style…
unclear · top 15,000 on PyPI
flake8-unused-argumentsA flake8 plugin that detects unused function…
permissive · top 15,000 on PyPI
flake8-comprehensionsA flake8 plugin that detects and suggests…
permissive · top 5,000 on PyPI
flake8-printA flake8 plugin that detects print statements…
permissive · top 5,000 on PyPI
flake8-noqaA flake8 plugin that validates the formatting…
copyleft · top 5,000 on PyPI
flake8-implicit-str-concatA Flake8 plugin that detects and reports…
permissive · top 15,000 on PyPI
flake8_simplifyA flake8 plugin that detects and flags…
permissive · top 15,000 on PyPI
flake8-tidy-importsA flake8 plugin that detects and reports…
permissive · top 15,000 on PyPI