chore(utils): add type hints to utils functions [python] - #4123
chore(utils): add type hints to utils functions [python]#4123yogeshwaran-c wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds missing type annotations to a few helper functions in python/bullmq/utils.py to improve consistency and IDE/static-analysis support in the Python BullMQ implementation.
Changes:
- Added imports needed for typing (
asyncio,Callable,Optional). - Added return/parameter type hints for
isRedisVersionLowerThan,extract_result, andget_parent_key.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def isRedisVersionLowerThan(current_version: str | None, minimum_version: str) -> bool: | ||
| if current_version is None: | ||
| return False | ||
| return semver.Version.parse(current_version).compare(minimum_version) == -1 |
|
Thanks for catching this! You're right that the The Happy to split this into two commits (annotations-only + the |
|
@copilot resolve the merge conflicts in this pull request |
|
|
||
|
|
||
| def extract_result(job_task, emit_callback): | ||
| def extract_result(job_task: asyncio.Future[Any], emit_callback: Callable[[str, Any], None]) -> Any: |
Summary
Adds missing type hints to three functions in
python/bullmq/utils.py:isRedisVersionLowerThan(current_version: str | None, minimum_version: str) -> boolextract_result(job_task: asyncio.Task, emit_callback: Callable[[str, Any], None]) -> Anyget_parent_key(opts: dict[str, str]) -> Optional[str]Also adds the necessary imports (
asyncio,Callable,Optional).Note:
isRedisVersionLowerThannow treatscurrent_version=Noneas "not lower" (returnsFalse) instead of raising. This is a small but intentional runtime change: callers likeRedisConnection.versionare typed asstr | Noneand previously would have crashed if checked beforegetRedisVersion()ran.Motivation
These functions previously lacked type annotations, while the rest of the file (e.g.
parse_json_string_values,object_to_flat_array,is_redis_cluster,get_cluster_nodes,get_node_client) is fully typed. This change brings consistency and improves IDE support / static analysis. Apart from the documentedNone-guard above, no other runtime behavior is altered.Test plan
None-guard inisRedisVersionLowerThan