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:
parent
2e44ebe98d
commit
bab4975809
394 changed files with 2555 additions and 2792 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import logging
|
||||
import threading
|
||||
import time
|
||||
from typing import Any, Optional
|
||||
from typing import Any
|
||||
|
||||
from flask import Flask, current_app
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
|
|
@ -27,11 +27,11 @@ class OutputModeration(BaseModel):
|
|||
rule: ModerationRule
|
||||
queue_manager: AppQueueManager
|
||||
|
||||
thread: Optional[threading.Thread] = None
|
||||
thread: threading.Thread | None = None
|
||||
thread_running: bool = True
|
||||
buffer: str = ""
|
||||
is_final_chunk: bool = False
|
||||
final_output: Optional[str] = None
|
||||
final_output: str | None = None
|
||||
model_config = ConfigDict(arbitrary_types_allowed=True)
|
||||
|
||||
def should_direct_output(self) -> bool:
|
||||
|
|
@ -127,7 +127,7 @@ class OutputModeration(BaseModel):
|
|||
if result.action == ModerationAction.DIRECT_OUTPUT:
|
||||
break
|
||||
|
||||
def moderation(self, tenant_id: str, app_id: str, moderation_buffer: str) -> Optional[ModerationOutputsResult]:
|
||||
def moderation(self, tenant_id: str, app_id: str, moderation_buffer: str) -> ModerationOutputsResult | None:
|
||||
try:
|
||||
moderation_factory = ModerationFactory(
|
||||
name=self.rule.type, app_id=app_id, tenant_id=tenant_id, config=self.rule.config
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue