Skip to content

fix: fix type hint union with grpc enum with old protobuf#1157

Merged
joein merged 2 commits into
devfrom
fix-old-grpc-enum-type-error
Mar 10, 2026
Merged

fix: fix type hint union with grpc enum with old protobuf#1157
joein merged 2 commits into
devfrom
fix-old-grpc-enum-type-error

Conversation

@joein

@joein joein commented Feb 24, 2026

Copy link
Copy Markdown
Member

@netlify

netlify Bot commented Feb 24, 2026

Copy link
Copy Markdown

Deploy Preview for poetic-froyo-8baba7 failed.

Name Link
🔨 Latest commit 9539dff
🔍 Latest deploy log https://app.netlify.com/projects/poetic-froyo-8baba7/deploys/69a95cd93c22ef0008652d6d

@coderabbitai

coderabbitai Bot commented Feb 24, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e97504ee-641c-422e-bb2b-3e68f81bdd39

📥 Commits

Reviewing files that changed from the base of the PR and between c3584ad and 9539dff.

📒 Files selected for processing (1)
  • qdrant_client/uploader/grpc_uploader.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • qdrant_client/uploader/grpc_uploader.py

📝 Walkthrough

Walkthrough

In qdrant_client/uploader/grpc_uploader.py the upload_batch_grpc function signature was changed: the update_mode parameter's type annotation was altered from grpc.UpdateMode | None = None to grpc.UpdateMode = None, retaining the default value of None while removing the union type in the annotation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: fixing type hint unions with gRPC enums for older protobuf versions, which aligns with the modification to the update_mode parameter type.
Description check ✅ Passed The description references issue #1155 and is minimalist but directly related to the changeset, which addresses a protobuf compatibility issue in the gRPC uploader.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-old-grpc-enum-type-error

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
qdrant_client/uploader/grpc_uploader.py (1)

3-3: ⚠️ Potential issue | 🟠 Major

Use Optional[grpc.UpdateMode] instead of the bare grpc.UpdateMode annotation

grpc.UpdateMode = None correctly avoids the TypeError from the old protobuf _UpdateModeEnumTypeWrapper metaclass not supporting the | operator, but it is semantically wrong — the annotation claims the parameter is grpc.UpdateMode (non-nullable) while the default is None. This will cause static type checkers to flag every call site that passes None (including the call in process_upload at line 149).

typing.Optional[T] is the backward-compatible way to express the same intent without invoking __or__ at runtime and without losing type accuracy.

🔧 Proposed fix
-from typing import Any, Generator, Iterable
+from typing import Any, Generator, Iterable, Optional
-    update_mode: grpc.UpdateMode = None,
+    update_mode: Optional[grpc.UpdateMode] = None,

Also applies to: 24-24

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@qdrant_client/uploader/grpc_uploader.py` at line 3, The parameter annotations
using grpc.UpdateMode with a default of None are wrong; change those to
typing.Optional[grpc.UpdateMode] wherever a default None is used (e.g., the
function/method signatures in grpc_uploader.py that currently annotate
update_mode: grpc.UpdateMode = None) so the type is nullable and static type
checkers won't error; update all occurrences (including the call site in
process_upload) to use Optional[grpc.UpdateMode] and ensure typing.Optional is
imported or referenced as Optional from typing.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@qdrant_client/uploader/grpc_uploader.py`:
- Line 3: The parameter annotations using grpc.UpdateMode with a default of None
are wrong; change those to typing.Optional[grpc.UpdateMode] wherever a default
None is used (e.g., the function/method signatures in grpc_uploader.py that
currently annotate update_mode: grpc.UpdateMode = None) so the type is nullable
and static type checkers won't error; update all occurrences (including the call
site in process_upload) to use Optional[grpc.UpdateMode] and ensure
typing.Optional is imported or referenced as Optional from typing.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 63f6954 and c3584ad.

📒 Files selected for processing (1)
  • qdrant_client/uploader/grpc_uploader.py

@joein joein requested a review from tbung February 25, 2026 11:55

@tbung tbung left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Type checker now reports, that None isn't a valid default value, if we expect this for this workaround we should tell the type checker.

@joein joein merged commit ee813f7 into dev Mar 10, 2026
8 of 12 checks passed
joein added a commit that referenced this pull request Mar 13, 2026
* fix: fix type hint union with grpc enum with old protobuf

* fix: add type ignore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants