Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Flake8 plugin that checks return values

Project description

flake8-return

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

Flake8 plugin that checks return values.

Installation

pip install flake8-return

Errors

  • R501 you shouldn`t add None at any return if function havn`t return value except None
def x(y):
    if not y:
        return
    return None  # error!
  • R502 you should add explicit value at every return if function have return value except None
def x(y):
    if not y:
        return  # error!
    return 1
  • R503 you should add explicit return at end of the function if function have return value except None
def x(y):
    if not y:
        return  # error!
    return 1
  • R504 you shouldn`t assign value to variable if it will be use only as return value
def x():
    a = 1
    # some code that not using `a`
    print('test')
    return a  # error!

Returns in asyncio coroutines also supported.

License

MIT

Change Log

Unreleased

  • ...

1.1.1 - 2019-09-21

  • fixed #3 The R504 doesn't detect that the variable is modified in loop
  • fixed #4 False positive with R503 inside async with clause

1.1.0 - 2019-05-23

  • update flask_plugin_utils version to 1.0

1.0.0 - 2019-05-13

  • skip assign after unpacking while unnecessary assign checking "(x, y = my_obj)"

0.3.2 - 2019-04-01

  • allow "assert False" as last function return

0.3.1 - 2019-03-11

  • add pypi deploy into travis config
  • add make bump_version command

0.3.0 - 2019-02-26

  • skip functions that consist only return None
  • fix false positive when last return inner with statement
  • add unnecessary assign error
  • add support tuple in assign or return expressions
  • add suppport asyncio coroutines

0.2.0 - 2019-02-21

  • fix explicit/implicit
  • add flake8-plugin-utils as dependency
  • allow raise as last function return
  • allow no return as last line in while block
  • fix if/elif/else cases

0.1.1 - 2019-02-10

  • fix error messages

0.1.0 - 2019-02-10

  • initial

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for flake8-return, version 1.1.1
Filename, size File type Python version Upload date Hashes
Filename, size flake8_return-1.1.1-py3-none-any.whl (6.0 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size flake8-return-1.1.1.tar.gz (5.1 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page