Skip to content

chore(dev): type-check against types-redis in CI too - #126

Merged
proxi merged 2 commits into
mainfrom
proxi/pre-commit-mypy-redis
Dec 1, 2026
Merged

proxi merged 2 commits into
mainfrom
proxi/pre-commit-mypy-redis

Conversation

@proxi

@proxi proxi commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

Follow-up to the doistbot note on #125: the pre-commit mypy hook and the CI type-check job checked different surfaces.

  • Hook: types-redis stubs.
  • CI: redis-py 5.3.1's inline types, from uv.lock.

The first version of this PR moved the hook to redis-py's inline types. That was the wrong direction: for the versions we pin (redis<6.0), the inline types are the broken side.

Types cli.keys() cli.get() cli.bitcount()
redis-py 5.3.1, 6.4.0, 7.4.1 inline Awaitable[Any] | Any Awaitable[Any] | Any Awaitable[Any] | Any
types-redis 4.6.0.20241004 list[bytes] bytes | None int
redis-py 8.0.1 inline list[bytes | str] bytes | str | None int

(reveal_type output from mypy 2.4.1.)

So this PR now:

  • Adds types-redis to the dev group. Stub packages take precedence over inline types, so the CI job resolves redis from the stubs, same as the hook.
  • Keeps types-redis in the hook (net change there is only a comment).
  • Drops the two casts from ci: run mypy on every push and pull request #125, which only the inline types required.

Trade-offs:

  • types-redis is frozen (last release 2024-10-04, targets the 4.6 API) and its own README says to uninstall it with redis >= 5. It still describes the commands bitmapist uses correctly.
  • It pulls 7 packages into the dev lock (types-pyopenssl, cryptography, cffi, ...). Dev only, nothing changes for users of the library.
  • The proper fix is redis-py >= 8, where the inline types are right. That needs the redis<6.0 pin raised, which is a separate decision; the comments in pyproject.toml and the hook config say to drop the stubs then.

Tested: uv run --locked mypy bitmapist test examples scripts passes without the casts, and so does mypy 2.4.1 with the hook's arguments and dependencies in an isolated env. I could not run the hook through pre-commit itself locally.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XGjgWiXoieBLCLiXckPSe9

The mypy hook installed the types-redis stubs, while the CI type-check
job uses redis-py's inline types from the locked environment. The two
disagreed: the hook passed code that CI rejects, such as
cli.delete(*cli.keys(...)).

Install redis-py in the hook instead, with the same range as
pyproject.toml, so both check the same surface.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XGjgWiXoieBLCLiXckPSe9
@proxi proxi added the 🚢 Ship PR requires passing checks before merge, but no independent human review. label Dec 1, 2026
Reverses the previous commit's direction. redis-py's inline types
declare every sync command as 'Awaitable[Any] | Any' up to 7.4.1 (fixed
in 8.0), and this project pins redis < 6. The types-redis stubs are
precise (keys -> list[bytes], bitcount -> int) and take precedence over
the inline types when both are installed.

So keep types-redis in the pre-commit hook, add it to the dev group so
the CI type-check job uses the same stubs, and drop the two casts that
only the inline types required.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XGjgWiXoieBLCLiXckPSe9
@proxi proxi changed the title chore(pre-commit): type-check against redis-py's own types chore(dev): type-check against types-redis in CI too Dec 1, 2026
@proxi
proxi marked this pull request as ready for review December 1, 2026 12:06

@doistbot doistbot left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This PR updates chore(dev): type-check against types-redis in CI too. No issues were flagged in the reviewed diff.

Share Feedback • Review Logs • Trace

@proxi
proxi merged commit f812646 into main Dec 1, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🚢 Ship PR requires passing checks before merge, but no independent human review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants