Skip to content

refactor(api): type log identity dict with IdentityDict TypedDict#34485

Merged
asukaminato0721 merged 1 commit intolanggenius:mainfrom
YB0y:refactor/typed-dict-structured-log-formatter
Apr 3, 2026
Merged

refactor(api): type log identity dict with IdentityDict TypedDict#34485
asukaminato0721 merged 1 commit intolanggenius:mainfrom
YB0y:refactor/typed-dict-structured-log-formatter

Conversation

@YB0y
Copy link
Copy Markdown
Contributor

@YB0y YB0y commented Apr 2, 2026

Summary

  • Add IdentityDict TypedDict (total=False) with keys tenant_id, user_id, user_type
  • Annotate return type of _extract_identity and its local variable

Why this change

_extract_identity returns a dict with 3 well-known optional keys but was typed as dict[str, str] | None. The TypedDict with total=False documents exactly which keys can appear, matching the structured JSON log schema documented in the class docstring.

Changes

  • core/logging/structured_formatter.py: Define IdentityDict, update return type and local variable annotation

Test plan

  • ruff check passes

Part of #32863 (core/logging/structured_formatter.py)

@YB0y YB0y requested a review from QuantumGhost as a code owner April 2, 2026 15:38
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. refactor labels Apr 2, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 2, 2026

Pyrefly Diff

No changes detected.

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Apr 3, 2026
@asukaminato0721 asukaminato0721 added this pull request to the merge queue Apr 3, 2026
Merged via the queue into langgenius:main with commit e178451 Apr 3, 2026
27 checks passed
@YB0y YB0y deleted the refactor/typed-dict-structured-log-formatter branch April 8, 2026 13:35
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