Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix type safety in OpenAIConversationsSession.get_items()#1901

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
mshsheikh wants to merge3 commits intoopenai:main
base:main
Choose a base branch
Loading
frommshsheikh:patch-33

Conversation

@mshsheikh
Copy link
Contributor

What This PR Fixes

  • Resolves type mismatch whereget_items() returnedlist[dict] but was annotated aslist[TResponseInputItem]
  • Removes unnecessary# type: ignore comments that masked real type safety issues
  • Adds explicit non-None assertion for client initialization instart_openai_conversations_session

Changes Made

  • Addedfrom typing import cast import to support explicit type casting
  • Typed theall_items accumulator aslist[TResponseInputItem] to match method signature
  • Castitem.model_dump(exclude_unset=True) results toTResponseInputItem in both iteration branches
  • Removed# type: ignore onget_items() return statement since type now matches annotation
  • Removed# type: ignore [typeddict-item] inpop_item() since items are now correctly typed
  • Added explicitassert _maybe_openai_client is not None instart_openai_conversations_session to document invariant

Why This Matters

  • Enables proper static type checking with mypy and other type checkers
  • Prevents potential runtime errors when downstream code expects properTResponseInputItem objects
  • Makes type contracts explicit and verifiable
  • Improves code maintainability without changing runtime behavior

Backward Compatibility

  • No changes to public APIs or method signatures
  • No changes to pagination, ordering, or session management behavior
  • All existing functionality preserved

Testing

  • Existing test suite validates unchanged behavior
  • Type checking now passes without suppressions

chatgpt-codex-connector[bot] reacted with thumbs up emoji
**What This PR Fixes**- Resolves type mismatch where `get_items()` returned `list[dict]` but was annotated as `list[TResponseInputItem]`- Removes unnecessary `# type: ignore` comments that masked real type safety issues- Adds explicit non-None assertion for client initialization in `start_openai_conversations_session`**Changes Made**- Added `from typing import cast` import to support explicit type casting- Typed the `all_items` accumulator as `list[TResponseInputItem]` to match method signature- Cast `item.model_dump(exclude_unset=True)` results to `TResponseInputItem` in both iteration branches- Removed `# type: ignore` on `get_items()` return statement since type now matches annotation- Removed `# type: ignore [typeddict-item]` in `pop_item()` since items are now correctly typed- Added explicit `assert _maybe_openai_client is not None` in `start_openai_conversations_session` to document invariant**Why This Matters**- Enables proper static type checking with mypy and other type checkers- Prevents potential runtime errors when downstream code expects proper `TResponseInputItem` objects- Makes type contracts explicit and verifiable- Improves code maintainability without changing runtime behavior**Backward Compatibility**- No changes to public APIs or method signatures- No changes to pagination, ordering, or session management behavior- All existing functionality preserved**Testing**- Existing test suite validates unchanged behavior- Type checking now passes without suppressions
Added type ignore comment for item_id assignment.
@seratch
Copy link
Member

Thanks for sending this, but I am not sure if having lots ofcast is a good idea here.

…ior unchanged.- Replace multiple per-item casts in get_items by accumulating plain dicts and applying a single cast at the return so the function matches its annotated return type while keeping runtime behavior identical.​- Retain a focused type ignore for item_id in pop_item because the TypedDict union does not guarantee an id key even though the API does, avoiding broader casts or schema changes in this small patch.​- Preserve ordering, pagination, and session behavior; no public API changes, no control-flow changes, and no added dependencies, making the change safe and easy to review.
@seratchseratch marked this pull request as draftOctober 17, 2025 04:31
@github-actions
Copy link
Contributor

This PR is stale because it has been open for 10 days with no activity.

@github-actionsgithub-actionsbot added stale and removed stale labelsOct 28, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@mshsheikh@seratch

[8]ページ先頭

©2009-2025 Movatter.jp