-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
[CodeStyle][task 10] enable ruff B017 rule in python/paddle/base #58185
[CodeStyle][task 10] enable ruff B017 rule in python/paddle/base #58185
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
@gouzil 可以review了 |
@@ -42,7 +42,7 @@ class TestAssertVariable(Dy2StTestBase): | |||
def _run(self, func, x, with_exception, to_static): | |||
paddle.jit.enable_to_static(to_static) | |||
if with_exception: | |||
with self.assertRaises(BaseException): | |||
with self.assertRaises(BaseException): # noqa: B017 |
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.
with self.assertRaises(BaseException): # noqa: B017 | |
with self.assertRaises(AssertionError): |
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.
这里从语义上来看,就是应该捕获各种异常的,noqa 是可以的,除非重构代码,不是传入 True/False 而是传入异常类型
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.
OK
@@ -61,10 +61,10 @@ def test_max_memory_allocated_exception(self): | |||
"gpu1", | |||
] | |||
for device in wrong_device: | |||
with self.assertRaises(BaseException): | |||
with self.assertRaises(BaseException): # noqa: B017 |
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.
with self.assertRaises(BaseException): # noqa: B017 | |
with self.assertRaises((ValueError, AssertionError)): |
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.
这四个 memory 的为什么是 ValueError, AssertionError
呢?这是能全部捕获的么?
@@ -61,10 +61,10 @@ def test_max_memory_reserved_exception(self): | |||
"gpu1", | |||
] | |||
for device in wrong_device: | |||
with self.assertRaises(BaseException): | |||
with self.assertRaises(BaseException): # noqa: B017 |
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.
with self.assertRaises(BaseException): # noqa: B017 | |
with self.assertRaises((ValueError, AssertionError)): |
@@ -46,10 +46,10 @@ def test_memory_allocated_exception(self): | |||
"gpu1", | |||
] | |||
for device in wrong_device: | |||
with self.assertRaises(BaseException): | |||
with self.assertRaises(BaseException): # noqa: B017 |
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.
with self.assertRaises(BaseException): # noqa: B017 | |
with self.assertRaises((ValueError, AssertionError)): |
@@ -46,10 +46,10 @@ def test_memory_reserved_exception(self): | |||
"gpu1", | |||
] | |||
for device in wrong_device: | |||
with self.assertRaises(BaseException): | |||
with self.assertRaises(BaseException): # noqa: B017 |
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.
with self.assertRaises(BaseException): # noqa: B017 | |
with self.assertRaises((ValueError, AssertionError)): |
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, @SigureMo
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.
LGTMeow 🐾
PR types
Others
PR changes
Others
Description
paddle.base
check #57367Task 10 B017