Apply several ruff SIM rules (#37283)
* Apply ruff SIM118 fix Signed-off-by: cyy <cyyever@outlook.com> * Apply ruff SIM910 fix Signed-off-by: cyy <cyyever@outlook.com> * Apply ruff SIM101 fix Signed-off-by: cyy <cyyever@outlook.com> * Format code Signed-off-by: cyy <cyyever@outlook.com> * More fixes Signed-off-by: cyy <cyyever@outlook.com> --------- Signed-off-by: cyy <cyyever@outlook.com>
This commit is contained in:
@@ -1440,7 +1440,7 @@ class GenerationTesterMixin:
|
||||
# added support for it yet. We skip these models for now.
|
||||
has_encoder_attributes = any(
|
||||
attr_name
|
||||
for attr_name in config.to_dict().keys()
|
||||
for attr_name in config.to_dict()
|
||||
if attr_name.startswith("encoder") and attr_name != "encoder_no_repeat_ngram_size"
|
||||
)
|
||||
if has_encoder_attributes:
|
||||
@@ -1644,7 +1644,7 @@ class GenerationTesterMixin:
|
||||
config.is_decoder = True
|
||||
|
||||
model = model_class(config).to(torch_device).eval()
|
||||
if "inputs_embeds" not in inspect.signature(model.prepare_inputs_for_generation).parameters.keys():
|
||||
if "inputs_embeds" not in inspect.signature(model.prepare_inputs_for_generation).parameters:
|
||||
continue
|
||||
|
||||
# No easy fix, let's skip the test for now
|
||||
@@ -1701,7 +1701,7 @@ class GenerationTesterMixin:
|
||||
# Skip models without explicit support
|
||||
model = model_class(config).to(torch_device).eval()
|
||||
set_model_for_less_flaky_test(model)
|
||||
if "inputs_embeds" not in inspect.signature(model.prepare_inputs_for_generation).parameters.keys():
|
||||
if "inputs_embeds" not in inspect.signature(model.prepare_inputs_for_generation).parameters:
|
||||
continue
|
||||
|
||||
# There are a few exception patterns in this test:
|
||||
@@ -1773,7 +1773,7 @@ class GenerationTesterMixin:
|
||||
self.skipTest(reason="This model is encoder-decoder and has Encoder-Decoder Cache")
|
||||
|
||||
model = model_class(config).to(torch_device).eval()
|
||||
if "inputs_embeds" not in inspect.signature(model.prepare_inputs_for_generation).parameters.keys():
|
||||
if "inputs_embeds" not in inspect.signature(model.prepare_inputs_for_generation).parameters:
|
||||
self.skipTest(reason="This model does not support `inputs_embeds` in generation")
|
||||
|
||||
input_ids = inputs_dict.pop("input_ids")
|
||||
@@ -1929,7 +1929,7 @@ class GenerationTesterMixin:
|
||||
|
||||
model = model_class(config).to(torch_device).eval()
|
||||
|
||||
if "inputs_embeds" not in inspect.signature(model.prepare_inputs_for_generation).parameters.keys():
|
||||
if "inputs_embeds" not in inspect.signature(model.prepare_inputs_for_generation).parameters:
|
||||
self.skipTest(reason="This model does not support `inputs_embeds` in generation")
|
||||
|
||||
# If "past_key_values" is not returned, skip the test (e.g. RWKV uses a different cache name and format)
|
||||
|
||||
Reference in New Issue
Block a user