chore: add ast-grep rule to convert Optional[T] to T | None (#25560)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
-LAN- 2025-09-15 13:06:33 +08:00 • committed by GitHub
commit bab4975809
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
394 changed files with 2555 additions and 2792 deletions

View file

@ -11,7 +11,7 @@ tenant_id, app_id, triggered_from, etc., which are not part of the core domain m
from collections.abc import Sequence
from datetime import datetime
from typing import Optional, Protocol
from typing import Protocol
from core.workflow.repositories.workflow_node_execution_repository import WorkflowNodeExecutionRepository
from models.workflow import WorkflowNodeExecutionModel
@ -44,7 +44,7 @@ class DifyAPIWorkflowNodeExecutionRepository(WorkflowNodeExecutionRepository, Pr
app_id: str,
workflow_id: str,
node_id: str,
) -> Optional[WorkflowNodeExecutionModel]:
) -> WorkflowNodeExecutionModel | None:
"""
Get the most recent execution for a specific node.
@ -87,8 +87,8 @@ class DifyAPIWorkflowNodeExecutionRepository(WorkflowNodeExecutionRepository, Pr
def get_execution_by_id(
self,
execution_id: str,
tenant_id: Optional[str] = None,
) -> Optional[WorkflowNodeExecutionModel]:
tenant_id: str | None = None,
) -> WorkflowNodeExecutionModel | None:
"""
Get a workflow node execution by its ID.

View file

@ -36,7 +36,7 @@ Example:
from collections.abc import Sequence
from datetime import datetime
from typing import Optional, Protocol
from typing import Protocol
from core.workflow.repositories.workflow_execution_repository import WorkflowExecutionRepository
from libs.infinite_scroll_pagination import InfiniteScrollPagination
@ -58,7 +58,7 @@ class APIWorkflowRunRepository(WorkflowExecutionRepository, Protocol):
app_id: str,
triggered_from: str,
limit: int = 20,
last_id: Optional[str] = None,
last_id: str | None = None,
) -> InfiniteScrollPagination:
"""
Get paginated workflow runs with filtering.
@ -90,7 +90,7 @@ class APIWorkflowRunRepository(WorkflowExecutionRepository, Protocol):
tenant_id: str,
app_id: str,
run_id: str,
) -> Optional[WorkflowRun]:
) -> WorkflowRun | None:
"""
Get a specific workflow run by ID.

View file

@ -7,7 +7,6 @@ using SQLAlchemy 2.0 style queries for WorkflowNodeExecutionModel operations.
from collections.abc import Sequence
from datetime import datetime
from typing import Optional
from sqlalchemy import delete, desc, select
from sqlalchemy.orm import Session, sessionmaker
@ -49,7 +48,7 @@ class DifyAPISQLAlchemyWorkflowNodeExecutionRepository(DifyAPIWorkflowNodeExecut
app_id: str,
workflow_id: str,
node_id: str,
) -> Optional[WorkflowNodeExecutionModel]:
) -> WorkflowNodeExecutionModel | None:
"""
Get the most recent execution for a specific node.
@ -116,8 +115,8 @@ class DifyAPISQLAlchemyWorkflowNodeExecutionRepository(DifyAPIWorkflowNodeExecut
def get_execution_by_id(
self,
execution_id: str,
tenant_id: Optional[str] = None,
) -> Optional[WorkflowNodeExecutionModel]:
tenant_id: str | None = None,
) -> WorkflowNodeExecutionModel | None:
"""
Get a workflow node execution by its ID.

View file

@ -22,7 +22,6 @@ Implementation Notes:
import logging
from collections.abc import Sequence
from datetime import datetime
from typing import Optional
from sqlalchemy import delete, select
from sqlalchemy.orm import Session, sessionmaker
@ -61,7 +60,7 @@ class DifyAPISQLAlchemyWorkflowRunRepository(APIWorkflowRunRepository):
app_id: str,
triggered_from: str,
limit: int = 20,
last_id: Optional[str] = None,
last_id: str | None = None,
) -> InfiniteScrollPagination:
"""
Get paginated workflow runs with filtering.
@ -107,7 +106,7 @@ class DifyAPISQLAlchemyWorkflowRunRepository(APIWorkflowRunRepository):
tenant_id: str,
app_id: str,
run_id: str,
) -> Optional[WorkflowRun]:
) -> WorkflowRun | None:
"""
Get a specific workflow run by ID with tenant and app isolation.
"""