Skip to content

refactor: migrate verify_subscription_credentials return type to TypedDict#34967

Merged
asukaminato0721 merged 1 commit intolanggenius:mainfrom
AlsoTheZv3n:refactor/typeddict-verify-subscription-credentials
Apr 11, 2026
Merged

refactor: migrate verify_subscription_credentials return type to TypedDict#34967
asukaminato0721 merged 1 commit intolanggenius:mainfrom
AlsoTheZv3n:refactor/typeddict-verify-subscription-credentials

Conversation

@AlsoTheZv3n
Copy link
Copy Markdown
Contributor

Summary

Migrates the -> dict[str, Any] return type hint on TriggerProviderService.verify_subscription_credentials() in api/services/trigger/trigger_provider_service.py to a proper TypedDict definition as part of the broader type safety refactor.

Changes

  • Added VerifyCredentialsResult TypedDict with a single verified: bool field, modeling the stable JSON response shape returned by verify_subscription_credentials() (both return sites yield {"verified": True})
  • Changed the method return type from dict[str, Any] to VerifyCredentialsResult
  • No logic, no call-site changes — the controller at controllers/console/workspace/trigger_providers.py passes the result straight to Flask-RESTx for JSON serialization, and the dict is never mutated or unpacked

Related Issue

Closes part of #32863

Checklist

  • Only type hints changed, no logic modified
  • Existing tests pass (tests/unit_tests/services/test_trigger_provider_service.py — 49/49, including all 5 verify_subscription_credentials tests)
  • Ruff linting passes (no new errors introduced)
  • basedpyright reports no new errors across the service, its controller, and the test file (0 errors, 0 warnings, 0 notes)

@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. refactor labels Apr 11, 2026
@asukaminato0721 asukaminato0721 requested a review from Copilot April 11, 2026 16:33
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Apr 11, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-04-11 16:34:16.764645134 +0000
+++ /tmp/pyrefly_pr.txt	2026-04-11 16:34:07.335740804 +0000
@@ -350,9 +350,9 @@
 ERROR `handled_tenant_count` was assigned in the current scope before the nonlocal declaration [unknown-name]
   --> services/plugin/plugin_migration.py:91:34
 ERROR `dict[str, Any]` is not assignable to attribute `credentials` with type `Never` [bad-assignment]
-   --> services/trigger/trigger_provider_service.py:446:40
+   --> services/trigger/trigger_provider_service.py:450:40
 ERROR `int` is not assignable to attribute `credential_expires_at` with type `Never` [bad-assignment]
-   --> services/trigger/trigger_provider_service.py:447:50
+   --> services/trigger/trigger_provider_service.py:451:50
 ERROR Object of class `dict` has no attribute `encode`
 ERROR Object of class `dict` has no attribute `encode`
 ERROR `Literal['error']` is not assignable to attribute `status` with type `Never` [bad-assignment]

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves type safety in the trigger service layer by replacing the broad dict[str, Any] return annotation on TriggerProviderService.verify_subscription_credentials() with a dedicated TypedDict that matches the method’s stable JSON response shape.

Changes:

  • Introduced VerifyCredentialsResult (TypedDict) with a single verified: bool field.
  • Updated verify_subscription_credentials() to return VerifyCredentialsResult instead of dict[str, Any].

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@asukaminato0721 asukaminato0721 added this pull request to the merge queue Apr 11, 2026
Merged via the queue into langgenius:main with commit 859920a Apr 11, 2026
32 checks passed
HanqingZ pushed a commit to HanqingZ/dify that referenced this pull request Apr 23, 2026
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:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants