Flake8插件,用于检查返回值
项目描述
flake8-return
Flake8插件,用于检查返回值。
安装
pip install flake8-return
错误
- R501 函数如果只有返回None一种可能值,则不要显式返回None。
def x(y):
if not y:
return
return None # error!
- R502 函数能够返回非None值,则不要隐式返回None。
def x(y):
if not y:
return # error!
return 1
- R503 函数能够返回非None值,但在末尾缺少显式返回。
def x(y):
if not y:
return 1
# error!
- R504 在返回语句之前不要进行不必要的变量赋值。
def x():
a = 1
# some code that not using `a`
print('test')
return a # error!
- R505 在返回语句之后不要有不必要的else。
def x(y, z):
if y: # error!
return 1
else:
return z
- R506 在raise语句之后不要有不必要的else。
def x(y, z):
if y: # error!
raise Exception(y)
else:
raise Exception(z)
- R507 在continue语句之后不要有不必要的else。
def x(y, z):
for i in y:
if i < z: # error!
continue
else:
a = 0
- R508 在break语句之后不要有不必要的else。
def x(y, z):
for i in y:
if i > z: # error!
break
else:
a = 0
asyncio协程也支持返回。
开发者
显示帮助
make help
创建venv并安装依赖
make init
安装git precommit钩子
make precommit
运行linters、autoformat、tests等
make pretty lint test
提升新版本
make bump_major
make bump_minor
make bump_patch
变更日志
未发布
- ...
1.2.0 - 2022-10-28
- 从pylint导出no-else-break、no-else-continue、no-else-raise、no-else-return (#122) Calum Young
- PEP 621:迁移更多配置到pyproject.toml (#123) Christian Clauss
- 修复/116/R504-try-except (#120) Calum Young
- 更新ci (#119) Calum Young
- 修复/47/Update-R504-for-assignment-value (#117) Calum Young
- 升级GitHub Actions (#113) Christian Clauss
- 添加一个空格以避免R503中的打字错误 (#98) Christian Clauss
- GitHub Action以检查Python代码 (#97) Christian Clauss
- 拼写修正 (#92) Aarni Koskela
- 创建codeql-analysis.yml Afonasev Evgeniy
- 将flake8-plugin-utils从1.1.1提升到1.3.2 (#87) dependabot
- 将mypy从0.812升级到0.971 (#114) dependabot
- 将pytest-cov从3.0.0升级到4.0.0 (#124) dependabot
- 将pytest-cov从2.11.1升级到3.0.0 (#102) dependabot
- 将pytest-mock从3.6.0升级到3.6.1 (#91) dependabot
- 将pytest从6.2.4升级到6.2.5 (#99) dependabot
- 将pylint从2.8.2升级到2.10.2 (#100) dependabot
- 将pytest从6.2.3升级到6.2.4 (#86) dependabot
1.1.3 - 2021-05-05
- 错误澄清 (#77) Clément Robert
- 修复linting(迁移到black 20.0b1) (#78) Clément Robert
1.1.2 - 2020-07-09
- 让R504访客处理while循环 (#56) Frank Tackitt
- 将allows-prereleases重命名为allow-prereleases (#55) Frank Tackitt
- 修复错别字:→ haven't (#24) Jon Dufresne
1.1.1 - 2019-09-21
1.1.0 - 2019-05-23
- 更新flask_plugin_utils版本到1.0
1.0.0 - 2019-05-13
- 跳过解包后的不必要的赋值检查"(x, y = my_obj)"
0.3.2 - 2019-04-01
- 允许"assert False"作为函数的最后返回值
0.3.1 - 2019-03-11
- 将pypi部署添加到travis配置中
- 添加make bump_version命令
0.3.0 - 2019-02-26
- 跳过仅包含
return None
的函数 - 修复最后返回内with语句时的误报
- 添加不必要的赋值错误
- 支持在赋值或返回表达式中使用元组
- 支持asyncio协程
0.2.0 - 2019-02-21
- 修复显式/隐式问题
- 添加flake8-plugin-utils作为依赖项
- 允许将raise作为函数的最后返回值
- 允许while块的最后一行没有返回
- 修复if/elif/else情况
0.1.1 - 2019-02-10
- 修复错误信息
0.1.0 - 2019-02-10
- 初始版本
项目详情
下载文件
下载适用于您的平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。
源分布
flake8-return-1.2.0.tar.gz (10.0 kB 查看哈希值)
构建分布
flake8_return-1.2.0-py3-none-any.whl (10.1 kB 查看哈希值)