mirror of
https://github.com/langflow-ai/langflow.git
synced 2026-07-25 16:43:27 +08:00
fix: Resolve ruff check failures in lfx deployment service (#11992)
* fix: Improve message formatting in DeploymentNotConfiguredError * fix: Change ValueError to TypeError for invalid flow nodes and edges * fix: Add noqa comments to suppress ARG002 warnings for unused function arguments * fix: Update exception raising in tests to improve clarity and suppress linting warnings * fix: Change TypeError to ValueError so pydantic recognizes the error
This commit is contained in:
committed by
GitHub
parent
91219be56c
commit
5a18aaadcd
@ -129,7 +129,8 @@ class DeploymentNotConfiguredError(DeploymentError):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
message: str = "No deployment adapter is registered. Register a concrete adapter to enable deployment operations.",
|
||||
message: str = "No deployment adapter is registered. "
|
||||
"Register a concrete adapter to enable deployment operations.",
|
||||
*,
|
||||
method: str | None = None,
|
||||
cause: Exception | None = None,
|
||||
|
||||
@ -57,10 +57,10 @@ class BaseFlowArtifact(BaseModel):
|
||||
raise ValueError(msg)
|
||||
if not isinstance(value["nodes"], list):
|
||||
msg = "Flow 'nodes' must be a list"
|
||||
raise ValueError(msg)
|
||||
raise ValueError(msg) # noqa: TRY004
|
||||
if not isinstance(value["edges"], list):
|
||||
msg = "Flow 'edges' must be a list"
|
||||
raise ValueError(msg)
|
||||
raise ValueError(msg) # noqa: TRY004
|
||||
return value
|
||||
|
||||
|
||||
|
||||
@ -47,9 +47,9 @@ class DeploymentService(BaseDeploymentService):
|
||||
async def create(
|
||||
self,
|
||||
*,
|
||||
user_id: IdLike,
|
||||
payload: DeploymentCreate,
|
||||
db: AsyncSession,
|
||||
user_id: IdLike, # noqa: ARG002
|
||||
payload: DeploymentCreate, # noqa: ARG002
|
||||
db: AsyncSession, # noqa: ARG002
|
||||
) -> DeploymentCreateResult:
|
||||
"""Create a new deployment in the provider."""
|
||||
raise DeploymentNotConfiguredError(method="create")
|
||||
@ -57,8 +57,8 @@ class DeploymentService(BaseDeploymentService):
|
||||
async def list_types(
|
||||
self,
|
||||
*,
|
||||
user_id: IdLike,
|
||||
db: AsyncSession,
|
||||
user_id: IdLike, # noqa: ARG002
|
||||
db: AsyncSession, # noqa: ARG002
|
||||
) -> DeploymentListTypesResult:
|
||||
"""List deployment types supported by the provider."""
|
||||
raise DeploymentNotConfiguredError(method="list_types")
|
||||
@ -66,9 +66,9 @@ class DeploymentService(BaseDeploymentService):
|
||||
async def list(
|
||||
self,
|
||||
*,
|
||||
user_id: IdLike,
|
||||
params: DeploymentListParams | None = None,
|
||||
db: AsyncSession,
|
||||
user_id: IdLike, # noqa: ARG002
|
||||
params: DeploymentListParams | None = None, # noqa: ARG002
|
||||
db: AsyncSession, # noqa: ARG002
|
||||
) -> DeploymentListResult:
|
||||
"""List deployments visible to this adapter."""
|
||||
raise DeploymentNotConfiguredError(method="list")
|
||||
@ -76,9 +76,9 @@ class DeploymentService(BaseDeploymentService):
|
||||
async def get(
|
||||
self,
|
||||
*,
|
||||
user_id: IdLike,
|
||||
deployment_id: IdLike,
|
||||
db: AsyncSession,
|
||||
user_id: IdLike, # noqa: ARG002
|
||||
deployment_id: IdLike, # noqa: ARG002
|
||||
db: AsyncSession, # noqa: ARG002
|
||||
) -> DeploymentGetResult:
|
||||
"""Return deployment metadata by provider ID."""
|
||||
raise DeploymentNotConfiguredError(method="get")
|
||||
@ -86,10 +86,10 @@ class DeploymentService(BaseDeploymentService):
|
||||
async def update(
|
||||
self,
|
||||
*,
|
||||
user_id: IdLike,
|
||||
deployment_id: IdLike,
|
||||
payload: DeploymentUpdate,
|
||||
db: AsyncSession,
|
||||
user_id: IdLike, # noqa: ARG002
|
||||
deployment_id: IdLike, # noqa: ARG002
|
||||
payload: DeploymentUpdate, # noqa: ARG002
|
||||
db: AsyncSession, # noqa: ARG002
|
||||
) -> DeploymentUpdateResult:
|
||||
"""Update deployment inputs and apply changes in the provider."""
|
||||
raise DeploymentNotConfiguredError(method="update")
|
||||
@ -97,9 +97,9 @@ class DeploymentService(BaseDeploymentService):
|
||||
async def redeploy(
|
||||
self,
|
||||
*,
|
||||
user_id: IdLike,
|
||||
deployment_id: IdLike,
|
||||
db: AsyncSession,
|
||||
user_id: IdLike, # noqa: ARG002
|
||||
deployment_id: IdLike, # noqa: ARG002
|
||||
db: AsyncSession, # noqa: ARG002
|
||||
) -> RedeployResult:
|
||||
"""Re-apply current deployment inputs without changing them."""
|
||||
raise DeploymentNotConfiguredError(method="redeploy")
|
||||
@ -107,9 +107,9 @@ class DeploymentService(BaseDeploymentService):
|
||||
async def duplicate(
|
||||
self,
|
||||
*,
|
||||
user_id: IdLike,
|
||||
deployment_id: IdLike,
|
||||
db: AsyncSession,
|
||||
user_id: IdLike, # noqa: ARG002
|
||||
deployment_id: IdLike, # noqa: ARG002
|
||||
db: AsyncSession, # noqa: ARG002
|
||||
) -> DeploymentDuplicateResult:
|
||||
"""Create a new deployment using the same inputs as the source."""
|
||||
raise DeploymentNotConfiguredError(method="duplicate")
|
||||
@ -117,9 +117,9 @@ class DeploymentService(BaseDeploymentService):
|
||||
async def delete(
|
||||
self,
|
||||
*,
|
||||
user_id: IdLike,
|
||||
deployment_id: IdLike,
|
||||
db: AsyncSession,
|
||||
user_id: IdLike, # noqa: ARG002
|
||||
deployment_id: IdLike, # noqa: ARG002
|
||||
db: AsyncSession, # noqa: ARG002
|
||||
) -> DeploymentDeleteResult:
|
||||
"""Delete the deployment from the provider."""
|
||||
raise DeploymentNotConfiguredError(method="delete")
|
||||
@ -127,9 +127,9 @@ class DeploymentService(BaseDeploymentService):
|
||||
async def get_status(
|
||||
self,
|
||||
*,
|
||||
user_id: IdLike,
|
||||
deployment_id: IdLike,
|
||||
db: AsyncSession,
|
||||
user_id: IdLike, # noqa: ARG002
|
||||
deployment_id: IdLike, # noqa: ARG002
|
||||
db: AsyncSession, # noqa: ARG002
|
||||
) -> DeploymentStatusResult:
|
||||
"""Return provider-reported health/status for the deployment."""
|
||||
raise DeploymentNotConfiguredError(method="get_status")
|
||||
@ -137,9 +137,9 @@ class DeploymentService(BaseDeploymentService):
|
||||
async def create_execution(
|
||||
self,
|
||||
*,
|
||||
user_id: IdLike,
|
||||
payload: ExecutionCreate,
|
||||
db: AsyncSession,
|
||||
user_id: IdLike, # noqa: ARG002
|
||||
payload: ExecutionCreate, # noqa: ARG002
|
||||
db: AsyncSession, # noqa: ARG002
|
||||
) -> ExecutionCreateResult:
|
||||
"""Run a provider-agnostic deployment execution."""
|
||||
raise DeploymentNotConfiguredError(method="create_execution")
|
||||
@ -147,9 +147,9 @@ class DeploymentService(BaseDeploymentService):
|
||||
async def get_execution(
|
||||
self,
|
||||
*,
|
||||
user_id: IdLike,
|
||||
execution_id: IdLike,
|
||||
db: AsyncSession,
|
||||
user_id: IdLike, # noqa: ARG002
|
||||
execution_id: IdLike, # noqa: ARG002
|
||||
db: AsyncSession, # noqa: ARG002
|
||||
) -> ExecutionStatusResult:
|
||||
"""Get provider-agnostic deployment execution state/output."""
|
||||
raise DeploymentNotConfiguredError(method="get_execution")
|
||||
|
||||
@ -143,9 +143,9 @@ def test_deployment_not_configured_default_message() -> None:
|
||||
|
||||
def test_auth_errors_not_caught_by_deployment_error() -> None:
|
||||
"""Ensure except DeploymentError does NOT catch auth failures."""
|
||||
with pytest.raises(AuthenticationError):
|
||||
with pytest.raises(AuthenticationError): # noqa: PT012
|
||||
try:
|
||||
raise CredentialResolutionError()
|
||||
raise CredentialResolutionError
|
||||
except DeploymentError:
|
||||
pytest.fail("DeploymentError should not catch AuthenticationError")
|
||||
|
||||
@ -153,9 +153,9 @@ def test_auth_errors_not_caught_by_deployment_error() -> None:
|
||||
def test_deployment_service_error_catches_both_hierarchies() -> None:
|
||||
"""DeploymentServiceError catches both deployment and auth errors."""
|
||||
with pytest.raises(DeploymentServiceError):
|
||||
raise CredentialResolutionError()
|
||||
raise CredentialResolutionError
|
||||
with pytest.raises(DeploymentServiceError):
|
||||
raise DeploymentNotFoundError()
|
||||
raise DeploymentNotFoundError
|
||||
|
||||
|
||||
def test_package_exports_base_and_error() -> None:
|
||||
|
||||
Reference in New Issue
Block a user