Repository navigation
chore(dev): type-check against types-redis in CI too - #126
Merged
Merged
Conversation
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
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
marked this pull request as ready for review
December 1, 2026 12:06
doistbot
reviewed
Dec 1, 2026
doistbot
left a comment
Member
There was a problem hiding this comment.
This PR updates chore(dev): type-check against types-redis in CI too. No issues were flagged in the reviewed diff.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to the doistbot note on #125: the pre-commit mypy hook and the CI
type-checkjob checked different surfaces.types-redisstubs.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.cli.keys()cli.get()cli.bitcount()Awaitable[Any] | AnyAwaitable[Any] | AnyAwaitable[Any] | Anytypes-redis4.6.0.20241004list[bytes]bytes | Noneintlist[bytes | str]bytes | str | Noneint(
reveal_typeoutput from mypy 2.4.1.)So this PR now:
types-redisto thedevgroup. Stub packages take precedence over inline types, so the CI job resolvesredisfrom the stubs, same as the hook.types-redisin the hook (net change there is only a comment).Trade-offs:
types-redisis 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.types-pyopenssl,cryptography,cffi, ...). Dev only, nothing changes for users of the library.redis<6.0pin raised, which is a separate decision; the comments inpyproject.tomland the hook config say to drop the stubs then.Tested:
uv run --locked mypy bitmapist test examples scriptspasses 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 throughpre-commititself locally.🤖 Generated with Claude Code
https://claude.ai/code/session_01XGjgWiXoieBLCLiXckPSe9