Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

refactor: clean type: ignore comments in login.py and template_transformer.py (#30510)

liff3ca8be9f925
diff --git a/api/controllers/console/auth/login.py b/api/controllers/console/auth/login.py
index 772d98822e3..4a52bf8abe0 100644
--- a/api/controllers/console/auth/login.py
+++ b/api/controllers/console/auth/login.py
@@ -1,3 +1,5 @@
+from typing import Any
+
import flask_login
from flask import make_response, request
from flask_restx import Resource
@@ -96,14 +98,13 @@ class LoginApi(Resource):
if is_login_error_rate_limit:
raise EmailPasswordLoginLimitError()
- # TODO: why invitation is re-assigned with different type?
- invitation = args.invite_token # type: ignore
- if invitation:
- invitation = RegisterService.get_invitation_if_token_valid(None, args.email, invitation) # type: ignore
+ invitation_data: dict[str, Any] | None = None
+ if args.invite_token:
+ invitation_data = RegisterService.get_invitation_if_token_valid(None, args.email, args.invite_token)
try:
- if invitation:
- data = invitation.get("data", {}) # type: ignore
+ if invitation_data:
+ data = invitation_data.get("data", {})
invitee_email = data.get("email") if data else None
if invitee_email != args.email:
raise InvalidEmailError()
diff --git a/api/core/helper/code_executor/template_transformer.py b/api/core/helper/code_executor/template_transformer.py
index 6fda0739135..5cdea19a8dd 100644
--- a/api/core/helper/code_executor/template_transformer.py
+++ b/api/core/helper/code_executor/template_transformer.py
@@ -76,7 +76,7 @@ class TemplateTransformer(ABC):
Post-process the result to convert scientific notation strings back to numbers
"""
- def convert_scientific_notation(value):
+ def convert_scientific_notation(value: Any) -> Any:
if isinstance(value, str):
# Check if the string looks like scientific notation
if re.match(r"^-?\d+\.?\d*e[+-]\d+$", value, re.IGNORECASE):
@@ -90,7 +90,7 @@ class TemplateTransformer(ABC):
return [convert_scientific_notation(v) for v in value]
return value
- return convert_scientific_notation(result) # type: ignore[no-any-return]
+ return convert_scientific_notation(result)
@classmethod
@abstractmethod