Skip to content

Commit 3465fdb

Browse files
Format backend with latest ruff (#10470)
* format * add changeset * more ruff * changes * update --------- Co-authored-by: gradio-pr-bot <[email protected]>
1 parent ef66fe5 commit 3465fdb

File tree

16 files changed

+62
-50
lines changed

16 files changed

+62
-50
lines changed

.changeset/dirty-ads-yell.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"gradio": minor
3+
"gradio_client": minor
4+
---
5+
6+
feat:Format backend with latest `ruff`

client/python/gradio_client/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ def _render_endpoints_info(
764764
default_value = info.get("parameter_default")
765765
default_value = utils.traverse(
766766
default_value,
767-
lambda x: f"handle_file(\"{x['url']}\")",
767+
lambda x: f'handle_file("{x["url"]}")',
768768
utils.is_file_obj_with_meta,
769769
)
770770
default_info = (
@@ -996,7 +996,7 @@ def deploy_discord(
996996
space_id = huggingface_hub.get_full_repo_name(to_id, token=hf_token)
997997
else:
998998
if self.space_id:
999-
space_id = f'{self.space_id.split("/")[1]}-gradio-discord-bot'
999+
space_id = f"{self.space_id.split('/')[1]}-gradio-discord-bot"
10001000
else:
10011001
space_id = f"gradio-discord-bot-{secrets.token_hex(4)}"
10021002
space_id = huggingface_hub.get_full_repo_name(space_id, token=hf_token)

client/python/gradio_client/documentation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,13 +336,13 @@ def generate_documentation():
336336
classes_inherit_documentation[cls] = cls_documentation["fns"]
337337
for mode, class_list in classes_to_document.items():
338338
for i, (cls, _) in enumerate(class_list):
339-
for super_class in classes_inherit_documentation:
339+
for super_class, fns in classes_inherit_documentation.items():
340340
if (
341341
inspect.isclass(cls)
342342
and issubclass(cls, super_class)
343343
and cls != super_class
344344
):
345-
for inherited_fn in classes_inherit_documentation[super_class]:
345+
for inherited_fn in fns:
346346
inherited_fn = dict(inherited_fn)
347347
try:
348348
inherited_fn["description"] = extract_instance_attr_doc(

gradio/blocks.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2826,8 +2826,7 @@ def integrate(
28262826
)
28272827
else:
28282828
print(
2829-
"The WandB integration requires you to "
2830-
"`launch(share=True)` first."
2829+
"The WandB integration requires you to `launch(share=True)` first."
28312830
)
28322831
if mlflow is not None:
28332832
analytics_integration = "MLFlow"

gradio/cli/commands/components/_docs_utils.py

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -689,17 +689,21 @@ def render_class_docs(exports, docs):
689689
### Initialization
690690
\"\"\", elem_classes=["md-custom"], header_links=True)
691691
692-
gr.ParamViewer(value=_docs["{class_name}"]["members"]["__init__"], linkify={list(linkify.keys())})
692+
gr.ParamViewer(value=_docs["{class_name}"]["members"]["__init__"], linkify={
693+
list(linkify.keys())
694+
})
693695
694696
{render_class_events(docs[class_name].get("events", None), class_name)}
695697
696-
{make_user_fn(
697-
class_name,
698-
user_fn_input_type,
699-
user_fn_input_description,
700-
user_fn_output_type,
701-
user_fn_output_description,
702-
)}
698+
{
699+
make_user_fn(
700+
class_name,
701+
user_fn_input_type,
702+
user_fn_input_description,
703+
user_fn_output_type,
704+
user_fn_output_description,
705+
)
706+
}
703707
"""
704708
return docs_classes
705709

@@ -752,7 +756,7 @@ def render_param_table(params):
752756
753757
</td>
754758
<td align="left"><code>{param["default"]}</code></td>
755-
<td align="left">{param['description']}</td>
759+
<td align="left">{param["description"]}</td>
756760
</tr>
757761
"""
758762
return table + "</tbody></table>"
@@ -783,12 +787,14 @@ def render_class_docs_markdown(exports, docs):
783787
784788
{render_class_events_markdown(docs[class_name].get("events", None))}
785789
786-
{make_user_fn_markdown(
787-
user_fn_input_type,
788-
user_fn_input_description,
789-
user_fn_output_type,
790-
user_fn_output_description,
791-
)}
790+
{
791+
make_user_fn_markdown(
792+
user_fn_input_type,
793+
user_fn_input_description,
794+
user_fn_output_type,
795+
user_fn_output_description,
796+
)
797+
}
792798
"""
793799
return docs_classes
794800

@@ -873,7 +879,7 @@ def make_space(
873879
{docs_classes}
874880
875881
{render_additional_interfaces(docs["__meta__"]["additional_interfaces"])}
876-
demo.load(None, js=r\"\"\"{make_js(get_deep(docs, ["__meta__", "additional_interfaces"]),get_deep( docs, ["__meta__", "user_fn_refs"]))}
882+
demo.load(None, js=r\"\"\"{make_js(get_deep(docs, ["__meta__", "additional_interfaces"]), get_deep(docs, ["__meta__", "user_fn_refs"]))}
877883
\"\"\")
878884
879885
demo.launch()

gradio/components/video.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ async def combine_stream(
521521
command = [
522522
"ffmpeg",
523523
"-i",
524-
f'concat:{"|".join(ts_files)}',
524+
f"concat:{'|'.join(ts_files)}",
525525
"-y",
526526
"-safe",
527527
"0",

gradio/external.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ def custom_post_binary(data):
316316
elif p == "zero-shot-classification":
317317
inputs = [
318318
components.Textbox(label="Input"),
319-
components.Textbox(label="Possible class names (" "comma-separated)"),
319+
components.Textbox(label="Possible class names (comma-separated)"),
320320
components.Checkbox(label="Allow multiple true classes"),
321321
]
322322
outputs = components.Label(label="Classification")

gradio/interface.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -809,18 +809,18 @@ def attach_clear_events(
809809
None,
810810
[],
811811
([input_component_column] if input_component_column else []), # type: ignore
812-
js=f"""() => {json.dumps(
813-
814-
[{'variant': None, 'visible': True, '__type__': 'update'}]
812+
js=f"""() => {
813+
json.dumps(
814+
[{"variant": None, "visible": True, "__type__": "update"}]
815815
if self.interface_type
816-
in [
817-
InterfaceTypes.STANDARD,
818-
InterfaceTypes.INPUT_ONLY,
819-
InterfaceTypes.UNIFIED,
820-
]
816+
in [
817+
InterfaceTypes.STANDARD,
818+
InterfaceTypes.INPUT_ONLY,
819+
InterfaceTypes.UNIFIED,
820+
]
821821
else []
822-
823-
)}
822+
)
823+
}
824824
""",
825825
)
826826

gradio/processing_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ def _add_root_url(file_dict: dict):
648648
file_dict["url"] = file_dict["url"][len(previous_root_url) :]
649649
elif client_utils.is_http_url_like(file_dict["url"]):
650650
return file_dict
651-
file_dict["url"] = f'{root_url}{file_dict["url"]}'
651+
file_dict["url"] = f"{root_url}{file_dict['url']}"
652652
return file_dict
653653

654654
return client_utils.traverse(data, _add_root_url, client_utils.is_file_obj_with_url)

gradio/route_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ def on_headers_finished(self) -> None:
590590
)
591591
except KeyError as e:
592592
raise MultiPartException(
593-
'The Content-Disposition header field "name" must be ' "provided."
593+
'The Content-Disposition header field "name" must be provided.'
594594
) from e
595595
if b"filename" in options:
596596
self._current_files += 1

0 commit comments

Comments
 (0)