refactor(api): type workflow run delete/count results with RunsWithRelatedCountsDict TypedDict#34531
Open
YB0y wants to merge 2 commits intolanggenius:mainfrom
Open
refactor(api): type workflow run delete/count results with RunsWithRelatedCountsDict TypedDict#34531YB0y wants to merge 2 commits intolanggenius:mainfrom
YB0y wants to merge 2 commits intolanggenius:mainfrom
Conversation
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-04-03 13:10:51.766135851 +0000
+++ /tmp/pyrefly_pr.txt 2026-04-03 13:10:41.884139977 +0000
@@ -343,6 +343,14 @@
--> services/document_indexing_proxy/duplicate_document_indexing_task_proxy.py:15:5
ERROR `handled_tenant_count` was assigned in the current scope before the nonlocal declaration [unknown-name]
--> services/plugin/plugin_migration.py:81:34
+ERROR `+=` is not supported between `int` and `object` [unsupported-operation]
+ --> services/retention/workflow_run/clear_free_plan_expired_workflow_run_logs.py:316:29
+ERROR Argument `dict[str, int | object]` is not assignable to parameter `related_counts` with type `dict[str, int] | None` in function `WorkflowRunCleanupMetrics.record_batch` [bad-argument-type]
+ --> services/retention/workflow_run/clear_free_plan_expired_workflow_run_logs.py:335:40
+ERROR Argument `dict[str, int | object]` is not assignable to parameter `related_counts` with type `dict[str, int] | None` in function `WorkflowRunCleanupMetrics.record_batch` [bad-argument-type]
+ --> services/retention/workflow_run/clear_free_plan_expired_workflow_run_logs.py:375:36
+ERROR `RunsWithRelatedCountsDict` is not assignable to attribute `deleted_counts` with type `dict[str, int]` [bad-assignment]
+ --> services/retention/workflow_run/delete_archived_workflow_run.py:100:37
ERROR Object of class `dict` has no attribute `encode`
ERROR Object of class `dict` has no attribute `encode`
ERROR Returned type `EndUser | Unknown | None` is not assignable to declared return type `Account | EndUser` [bad-return]
|
46ff1b9 to
d6fc29e
Compare
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-04-03 13:36:11.758609018 +0000
+++ /tmp/pyrefly_pr.txt 2026-04-03 13:36:02.878624358 +0000
@@ -343,6 +343,10 @@
--> services/document_indexing_proxy/duplicate_document_indexing_task_proxy.py:15:5
ERROR `handled_tenant_count` was assigned in the current scope before the nonlocal declaration [unknown-name]
--> services/plugin/plugin_migration.py:81:34
+ERROR No matching overload found for function `dict.__init__` called with arguments: (RunsWithRelatedCountsDict) [no-matching-overload]
+ --> services/retention/workflow_run/clear_free_plan_expired_workflow_run_logs.py:304:56
+ERROR No matching overload found for function `dict.__init__` called with arguments: (RunsWithRelatedCountsDict) [no-matching-overload]
+ --> services/retention/workflow_run/clear_free_plan_expired_workflow_run_logs.py:343:50
ERROR Object of class `dict` has no attribute `encode`
ERROR Object of class `dict` has no attribute `encode`
ERROR Returned type `EndUser | Unknown | None` is not assignable to declared return type `Account | EndUser` [bad-return]
|
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-04-03 13:38:15.804466229 +0000
+++ /tmp/pyrefly_pr.txt 2026-04-03 13:38:06.884453495 +0000
@@ -343,6 +343,10 @@
--> services/document_indexing_proxy/duplicate_document_indexing_task_proxy.py:15:5
ERROR `handled_tenant_count` was assigned in the current scope before the nonlocal declaration [unknown-name]
--> services/plugin/plugin_migration.py:81:34
+ERROR No matching overload found for function `dict.__init__` called with arguments: (RunsWithRelatedCountsDict) [no-matching-overload]
+ --> services/retention/workflow_run/clear_free_plan_expired_workflow_run_logs.py:304:56
+ERROR No matching overload found for function `dict.__init__` called with arguments: (RunsWithRelatedCountsDict) [no-matching-overload]
+ --> services/retention/workflow_run/clear_free_plan_expired_workflow_run_logs.py:345:50
ERROR Object of class `dict` has no attribute `encode`
ERROR Object of class `dict` has no attribute `encode`
ERROR Returned type `EndUser | Unknown | None` is not assignable to declared return type `Account | EndUser` [bad-return]
|
…latedCountsDict TypedDict
dbdde17 to
bcf0c39
Compare
Contributor
Pyrefly DiffNo changes detected. |
Contributor
Pyrefly DiffNo changes detected. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
RunsWithRelatedCountsDictTypedDict with keysruns,node_executions,offloads,app_logs,trigger_logs,pauses,pause_reasonsdelete_runs_with_relatedandcount_runs_with_relatedin both protocol and implementationWhy this change
Both methods return a 7-key integer dict representing counts of deleted/counted workflow runs and their related records. The dict shape is identical across the abstract protocol and its SQLAlchemy implementation, and callers access keys by name. A TypedDict makes the contract explicit at the protocol level.
Changes
repositories/api_workflow_run_repository.py: DefineRunsWithRelatedCountsDict, update 2 protocol method return typesrepositories/sqlalchemy_api_workflow_run_repository.py: Import TypedDict, update 2 implementation method return typesTest plan
ruff checkpassesPart of #32863 (
repositories/api_workflow_run_repository.py,repositories/sqlalchemy_api_workflow_run_repository.py)