Skip to content

Conversation

@vchomakov
Copy link
Member

Description of change

This PR adds a DriverInfo class to enable upstream drivers (like django-redis, celery, rq, etc.) to identify themselves when using redis-py as their underlying client.

Key features:

  • DriverInfo dataclass that tracks upstream driver name and version
  • Formatted output follows the pattern: redis-py(driver1_vVersion1;driver2_vVersion2)
  • Validation ensures driver names follow Python package naming conventions (lowercase, start with letter, only letters/digits/hyphens/underscores)
  • Validation ensures driver versions contain only printable ASCII without spaces or braces
  • Integration with both Redis and AsyncRedis clients via optional driver_info parameter
  • Most recently added driver appears first in the formatted name

Example usage:

from redis import Redis, DriverInfo

info = DriverInfo().add_upstream_driver("django-redis", "5.4.0")
client = Redis(driver_info=info)
# Client will identify as: redis-py(django-redis_v5.4.0)

Pull Request check-list

  • Do tests and lints pass with this change?
    • All 10 new tests passing
    • ruff check passes
    • ruff format --check passes
  • Do the CI tests pass with this change (enable it first in your forked repo and wait for the github action build to finish)?
    • Will enable and monitor
  • Is the new or changed code fully tested?
    • Comprehensive test suite with 10 test cases covering:
      • Default behavior (no upstream drivers)
      • Single upstream driver
      • Multiple upstream drivers (latest first)
      • Invalid driver name validation (4 test cases)
      • Invalid driver version validation (3 test cases)
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
    • Docstrings added to all public methods and classes
    • Examples included in docstrings
  • Is there an example added to the examples folder (if applicable)?
    • Not applicable - this is a utility class for library integrators, not end users

petyaslavova
petyaslavova previously approved these changes Dec 10, 2025
Copy link
Collaborator

@petyaslavova petyaslavova left a comment

Choose a reason for hiding this comment

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

Edited: Sorry - github initially showed just one small formatting change. Will review it in details tomorrow.

@petyaslavova petyaslavova self-requested a review December 10, 2025 19:54
@petyaslavova petyaslavova dismissed their stale review December 10, 2025 19:54

Didn't go through all the changes.

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