Skip to content

refactor(api): type celery sqlcommenter tags with CelerySqlcommenterTagsDict TypedDict#34526

Merged
asukaminato0721 merged 1 commit intolanggenius:mainfrom
YB0y:refactor/typed-dict-celery-sqlcommenter-tags
Apr 3, 2026
Merged

refactor(api): type celery sqlcommenter tags with CelerySqlcommenterTagsDict TypedDict#34526
asukaminato0721 merged 1 commit intolanggenius:mainfrom
YB0y:refactor/typed-dict-celery-sqlcommenter-tags

Conversation

@YB0y
Copy link
Copy Markdown
Contributor

@YB0y YB0y commented Apr 3, 2026

Summary

  • Add CelerySqlcommenterTagsDict TypedDict (total=False) with keys framework, task_name, traceparent, celery_retries, routing_key
  • Annotate return type of _build_celery_sqlcommenter_tags and its local variable

Why this change

_build_celery_sqlcommenter_tags builds a dict with 5 well-known optional keys but was typed as dict[str, str | int]. The TypedDict documents exactly which SQL commenter tags can appear and their individual types (str vs int for celery_retries).

Changes

  • extensions/otel/celery_sqlcommenter.py: Define CelerySqlcommenterTagsDict, update function return type and local variable annotation

Test plan

  • ruff check passes

Part of #32863 (extensions/otel/celery_sqlcommenter.py)

@YB0y YB0y requested a review from QuantumGhost as a code owner April 3, 2026 11:57
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. refactor labels Apr 3, 2026
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Apr 3, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 3, 2026

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-04-03 11:58:31.401059777 +0000
+++ /tmp/pyrefly_pr.txt	2026-04-03 11:58:22.230073476 +0000
@@ -6025,8 +6025,6 @@
    --> tests/unit_tests/enterprise/telemetry/test_exporter.py:582:71
 ERROR Argument `dict[str, str]` is not assignable to parameter `labels` with type `dict[str, AttributeValue]` in function `enterprise.telemetry.exporter.EnterpriseExporter.record_histogram` [bad-argument-type]
    --> tests/unit_tests/enterprise/telemetry/test_exporter.py:615:85
-ERROR Object of class `int` has no attribute `startswith` [missing-attribute]
-  --> tests/unit_tests/extensions/otel/test_celery_sqlcommenter.py:25:16
 ERROR Cannot index into `object` [bad-index]
    --> tests/unit_tests/extensions/otel/test_celery_sqlcommenter.py:136:20
 ERROR Cannot index into `object` [bad-index]

@asukaminato0721 asukaminato0721 added this pull request to the merge queue Apr 3, 2026
Merged via the queue into langgenius:main with commit 0f051d5 Apr 3, 2026
27 checks passed
@YB0y YB0y deleted the refactor/typed-dict-celery-sqlcommenter-tags branch April 8, 2026 13:35
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:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants