fix: fix type hint union with grpc enum with old protobuf#1157
Conversation
❌ Deploy Preview for poetic-froyo-8baba7 failed.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughIn qdrant_client/uploader/grpc_uploader.py the Estimated code review effort🎯 2 (Simple) | ⏱️ ~7 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). 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. Comment |
There was a problem hiding this comment.
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 | 🟠 MajorUse
Optional[grpc.UpdateMode]instead of the baregrpc.UpdateModeannotation
grpc.UpdateMode = Nonecorrectly avoids theTypeErrorfrom the old protobuf_UpdateModeEnumTypeWrappermetaclass not supporting the|operator, but it is semantically wrong — the annotation claims the parameter isgrpc.UpdateMode(non-nullable) while the default isNone. This will cause static type checkers to flag every call site that passesNone(including the call inprocess_uploadat 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.
tbung
left a comment
There was a problem hiding this comment.
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.
* fix: fix type hint union with grpc enum with old protobuf * fix: add type ignore
#1155