-
Notifications
You must be signed in to change notification settings - Fork 5.8k
[CodeStyle][E711] use is
/is not
for comparison with None
#47452
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
is
/is not
for comparison with None
is
/is not
for comparison with None
是否考虑将修复工具引入precommit配置? |
ast-grep 的话暂时不考虑,一方面它并不是 python 生态的,而是 Rust / Node.js 生态的工具,目前不方便集成,另一方面它刚刚开发几个月,非常不成熟 |
return _legacy_C_ops.reduce_any( | ||
x, 'dim', axis, 'keep_dim', keepdim, 'reduce_all', reduce_all_flag | ||
) | ||
|
||
attrs = { | ||
'dim': axis if axis != None and axis != [] and axis != () else [0], | ||
'dim': axis if axis is not None and axis != [] and axis != () else [0], | ||
'keep_dim': keepdim, | ||
'reduce_all': reduce_all_flag, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2022-10-31 18:16:21 0. APIs without core.ops:
2022-10-31 18:16:21 paddle.fluid.layers.nn.reduce_any
2022-10-31 18:16:21 You must have one RD (JiabinYang (Recommend) or wanghuancoder, phlrain) approval for the api change for the opreator-related api without '_C_ops'.
2022-10-31 18:16:21 For more details, please click [https://github.com/PaddlePaddle/Paddle/wiki/paddle_api_development_manual.md]
请 @wanghuancoder @JiabinYang review
确实如此。后续可以在 代码风格检查指南 里加一下常见错误码(无法自动格式化) 的处理方式。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
请解决下冲突 |
已解决~ |
PR types
Others
PR changes
Others
Describe
解决 Flake8 E711 问题(comparison to None should be ‘if cond is None:’)
x == None
->x is None
x != None
->x is not None
并调整单测中的相关使用(与 None 相关的比较),如
self.assertTrue(x is None)
->self.assertIsNone(x)
,可以优化报错信息:全部替换如下:
self.assertTrue(x is None)
->self.assertIsNone(x)
self.assertTrue(x is not None)
->self.assertIsNotNone(x)
self.assertFalse(x is None)
->self.assertIsNotNone(x)
self.assertFalse(x is not None)
->self.assertIsNone(x)
(无此情况)self.assertEqual(x, None)
->self.assertIsNone(x)
self.assertNotEqual(x, None)
->self.assertIsNotNone(x)
具体所使用工具及命令如下:
Related links