Skip to content

Improve JsonType type definition #3667

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

petyaslavova
Copy link
Collaborator

Pull Request check-list

Please make sure to review and check all of these items:

  • Do tests and lints pass with this change?
  • Do the CI tests pass with this change (enable it first in your forked repo and wait for the github action build to finish)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
  • Is there an example added to the examples folder (if applicable)?

NOTE: these things are not required to open a PR and can be done
afterwards / while the PR is open.

Description of change

Fixes #3519

Related discussion in python source repo: python/typing#182

@petyaslavova petyaslavova added the breakingchange API or Breaking Change label Jun 3, 2025
@petyaslavova petyaslavova marked this pull request as ready for review June 5, 2025 14:21
@petyaslavova petyaslavova requested a review from Copilot June 5, 2025 14:21
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves type definitions and annotations in the Redis commands modules. Key changes include:

  • Updating type annotations for query parameters and methods in the Query class.
  • Changing the _ids attribute from a List to a Tuple to promote immutability.
  • Enhancing the JsonType definition to a recursive and Mapping-based type.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
redis/commands/search/query.py Refined type annotations for method arguments and attributes to better reflect their intended usage.
redis/commands/json/_util.py Updated the JsonType definition to a recursive structure using Mapping, aligning with JSON standards.
Comments suppressed due to low confidence (1)

redis/commands/search/query.py:34

  • Consider updating the _ids type annotation to Tuple[str, ...] if multiple string IDs are expected, to clarify that it may contain more than one element.
self._ids: Optional[Tuple[str]] = None

@petyaslavova petyaslavova requested a review from vladvildanov June 5, 2025 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breakingchange API or Breaking Change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JsonType could be better declared
1 participant