Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX]Ruff: lint errors for E731 #13018

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion api/.ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ ignore = [
"E712", # true-false-comparison
"E721", # type-comparison
"E722", # bare-except
"E731", # lambda-assignment
"F821", # undefined-name
"F841", # unused-variable
"FURB113", # repeated-append
Expand Down
5 changes: 2 additions & 3 deletions api/core/tools/tool_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,9 +464,8 @@ def user_list_providers(
db.session.query(BuiltinToolProvider).filter(BuiltinToolProvider.tenant_id == tenant_id).all()
)

find_db_builtin_provider = lambda provider: next(
(x for x in db_builtin_providers if x.provider == provider), None
)
def find_db_builtin_provider(provider):
return next((x for x in db_builtin_providers if x.provider == provider), None)

# append builtin providers
for provider in builtin_providers:
Expand Down
22 changes: 12 additions & 10 deletions api/models/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,12 @@ def environment_variables(self) -> Sequence[Variable]:
]

# decrypt secret variables value
decrypt_func = (
lambda var: var.model_copy(update={"value": encrypter.decrypt_token(tenant_id=tenant_id, token=var.value)})
if isinstance(var, SecretVariable)
else var
)
def decrypt_func(var):
if isinstance(var, SecretVariable):
return var.model_copy(update={"value": encrypter.decrypt_token(tenant_id=tenant_id, token=var.value)})
else:
return var

results = list(map(decrypt_func, results))
return results

Expand All @@ -277,11 +278,12 @@ def environment_variables(self, value: Sequence[Variable]):
value[i] = origin_variables_dictionary[variable.id].model_copy(update={"name": variable.name})

# encrypt secret variables value
encrypt_func = (
lambda var: var.model_copy(update={"value": encrypter.encrypt_token(tenant_id=tenant_id, token=var.value)})
if isinstance(var, SecretVariable)
else var
)
def encrypt_func(var):
if isinstance(var, SecretVariable):
return var.model_copy(update={"value": encrypter.encrypt_token(tenant_id=tenant_id, token=var.value)})
else:
return var

encrypted_vars = list(map(encrypt_func, value))
environment_variables_json = json.dumps(
{var.name: var.model_dump() for var in encrypted_vars},
Expand Down
5 changes: 2 additions & 3 deletions api/services/tools/builtin_tools_manage_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,8 @@ def list_builtin_tools(user_id: str, tenant_id: str) -> list[UserToolProvider]:
)

# find provider
find_provider = lambda provider: next(
filter(lambda db_provider: db_provider.provider == provider, db_providers), None
)
def find_provider(provider):
return next(filter(lambda db_provider: db_provider.provider == provider, db_providers), None)

result: list[UserToolProvider] = []

Expand Down