skillfed

flake8-return

Flake8 plugin that checks return values

flake8-return v1.2.0 603.1K downloads/30d#5,812 on PyPI60
Permissive license MIT AGING released

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-return

uv

uv add flake8-return

poetry

poetry add flake8-return

Installing 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

License :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9

Tags

flake8 return value lintingcheck return statementsdetect unnecessary else blockspython return pattern checkerflake8 plugin qualityfunction return analysiscode style return validation
flake8-plugincode-qualitylinting

More Quality Assurance packages