Use max/min (#41280)

Signed-off-by: Yuanyuan Chen <cyyever@outlook.com>
This commit is contained in:
Yuanyuan Chen
2025-10-02 20:15:27 +08:00
committed by GitHub
parent f1b64c5b06
commit 1d91a8a454
8 changed files with 9 additions and 9 deletions

View File

@ -134,7 +134,7 @@ def find_test_class(test_file):
break
# Take the test class with the shortest name (just a heuristic)
if target_test_class is None and len(test_classes) > 0:
target_test_class = sorted(test_classes, key=lambda x: (len(x.__name__), x.__name__))[0]
target_test_class = min(test_classes, key=lambda x: (len(x.__name__), x.__name__))
return target_test_class

View File

@ -389,7 +389,7 @@ def get_tiny_config(config_class, model_class=None, **model_tester_kwargs):
# This is to avoid `T5EncoderOnlyModelTest` is used instead of `T5ModelTest`, which has
# `is_encoder_decoder=False` and causes some pipeline tests failing (also failures in `Optimum` CI).
# TODO: More fine grained control of the desired tester class.
model_tester_class = sorted(tester_classes, key=lambda x: (len(x.__name__), x.__name__))[0]
model_tester_class = min(tester_classes, key=lambda x: (len(x.__name__), x.__name__))
except ModuleNotFoundError:
error = f"Tiny config not created for {model_type} - cannot find the testing module from the model name."
raise ValueError(error)

View File

@ -37,7 +37,7 @@ def get_last_stable_minor_release():
last_stable_minor_releases = [
release for release in release_data["releases"] if release.startswith(last_major_minor)
]
last_stable_release = sorted(last_stable_minor_releases, key=version.parse)[-1]
last_stable_release = max(last_stable_minor_releases, key=version.parse)
return last_stable_release