Giu*_*oni 3 python lint python-3.x
我在 Lint 中有这个警告:R0916: Too many boolean expressions in if statement (6/5) (too-many-boolean-expressions)
那是我的代码:
if (
old_image.get("var") == "Type1"
or old_image.get("var") == "Type2"
or old_image.get("var") == "Type3"
) and (
new_image.get("var") != "Type1"
and new_image.get("var") != "Type2"
and new_image.get("var") != "Type3"
):
Run Code Online (Sandbox Code Playgroud)
如何删除此 lint 错误?
你可以试试这个:
types = [ "Type1", "Type2", "Type3"]
if old_image.get("var") in types and new_image.get("var") not in types:
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
45 次 |
| 最近记录: |