Home

Awesome

flake8-return

pypi Python: 3.6+ Downloads Build Status Code coverage License: MIT Code style: black

Flake8 plugin that checks return values. Flake8-return rule set is supported in ruff.

Installation

pip install flake8-return

Errors

def x(y):
    if not y:
        return
    return None  # error!
def x(y):
    if not y:
        return  # error!
    return 1
def x(y):
    if not y:
        return 1
    # error!
def x():
    a = 1
    # some code that not using `a`
    print('test')
    return a  # error!
def x(y, z):
    if y:  # error!
        return 1
    else:
        return z
def x(y, z):
    if y:  # error!
        raise Exception(y)
    else:
        raise Exception(z)
def x(y, z):
    for i in y:
        if i < z:  # error!
            continue
        else:
            a = 0
def x(y, z):
    for i in y:
        if i > z:  # error!
            break
        else:
            a = 0

Returns in asyncio coroutines also supported.

For developers

Show help

make help

Create venv and install deps

make init

Install git precommit hook

make precommit

Run linters, autoformat, tests etc

make pretty lint test

Bump new version

make bump_major
make bump_minor
make bump_patch

Change Log

Unreleased

1.2.0 - 2022-10-28

1.1.3 - 2021-05-05

1.1.2 - 2020-07-09

1.1.1 - 2019-09-21

1.1.0 - 2019-05-23

1.0.0 - 2019-05-13

0.3.2 - 2019-04-01

0.3.1 - 2019-03-11

0.3.0 - 2019-02-26

0.2.0 - 2019-02-21

0.1.1 - 2019-02-10

0.1.0 - 2019-02-10