mirror of
https://github.com/gradio-app/gradio.git
synced 2024-11-21 01:01:05 +08:00
upgrade ruff
test dependency to ruff==0.4.1
(#8100)
* upgrade ruff==0.4.1 * add changeset * add changeset --------- Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
This commit is contained in:
parent
32cfa614d6
commit
cbdfbdfc97
6
.changeset/dry-trees-end.md
Normal file
6
.changeset/dry-trees-end.md
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
"gradio": patch
|
||||
"gradio_client": patch
|
||||
---
|
||||
|
||||
feat:upgrade `ruff` test dependency to `ruff==0.4.1`
|
@ -1,4 +1,5 @@
|
||||
"""The main Client class for the Python client."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import concurrent.futures
|
||||
@ -154,9 +155,9 @@ class Client:
|
||||
self._login(auth)
|
||||
|
||||
self.config = self._get_config()
|
||||
self.protocol: Literal[
|
||||
"ws", "sse", "sse_v1", "sse_v2", "sse_v2.1"
|
||||
] = self.config.get("protocol", "ws")
|
||||
self.protocol: Literal["ws", "sse", "sse_v1", "sse_v2", "sse_v2.1"] = (
|
||||
self.config.get("protocol", "ws")
|
||||
)
|
||||
self.api_url = urllib.parse.urljoin(self.src, utils.API_URL)
|
||||
self.sse_url = urllib.parse.urljoin(
|
||||
self.src, utils.SSE_URL_V0 if self.protocol == "sse" else utils.SSE_URL
|
||||
|
@ -1,4 +1,5 @@
|
||||
""" This module contains the EndpointV3Compatibility class, which is used to connect to Gradio apps running 3.x.x versions of Gradio."""
|
||||
"""This module contains the EndpointV3Compatibility class, which is used to connect to Gradio apps running 3.x.x versions of Gradio."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
|
@ -1,4 +1,5 @@
|
||||
"""Included for backwards compatibility with 3.x spaces/apps."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
|
@ -1,6 +1,6 @@
|
||||
pytest-asyncio
|
||||
pytest==7.1.2
|
||||
ruff==0.2.2
|
||||
ruff==0.4.1
|
||||
pyright==1.1.327
|
||||
gradio
|
||||
pydub==0.25.1
|
||||
|
@ -1,4 +1,5 @@
|
||||
""" Functions related to analytics and telemetry. """
|
||||
"""Functions related to analytics and telemetry."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
|
@ -2210,9 +2210,9 @@ Received outputs:
|
||||
self.server_name = server_name
|
||||
self.local_url = local_url
|
||||
self.server_port = server_port
|
||||
self.server_app = (
|
||||
self.app
|
||||
) = app # server_app is included for backwards compatibility
|
||||
self.server_app = self.app = (
|
||||
app # server_app is included for backwards compatibility
|
||||
)
|
||||
self.server = server
|
||||
self.is_running = True
|
||||
self.is_colab = utils.colab_check()
|
||||
|
@ -2,7 +2,6 @@
|
||||
This file defines a useful high-level abstraction to build Gradio chatbots: ChatInterface.
|
||||
"""
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import inspect
|
||||
|
@ -1,6 +1,7 @@
|
||||
""" This file is the part of 'gradio/cli.py' for printing the environment info
|
||||
"""This file is the part of 'gradio/cli.py' for printing the environment info
|
||||
for the cli command 'gradio environment'
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import platform
|
||||
|
@ -382,10 +382,10 @@ def extract_docstrings(module):
|
||||
|
||||
# We just want to normalise the arg name to 'value' for the preprocess and postprocess methods
|
||||
if member_name in ("postprocess", "preprocess"):
|
||||
docs[name]["members"][member_name][
|
||||
"value"
|
||||
] = find_first_non_return_key(
|
||||
docs[name]["members"][member_name]
|
||||
docs[name]["members"][member_name]["value"] = (
|
||||
find_first_non_return_key(
|
||||
docs[name]["members"][member_name]
|
||||
)
|
||||
)
|
||||
additional_refs = get_deep(
|
||||
docs, ["__meta__", "user_fn_refs", name]
|
||||
|
@ -5,6 +5,7 @@ Contains the functions that run when `gradio` is called from the command line. S
|
||||
$ gradio app.py, to run app.py in reload mode where any changes in the app.py file or Gradio library reloads the demo.
|
||||
$ gradio app.py my_demo, to use variable names other than "demo"
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import inspect
|
||||
|
@ -295,10 +295,10 @@ class Audio(
|
||||
# strip length information from first chunk header, remove headers entirely from subsequent chunks
|
||||
if first_chunk:
|
||||
binary_data = (
|
||||
binary_data[:4] + b"\xFF\xFF\xFF\xFF" + binary_data[8:]
|
||||
binary_data[:4] + b"\xff\xff\xff\xff" + binary_data[8:]
|
||||
)
|
||||
binary_data = (
|
||||
binary_data[:40] + b"\xFF\xFF\xFF\xFF" + binary_data[44:]
|
||||
binary_data[:40] + b"\xff\xff\xff\xff" + binary_data[44:]
|
||||
)
|
||||
else:
|
||||
binary_data = binary_data[44:]
|
||||
|
@ -1,4 +1,4 @@
|
||||
""" Predefined buttons with bound events that can be included in a gr.Blocks for convenience. """
|
||||
"""Predefined buttons with bound events that can be included in a gr.Blocks for convenience."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
""" Predefined buttons with bound events that can be included in a gr.Blocks for convenience. """
|
||||
"""Predefined buttons with bound events that can be included in a gr.Blocks for convenience."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
"""Predefined button to sign out from Hugging Face in a Gradio Space."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import warnings
|
||||
|
@ -90,12 +90,12 @@ class PredictBody(BaseModel):
|
||||
fn_index: Optional[int] = None
|
||||
trigger_id: Optional[int] = None
|
||||
simple_format: bool = False
|
||||
batched: Optional[
|
||||
bool
|
||||
] = False # Whether the data is a batch of samples (i.e. called from the queue if batch=True) or a single sample (i.e. called from the UI)
|
||||
request: Optional[
|
||||
Request
|
||||
] = None # dictionary of request headers, query parameters, url, etc. (used to to pass in request for queuing)
|
||||
batched: Optional[bool] = (
|
||||
False # Whether the data is a batch of samples (i.e. called from the queue if batch=True) or a single sample (i.e. called from the UI)
|
||||
)
|
||||
request: Optional[Request] = (
|
||||
None # dictionary of request headers, query parameters, url, etc. (used to to pass in request for queuing)
|
||||
)
|
||||
|
||||
|
||||
class ResetBody(BaseModel):
|
||||
|
@ -2,6 +2,7 @@
|
||||
Defines helper methods useful for setting up ports, launching servers, and
|
||||
creating tunnels.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
|
@ -88,9 +88,9 @@ class Queue:
|
||||
block_fns: list[BlockFunction],
|
||||
default_concurrency_limit: int | None | Literal["not_set"] = "not_set",
|
||||
):
|
||||
self.pending_messages_per_session: LRUCache[
|
||||
str, ThreadQueue[EventMessage]
|
||||
] = LRUCache(2000)
|
||||
self.pending_messages_per_session: LRUCache[str, ThreadQueue[EventMessage]] = (
|
||||
LRUCache(2000)
|
||||
)
|
||||
self.pending_event_ids_session: dict[str, set[str]] = {}
|
||||
self.pending_message_lock = safe_get_lock()
|
||||
self.event_queue_per_concurrency_id: dict[str, EventQueue] = {}
|
||||
|
@ -86,9 +86,9 @@ class RangedFileResponse(Response):
|
||||
raise ValueError("No stat result to set range headers with")
|
||||
total_length = self.stat_result.st_size
|
||||
content_length = len(range)
|
||||
self.headers[
|
||||
"content-range"
|
||||
] = f"bytes {range.start}-{range.end}/{total_length}"
|
||||
self.headers["content-range"] = (
|
||||
f"bytes {range.start}-{range.end}/{total_length}"
|
||||
)
|
||||
self.headers["content-length"] = str(content_length)
|
||||
pass
|
||||
|
||||
|
@ -4,6 +4,6 @@ cd "$(dirname ${0})/.."
|
||||
|
||||
echo "Formatting the backend... Our style follows the ruff code style."
|
||||
python -c "import gradio"
|
||||
python -m ruff --fix gradio test client
|
||||
python -m ruff check --fix gradio test client
|
||||
python -m ruff format gradio test client
|
||||
bash scripts/type_check_backend.sh
|
@ -269,7 +269,7 @@ rfc3986[idna2008]==1.5.0
|
||||
# rfc3986
|
||||
rich==13.7.0
|
||||
# via typer
|
||||
ruff==0.2.2
|
||||
ruff==0.4.1
|
||||
# via
|
||||
# -r requirements.in
|
||||
# gradio
|
||||
|
@ -2,6 +2,7 @@
|
||||
This suite of tests is designed to ensure compatibility between the current version of Gradio
|
||||
with custom components created using the previous version of Gradio.
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from gradio_pdf import PDF
|
||||
|
@ -1,4 +1,5 @@
|
||||
"""Contains tests for networking.py and app.py"""
|
||||
|
||||
import functools
|
||||
import os
|
||||
import tempfile
|
||||
|
Loading…
Reference in New Issue
Block a user