Add pydoclint pre-commit hook and align docstrings to Google form#443
Add pydoclint pre-commit hook and align docstrings to Google form#443kenibrewer merged 5 commits intomainfrom
Conversation
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughBumps a pre-commit mypy hook and adds a pydoclint hook; standardizes and corrects docstrings and type annotations across modules; tightens three utility function signatures; minor runtime change in file-line detection logic in sources; expanded Iceberg warehouse docstrings. No public API removals. ChangesPre-commit configuration
Docstring, typing, and small runtime tweaks
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@cytotable/sources.py`:
- Around line 323-324: The docstring claims NoInputDataException is raised for
zero-line files but the actual code path currently returns False for
non-multi-line inputs (the branch with the existing "return False" near the
check around line 333); fix this by either (A) changing that branch to raise
NoInputDataException instead of returning False (replace the "return False" in
the non-multi-line path with "raise NoInputDataException(...)"), or (B) update
the docstring to remove the claim about NoInputDataException so it matches the
current return-False behavior—make the change next to the function that contains
the existing "return False" and keep NoInputDataException referenced
consistently.
In `@cytotable/utils.py`:
- Around line 208-209: The docstring for _sqlite_mixed_type_query_to_parquet is
incorrect: it claims to return a parquet file path but the function actually
returns a pyarrow Table (pa.Table) at the end of the function; update the return
contract to state it returns a pa.Table (or modify the function to write and
return a file path if that was intended). Specifically, edit the docstring for
_sqlite_mixed_type_query_to_parquet to describe the returned type as pa.Table
and include a brief note about the table representing the extracted data so
callers (and type checkers) match the actual return value.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 62a2cc3d-6e95-447f-a2e7-ae8ffb1e5bff
📒 Files selected for processing (5)
.pre-commit-config.yamlcytotable/convert.pycytotable/sources.pycytotable/utils.pycytotable/warehouse/iceberg.py
Address CodeRabbit feedback on PR #443: - sources.py: `_file_is_more_than_one_line` documented raising `NoInputDataException` for zero-line files, but the `except StopIteration` block was unreachable (`file.readline()` returns `''` on EOF, it does not raise). The function actually returned `False` for zero/one-line files, which matches existing test expectations. Remove the dead branch and the misleading `Raises:` section so the contract matches behavior; drop the now-unused `NoInputDataException` import. - utils.py: `_sqlite_mixed_type_query_to_parquet` was annotated `-> str` but returns `pa.Table.from_pylist(results)`. Both call sites in convert.py and the existing test pass the result as a `pa.Table` (named `arrow_data_tbl`, passed as `table=` to `parquet.write_table`). Correct the annotation and docstring to `pa.Table`. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@cytotable/warehouse/iceberg.py`:
- Around line 610-617: The docstring incorrectly states that missing optional
pyiceberg raises CytoTableException; update the docstring to match runtime
behavior by replacing that part to say the missing pyiceberg dependency raises
ImportError raised by _require_pyiceberg(), or alternatively change the
call-sites that use _require_pyiceberg() to catch ImportError and raise
CytoTableException instead—refer to the _require_pyiceberg() helper and the
CytoTableException symbol in your change so the documentation and runtime
behavior stay consistent.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 8e80a901-4d2e-4edc-a7e3-8d66db0a8af5
📒 Files selected for processing (3)
cytotable/sources.pycytotable/utils.pycytotable/warehouse/iceberg.py
🚧 Files skipped from review as they are similar to previous changes (1)
- cytotable/utils.py
d33bs
left a comment
There was a problem hiding this comment.
Thanks @kenibrewer !This LGTM! There's one remaining coderabbit review item that might need attention but I couldn't tell if it was absolutely accurate or not (and it's a low risk change generally).
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@cytotable/warehouse/iceberg.py`:
- Line 623: Remove the invalid Ruff noqa marker by deleting the "# noqa: DOC503"
suffix from the triple-quoted docstring end (the closing triple quote) so the
docstring no longer contains the pydocstyle-specific noqa; i.e., find the
closing docstring token in iceberg.py (the line containing """ # noqa: DOC503)
and remove the " # noqa: DOC503" portion so only the closing triple quotes
remain.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: cf0eaff7-1d32-4899-9780-2fecfae920f4
📒 Files selected for processing (1)
cytotable/warehouse/iceberg.py
Wire pydoclint 0.8.3 into .pre-commit-config.yaml with --style=google so docstring sections (Args, Returns, Yields, Raises) are verified against each function's signature on every commit. Convert all Args/Returns blocks in convert.py, utils.py, sources.py, and warehouse/iceberg.py to the canonical `name (TYPE):` Google form with types matching annotations exactly, and add missing Raises sections where functions raise. Strict mode (default) is enforced: types must be present in docstring args and match the signature, and Returns types must match the return annotation. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Address CodeRabbit feedback on PR #443: - sources.py: `_file_is_more_than_one_line` documented raising `NoInputDataException` for zero-line files, but the `except StopIteration` block was unreachable (`file.readline()` returns `''` on EOF, it does not raise). The function actually returned `False` for zero/one-line files, which matches existing test expectations. Remove the dead branch and the misleading `Raises:` section so the contract matches behavior; drop the now-unused `NoInputDataException` import. - utils.py: `_sqlite_mixed_type_query_to_parquet` was annotated `-> str` but returns `pa.Table.from_pylist(results)`. Both call sites in convert.py and the existing test pass the result as a `pa.Table` (named `arrow_data_tbl`, passed as `table=` to `parquet.write_table`). Correct the annotation and docstring to `pa.Table`. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The previous rewrite narrowed Raises: to only the directly raised CytoTableException for an existing warehouse_path, but the function also propagates ValueError from _validate_iceberg_join_prerequisites (empty joins or missing page_keys["join"]) and additional CytoTableException cases from _validate_image_export_prerequisites (missing image_dir, non-existent referenced directories, missing join SQL or page_keys when image export is requested) and from _require_pyiceberg. Document all of these and suppress DOC503 with `# noqa: DOC503` on the closing docstring line, since pydoclint can only see direct raise statements and would otherwise flag the helper-propagated exceptions as "in docstring but not in body". Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Three helper functions added in PR #441 (`_glob_pattern_matches`, `_glob_follow_symlinks`, `_walk_and_match`) carry untyped Args/Yields sections. After rebasing this branch onto current main, pydoclint flags DOC105/109/110/203/404 because the codebase now requires typed Google- style docstrings. Add `name (TYPE):` and `TYPE:` blocks matching the existing signatures. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
4c9b3eb to
c362074
Compare
Description
Adds a
pydoclintpre-commit hook (v0.8.3,--style=google) that verifies each function'sArgs/Returns/Yields/Raisessections against its actual signature on every commit. The default strict mode is used, so docstring arg types must be present and match annotations, and Returns types must match the return annotation. To pass the new hook, every Args/Returns block incytotable/convert.py,cytotable/utils.py,cytotable/sources.py, andcytotable/warehouse/iceberg.pywas migrated to canonical Google form (name (TYPE):) with types matching annotations exactly, and missingRaises:sections were added where functions raise. This is a developer-tooling/quality change with no runtime behavior changes; it complements the existingruffD-rules (presence/format) by adding signature-vs-docstring agreement.What is the nature of your change?
Checklist
Summary by CodeRabbit