Skip to content

refactor: replace Any with [T] syntax#35750

Merged
asukaminato0721 merged 2 commits into
langgenius:mainfrom
aliworksx08:refactor/use-T-instead-of-any
Apr 30, 2026
Merged

refactor: replace Any with [T] syntax#35750
asukaminato0721 merged 2 commits into
langgenius:mainfrom
aliworksx08:refactor/use-T-instead-of-any

Conversation

@aliworksx08
Copy link
Copy Markdown
Contributor

Summary

Fixes #34878
This PR addresses issue by replacing Any usage with Python 3.12+ [T] syntax and specific type annotations. The changes improve type safety and leverage modern Python typing features now that the project requires Python 3.12+.

Changes

  1. config_helper.py - Eliminated Any by replacing dict[str, Any] with specific TypedDict types and [T] syntax
  2. mock_openai_server.py - Fixed Flask route return types from Any to concrete Response types
    Motivation: The project requires Python 3.12+ (requires-python = "~=3.12.0"), so we should leverage modern typing features to eliminate Any usage and improve code quality as recommended in AGENTS.md.

Test

This change requires a documentation update, included: Dify Document
I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
I've updated the documentation accordingly.
I ran make lint && make type-check (backend) and cd web && pnpm exec vp staged (frontend) to appease the lint gods

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. refactor labels Apr 30, 2026
@aliworksx08
Copy link
Copy Markdown
Contributor Author

@asukaminato0721, could you review my PR, please?

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Apr 30, 2026
@asukaminato0721 asukaminato0721 added this pull request to the merge queue Apr 30, 2026
Merged via the queue into langgenius:main with commit 87add9a Apr 30, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer refactor size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Refactor/Chore] use [T] instead of Any

2 participants