Flake8 plugin that checks return values
Project description
flake8-return
Flake8 plugin that checks return values.
Installation
pip install flake8-return
Errors
- R501 do not explicitly return None in function if it is the only possible return value.
def x(y):
if not y:
return
return None # error!
- R502 do not implicitly return None in function able to return non-None value.
def x(y):
if not y:
return # error!
return 1
- R503 missing explicit return at the end of function able to return non-None value.
def x(y):
if not y:
return 1
# error!
- R504 unecessary variable assignement before return statement.
def x():
a = 1
# some code that not using `a`
print('test')
return a # error!
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.1.3 - 2021-05-05
- Error clarifications (#77) Clément Robert
- fix linting (migrate to black 20.0b1) (#78) Clément Robert
1.1.2 - 2020-07-09
- Make R504 visitors handle while loops (#56) Frank Tackitt
- Rename allows-prereleases to allow-prereleases (#55) Frank Tackitt
- Fix typo: havn't → haven't (#24) Jon Dufresne
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
flake8-return-1.1.3.tar.gz
(5.6 kB
view hashes)
Built Distribution
Close
Hashes for flake8_return-1.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a266191f7ed69aa26b835ec90c5a5522fa8f79f5cf6363a877ac499f8eb418b |
|
MD5 | b696541bb370ef5202e84eb5fb9781fe |
|
BLAKE2b-256 | d52eeea88391408a7c15a07e19df870bba8d393ea103c28d3e567cb92d61a319 |