Skip to content

Fix pyright type resolution for Pipeline parameter#802

Merged
abrookins merged 1 commit intomainfrom
fix/pyright-pipeline-type-678
Jan 30, 2026
Merged

Fix pyright type resolution for Pipeline parameter#802
abrookins merged 1 commit intomainfrom
fix/pyright-pipeline-type-678

Conversation

@abrookins
Copy link
Collaborator

Fixes #678

Problem

Pyright could not resolve the Pipeline type in method signatures like save(), delete(), and expire(). While mypy correctly showed redis.asyncio.client.Pipeline[Any] | None, pyright showed just Unknown | None.

The root cause was the module aliasing pattern:

  • aredis_om/async_redis.py imports redis.asyncio as redis
  • model.py used redis.client.Pipeline for type hints via this alias
  • Mypy could follow this aliasing, but pyright could not

Solution

  • Import Pipeline directly from redis.asyncio.client in aredis_om/model/model.py
  • Replace all redis.client.Pipeline type annotations with just Pipeline
  • Add post-processing in make_sync.py to convert the import to from redis.client import Pipeline for the sync version

Verification

Before:

pyright: pipeline: Unknown | None

After:

pyright: pipeline: Pipeline[Unknown] | None
mypy: pipeline: redis.asyncio.client.Pipeline[Any] | None

Both type checkers now correctly identify the Pipeline type.

Direct import of Pipeline from redis.asyncio.client allows pyright
to correctly resolve the type instead of showing Unknown.
@abrookins abrookins merged commit 2a27d48 into main Jan 30, 2026
16 checks passed
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.

redis.client.Pipeline is not imported correctly

1 participant