mirror of
https://github.com/langgenius/dify.git
synced 2026-05-06 02:18:08 +08:00
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:
@ -1,5 +1,5 @@
|
||||
import json
|
||||
from typing import Optional, Union
|
||||
from typing import Union
|
||||
|
||||
from core.app.apps.advanced_chat.app_config_manager import AdvancedChatAppConfigManager
|
||||
from core.app.entities.app_invoke_entities import InvokeFrom
|
||||
@ -29,9 +29,9 @@ class MessageService:
|
||||
def pagination_by_first_id(
|
||||
cls,
|
||||
app_model: App,
|
||||
user: Optional[Union[Account, EndUser]],
|
||||
user: Union[Account, EndUser] | None,
|
||||
conversation_id: str,
|
||||
first_id: Optional[str],
|
||||
first_id: str | None,
|
||||
limit: int,
|
||||
order: str = "asc",
|
||||
) -> InfiniteScrollPagination:
|
||||
@ -91,11 +91,11 @@ class MessageService:
|
||||
def pagination_by_last_id(
|
||||
cls,
|
||||
app_model: App,
|
||||
user: Optional[Union[Account, EndUser]],
|
||||
last_id: Optional[str],
|
||||
user: Union[Account, EndUser] | None,
|
||||
last_id: str | None,
|
||||
limit: int,
|
||||
conversation_id: Optional[str] = None,
|
||||
include_ids: Optional[list] = None,
|
||||
conversation_id: str | None = None,
|
||||
include_ids: list | None = None,
|
||||
) -> InfiniteScrollPagination:
|
||||
if not user:
|
||||
return InfiniteScrollPagination(data=[], limit=limit, has_more=False)
|
||||
@ -145,9 +145,9 @@ class MessageService:
|
||||
*,
|
||||
app_model: App,
|
||||
message_id: str,
|
||||
user: Optional[Union[Account, EndUser]],
|
||||
rating: Optional[str],
|
||||
content: Optional[str],
|
||||
user: Union[Account, EndUser] | None,
|
||||
rating: str | None,
|
||||
content: str | None,
|
||||
):
|
||||
if not user:
|
||||
raise ValueError("user cannot be None")
|
||||
@ -196,7 +196,7 @@ class MessageService:
|
||||
return [record.to_dict() for record in feedbacks]
|
||||
|
||||
@classmethod
|
||||
def get_message(cls, app_model: App, user: Optional[Union[Account, EndUser]], message_id: str):
|
||||
def get_message(cls, app_model: App, user: Union[Account, EndUser] | None, message_id: str):
|
||||
message = (
|
||||
db.session.query(Message)
|
||||
.where(
|
||||
@ -216,7 +216,7 @@ class MessageService:
|
||||
|
||||
@classmethod
|
||||
def get_suggested_questions_after_answer(
|
||||
cls, app_model: App, user: Optional[Union[Account, EndUser]], message_id: str, invoke_from: InvokeFrom
|
||||
cls, app_model: App, user: Union[Account, EndUser] | None, message_id: str, invoke_from: InvokeFrom
|
||||
) -> list[Message]:
|
||||
if not user:
|
||||
raise ValueError("user cannot be None")
|
||||
|
||||
Reference in New Issue
Block a user