ref: Apply ruff rule RUF052 (#5089)

Apply ruff rule RUF052
This commit is contained in:
Christophe Bornet 2024-12-08 12:51:02 +01:00 • committed by GitHub
commit 0b39554795
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
57 changed files with 351 additions and 359 deletions

View file

@ -222,13 +222,13 @@ def distributed_client_fixture(
monkeypatch.undo()
def get_graph(_type="basic"):
def get_graph(type_="basic"):
"""Get a graph from a json file."""
if _type == "basic":
if type_ == "basic":
path = pytest.BASIC_EXAMPLE_PATH
elif _type == "complex":
elif type_ == "complex":
path = pytest.COMPLEX_EXAMPLE_PATH
elif _type == "openapi":
elif type_ == "openapi":
path = pytest.OPENAPI_EXAMPLE_PATH
with path.open(encoding="utf-8") as f:

View file

@ -43,10 +43,10 @@ async def test_delete_api_key_route(client: AsyncClient, logged_in_headers, acti
"api_key": "string",
"user_id": str(active_user.id),
}
_response = await client.post("api/v1/api_key/", json=basic_case, headers=logged_in_headers)
_id = _response.json()["id"]
response_ = await client.post("api/v1/api_key/", json=basic_case, headers=logged_in_headers)
id_ = response_.json()["id"]
response = await client.delete(f"api/v1/api_key/{_id}", headers=logged_in_headers)
response = await client.delete(f"api/v1/api_key/{id_}", headers=logged_in_headers)
result = response.json()
assert response.status_code == status.HTTP_200_OK

View file

@ -69,9 +69,9 @@ async def test_read_flow(client: AsyncClient, logged_in_headers):
"user_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"folder_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
}
_response = await client.post("api/v1/flows/", json=basic_case, headers=logged_in_headers)
_id = _response.json()["id"]
response = await client.get(f"api/v1/flows/{_id}", headers=logged_in_headers)
response_ = await client.post("api/v1/flows/", json=basic_case, headers=logged_in_headers)
id_ = response_.json()["id"]
response = await client.get(f"api/v1/flows/{id_}", headers=logged_in_headers)
result = response.json()
assert response.status_code == status.HTTP_200_OK
@ -109,11 +109,11 @@ async def test_update_flow(client: AsyncClient, logged_in_headers):
"folder_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
}
basic_case["name"] = name
_response = await client.post("api/v1/flows/", json=basic_case, headers=logged_in_headers)
_id = _response.json()["id"]
response_ = await client.post("api/v1/flows/", json=basic_case, headers=logged_in_headers)
id_ = response_.json()["id"]
basic_case["name"] = updated_name
response = await client.patch(f"api/v1/flows/{_id}", json=basic_case, headers=logged_in_headers)
response = await client.patch(f"api/v1/flows/{id_}", json=basic_case, headers=logged_in_headers)
result = response.json()
assert isinstance(result, dict), "The result must be a dictionary"

View file

@ -35,9 +35,9 @@ async def test_read_folders(client: AsyncClient, logged_in_headers):
async def test_read_folder(client: AsyncClient, logged_in_headers, basic_case):
_response = await client.post("api/v1/folders/", json=basic_case, headers=logged_in_headers)
_id = _response.json()["id"]
response = await client.get(f"api/v1/folders/{_id}", headers=logged_in_headers)
response_ = await client.post("api/v1/folders/", json=basic_case, headers=logged_in_headers)
id_ = response_.json()["id"]
response = await client.get(f"api/v1/folders/{id_}", headers=logged_in_headers)
result = response.json()
assert response.status_code == status.HTTP_200_OK
@ -51,9 +51,9 @@ async def test_read_folder(client: AsyncClient, logged_in_headers, basic_case):
async def test_update_folder(client: AsyncClient, logged_in_headers, basic_case):
update_case = basic_case.copy()
update_case["name"] = "Updated Folder"
_response = await client.post("api/v1/folders/", json=basic_case, headers=logged_in_headers)
_id = _response.json()["id"]
response = await client.patch(f"api/v1/folders/{_id}", json=update_case, headers=logged_in_headers)
response_ = await client.post("api/v1/folders/", json=basic_case, headers=logged_in_headers)
id_ = response_.json()["id"]
response = await client.patch(f"api/v1/folders/{id_}", json=update_case, headers=logged_in_headers)
result = response.json()
assert response.status_code == status.HTTP_200_OK

View file

@ -49,10 +49,10 @@ async def test_patch_user(client: AsyncClient, logged_in_headers_super_user):
name = "string"
updated_name = "string2"
basic_case = {"username": name, "password": "string"}
_response = await client.post("api/v1/users/", json=basic_case)
_id = _response.json()["id"]
response_ = await client.post("api/v1/users/", json=basic_case)
id_ = response_.json()["id"]
basic_case["username"] = updated_name
response = await client.patch(f"api/v1/users/{_id}", json=basic_case, headers=logged_in_headers_super_user)
response = await client.patch(f"api/v1/users/{id_}", json=basic_case, headers=logged_in_headers_super_user)
result = response.json()
assert response.status_code == status.HTTP_200_OK
@ -69,9 +69,9 @@ async def test_patch_user(client: AsyncClient, logged_in_headers_super_user):
async def test_reset_password(client: AsyncClient, logged_in_headers, active_user):
_id = str(active_user.id)
id_ = str(active_user.id)
basic_case = {"username": "string", "password": "new_password"}
response = await client.patch(f"api/v1/users/{_id}/reset-password", json=basic_case, headers=logged_in_headers)
response = await client.patch(f"api/v1/users/{id_}/reset-password", json=basic_case, headers=logged_in_headers)
result = response.json()
assert response.status_code == status.HTTP_200_OK
@ -88,9 +88,9 @@ async def test_reset_password(client: AsyncClient, logged_in_headers, active_use
async def test_delete_user(client: AsyncClient, logged_in_headers_super_user):
basic_case = {"username": "string", "password": "string"}
_response = await client.post("api/v1/users/", json=basic_case)
_id = _response.json()["id"]
response = await client.delete(f"api/v1/users/{_id}", headers=logged_in_headers_super_user)
response_ = await client.post("api/v1/users/", json=basic_case)
id_ = response_.json()["id"]
response = await client.delete(f"api/v1/users/{id_}", headers=logged_in_headers_super_user)
result = response.json()
assert response.status_code == status.HTTP_200_OK

View file

@ -99,8 +99,8 @@ async def test_get_variable__typeerror(service, session: AsyncSession):
name = "name"
value = "value"
field = "session_id"
_type = CREDENTIAL_TYPE
await service.create_variable(user_id, name, value, _type=_type, session=session)
type_ = CREDENTIAL_TYPE
await service.create_variable(user_id, name, value, type_=type_, session=session)
with pytest.raises(TypeError) as exc:
await session.run_sync(_get_variable, service, user_id, name, field)

View file

@ -194,7 +194,7 @@ def test_url_component():
url_component = data.URLComponent()
url_component.set_attributes({"urls": ["https://langflow.org"]})
# the url component can be used to load the contents of a website
_data = url_component.fetch_content()
assert all(value.data for value in _data)
assert all(value.text for value in _data)
assert all(value.source for value in _data)
data_ = url_component.fetch_content()
assert all(value.data for value in data_)
assert all(value.text for value in data_)
assert all(value.source for value in data_)