mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[BE]: enable ruff rules PLR1722 and PLW3301 (#109461)
Enables two ruff rules derived from pylint: * PLR1722 replaces any exit() calls with sys.exit(). exit() is only designed to be used in repl contexts as may not always be imported by default. This always use the version in the sys module which is better * PLW3301 replaces nested min / max calls with simplified versions (ie. `min(a, min(b, c))` => `min(a, b. c)`). The new version is more idiomatic and more efficient. Pull Request resolved: https://github.com/pytorch/pytorch/pull/109461 Approved by: https://github.com/ezyang
This commit is contained in:
committed by
PyTorch MergeBot
parent
a9a0f7a4ad
commit
6d725e7d66
@ -12,7 +12,7 @@ try:
|
||||
from tools.testing.test_selections import calculate_shards, ShardedTest, THRESHOLD
|
||||
except ModuleNotFoundError:
|
||||
print("Can't import required modules, exiting")
|
||||
exit(1)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
class TestCalculateShards(unittest.TestCase):
|
||||
@ -308,7 +308,7 @@ class TestCalculateShards(unittest.TestCase):
|
||||
if k != "super_long_test" and k != "long_test1"
|
||||
]
|
||||
sum_of_rest = sum(rest_of_tests)
|
||||
random_times["super_long_test"] = max(sum_of_rest / 2, max(rest_of_tests))
|
||||
random_times["super_long_test"] = max(sum_of_rest / 2, *rest_of_tests)
|
||||
random_times["long_test1"] = sum_of_rest - random_times["super_long_test"]
|
||||
# An optimal sharding would look like the below, but we don't need to compute this for the test:
|
||||
# optimal_shards = [
|
||||
|
Reference in New Issue
Block a user