"vscode:/vscode.git/clone" did not exist on "08b7e4a28232c71b97a5e1fc90d50be9a8e6c6f1"
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):
def __getitem__(self, k):
if isinstance(k, str):
inner_dict = {k: v for (k, v) in self.items()}
inner_dict = dict(self.items())
return inner_dict[k]
else:
return self.to_tuple()[k]
......
......@@ -43,7 +43,7 @@ def clean_doc_toc(doc_list):
new_doc = []
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:
raise ValueError(
f"{duplicate_key} is present several times in the documentation table of content at "
......
......@@ -219,7 +219,7 @@ def check_model_list():
# Get the models from the directory structure of `src/transformers/models/`
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:
raise Exception(
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():
for attr_name in dir(diffusers.models.auto.modeling_flax_auto):
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)))
return [cls for cls in result]
return list(result)
def ignore_unautoclassed(model_name):
......
......@@ -67,7 +67,7 @@ def overwrite_file(file, class_name, test_name, correct_line, done_test):
def main(correct, fail=None):
if fail is not None:
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:
test_failures = None
......
......@@ -38,7 +38,7 @@ def main():
open_issues = repo.get_issues(state="open")
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
if (
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