Skip to content

feat: add type annotations to the cohort module - #129

Merged
proxi merged 1 commit into
mainfrom
proxi/type-cohort-module
Dec 1, 2026
Merged

proxi merged 1 commit into
mainfrom
proxi/type-cohort-module

Conversation

@proxi

@proxi proxi commented Dec 1, 2026

Copy link
Copy Markdown
Member

Third step towards mypy --disallow-untyped-defs, after #127 (System alias) and #128 (core module).

All 12 untyped functions in bitmapist/cohort/__init__.py are now annotated: mypy --disallow-untyped-defs bitmapist passes for the whole package. Untyped functions left in the repo: 94 → 82 (81 in test/, 1 in examples/).

What to look at:

  • Public signatures: render_html_form(), render_html_data(), render_csv_data() and get_dates_data() are fully annotated. The render functions return str; get_dates_data() returns list[list[Any]].
  • EventNames = str | Iterable[str] | None is a new alias for the select* arguments: one event name, several that must all match, or nothing.
  • OptionGroup and Selection move above render_html_form(), which now uses them in its signature. The module has no from __future__ import annotations, so they must be defined first.
  • Private helpers take System for system and return _Events (GenericPeriodEvents | BitOperation).

Left loose on purpose:

  • get_dates_data() rows mix datetime, int, float and "", so a row is list[Any].
  • Custom handlers stay Callable[..., Any], as CUSTOM_HANDLERS already was.

No runtime change. mypy passes in the project env and with the pre-commit hook's setup. Locally I could only smoke-test the render functions (no Redis backend), so the test suite is verified by CI only.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XGjgWiXoieBLCLiXckPSe9

All 12 untyped functions in bitmapist/cohort are now annotated, so
'mypy --disallow-untyped-defs bitmapist' passes for the whole package.

- render_html_form(), render_html_data(), render_csv_data() and
  get_dates_data() have full signatures. The select arguments take
  EventNames: one event name, several, or None.
- The OptionGroup and Selection aliases move above render_html_form(),
  which now uses them in its signature.
- Private helpers use System for the system argument and return _Events,
  a period's events or a bit operation over several.

No runtime change.

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
@proxi
proxi marked this pull request as ready for review December 1, 2026 13:05
@proxi
proxi merged commit cd75fe5 into main Dec 1, 2026
9 checks passed

@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 feat: add type annotations to the cohort module. No issues were flagged in the reviewed diff.

Share Feedback • Review Logs • Trace

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