Repository navigation
feat: add a System type alias for the system arguments - #127
Conversation
The system arguments have accepted a redis-py client or pipeline as well as a registered name since 6026462 (2015), and the docstrings say so, but the annotations said 'str'. Type checkers rejected the documented usage. Add 'System = str | Redis | Pipeline' and use it for the 11 parameters that were annotated 'system: str'. No runtime change. Passing a client or a pipeline had no test, so add one. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XGjgWiXoieBLCLiXckPSe9
doistbot
left a comment
There was a problem hiding this comment.
Nice, clean typing step: System = str | Redis | Pipeline now matches what the system parameters have actually accepted since 2015, and it's applied consistently across the 11 annotated parameters, with a new test covering the previously untested client/pipeline usage. No inline issues were flagged; the only open item is CI confirmation of the new test since it couldn't run locally without a Redis backend.
I also left one optional follow-up note in the details below.
Optional follow-up note (1)
Pipeline subclasses Redis, so listing it added nothing to what the alias accepts. Pipeline goes back to a type-checking-only import. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XGjgWiXoieBLCLiXckPSe9
|
This comment was posted by Claude on Janusz's behalf, as part of addressing the doistbot review.
Changed in 805afc4: the alias is now |
First step towards
mypy --disallow-untyped-defs: say whatsystemreally accepts.The
systemarguments have accepted a redis-py client or pipeline as well as a registered name since 6026462 (2015), and the docstrings say "string, Redis instance, or Pipeline instance". The annotations saidstr, so type checkers rejected the documented usage.System = str | Redistobitmapist. A pipeline is covered, sincePipelinesubclassesRedis.system: str(get_redis,mark_event,unmark_event,mark_unique,unmark_unique,get_event_names,delete_all_events,delete_temporary_bitop_keys, and three event class methods).test_system_accepts_client_and_pipeline: passing a client or a pipeline had no test.No runtime change, apart from
redis.client.Redisnow being imported at runtime (the alias needs it;rediswas imported already).Not in this PR: the
systemparameters that have no annotation yet (most event classes,bitmapist.cohort). They getSystemwhen those modules are typed.mypy passes in the project env and with the pre-commit hook's setup. I could not run the test suite locally (no Redis backend), so the new test is verified by CI only.
🤖 Generated with Claude Code
https://claude.ai/code/session_01XGjgWiXoieBLCLiXckPSe9