"tests/python/vscode:/vscode.git/clone" did not exist on "51ff82552150812a4135de88a16302e15baa1f89"
Unverified Commit 1d7b4b60 authored by Pedro Cuenca's avatar Pedro Cuenca Committed by GitHub
Browse files

Ruff: apply same rules as in transformers (#2827)

* Apply same ruff settings as in transformers

See https://github.com/huggingface/transformers/blob/main/pyproject.toml

Co-authored-by: default avatarAaron Gokaslan <aaronGokaslan@gmail.com>

* Apply new style rules

* Style
Co-authored-by: default avatarAaron Gokaslan <aaronGokaslan@gmail.com>

* style

* remove list, ruff wouldn't auto fix.

---------
Co-authored-by: default avatarAaron Gokaslan <aaronGokaslan@gmail.com>
parent abb22b4e
...@@ -84,7 +84,7 @@ class BaseOutput(OrderedDict): ...@@ -84,7 +84,7 @@ class BaseOutput(OrderedDict):
def __getitem__(self, k): def __getitem__(self, k):
if isinstance(k, str): if isinstance(k, str):
inner_dict = {k: v for (k, v) in self.items()} inner_dict = dict(self.items())
return inner_dict[k] return inner_dict[k]
else: else:
return self.to_tuple()[k] return self.to_tuple()[k]
......
...@@ -43,7 +43,7 @@ def clean_doc_toc(doc_list): ...@@ -43,7 +43,7 @@ def clean_doc_toc(doc_list):
new_doc = [] new_doc = []
for duplicate_key in duplicates: for duplicate_key in duplicates:
titles = list(set(doc["title"] for doc in doc_list if doc["local"] == duplicate_key)) titles = list({doc["title"] for doc in doc_list if doc["local"] == duplicate_key})
if len(titles) > 1: if len(titles) > 1:
raise ValueError( raise ValueError(
f"{duplicate_key} is present several times in the documentation table of content at " f"{duplicate_key} is present several times in the documentation table of content at "
......
...@@ -219,7 +219,7 @@ def check_model_list(): ...@@ -219,7 +219,7 @@ def check_model_list():
# Get the models from the directory structure of `src/transformers/models/` # Get the models from the directory structure of `src/transformers/models/`
models = [model for model in dir(diffusers.models) if not model.startswith("__")] models = [model for model in dir(diffusers.models) if not model.startswith("__")]
missing_models = sorted(list(set(_models).difference(models))) missing_models = sorted(set(_models).difference(models))
if missing_models: if missing_models:
raise Exception( raise Exception(
f"The following models should be included in {models_dir}/__init__.py: {','.join(missing_models)}." f"The following models should be included in {models_dir}/__init__.py: {','.join(missing_models)}."
...@@ -429,7 +429,7 @@ def get_all_auto_configured_models(): ...@@ -429,7 +429,7 @@ def get_all_auto_configured_models():
for attr_name in dir(diffusers.models.auto.modeling_flax_auto): for attr_name in dir(diffusers.models.auto.modeling_flax_auto):
if attr_name.startswith("FLAX_MODEL_") and attr_name.endswith("MAPPING_NAMES"): if attr_name.startswith("FLAX_MODEL_") and attr_name.endswith("MAPPING_NAMES"):
result = result | set(get_values(getattr(diffusers.models.auto.modeling_flax_auto, attr_name))) result = result | set(get_values(getattr(diffusers.models.auto.modeling_flax_auto, attr_name)))
return [cls for cls in result] return list(result)
def ignore_unautoclassed(model_name): def ignore_unautoclassed(model_name):
......
...@@ -67,7 +67,7 @@ def overwrite_file(file, class_name, test_name, correct_line, done_test): ...@@ -67,7 +67,7 @@ def overwrite_file(file, class_name, test_name, correct_line, done_test):
def main(correct, fail=None): def main(correct, fail=None):
if fail is not None: if fail is not None:
with open(fail, "r") as f: with open(fail, "r") as f:
test_failures = set([l.strip() for l in f.readlines()]) test_failures = {l.strip() for l in f.readlines()}
else: else:
test_failures = None test_failures = None
......
...@@ -38,7 +38,7 @@ def main(): ...@@ -38,7 +38,7 @@ def main():
open_issues = repo.get_issues(state="open") open_issues = repo.get_issues(state="open")
for issue in open_issues: for issue in open_issues:
comments = sorted([comment for comment in issue.get_comments()], key=lambda i: i.created_at, reverse=True) comments = sorted(issue.get_comments(), key=lambda i: i.created_at, reverse=True)
last_comment = comments[0] if len(comments) > 0 else None last_comment = comments[0] if len(comments) > 0 else None
if ( if (
last_comment is not None last_comment is not None
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment