Skip to content

Add pydoclint documentation checks - #95

Merged
Snuffy2 merged 7 commits into
mainfrom
Add-pydoclint
Aug 8, 2026
Merged

Add pydoclint documentation checks#95
Snuffy2 merged 7 commits into
mainfrom
Add-pydoclint

Conversation

@Snuffy2

@Snuffy2 Snuffy2 commented Aug 8, 2026

Copy link
Copy Markdown
Owner

Summary

Adds pydoclint to the prek checks and brings the repository's Google-style docstrings into compliance with the configured documentation contract.

What Changed

  • Added pydoclint 0.9.1 to the prek hook suite with the repository's Google-style rules.
  • Completed and corrected argument, return, and yield documentation across library modules, scripts, documentation helpers, and tests.
  • Added missing test callback parameter annotations where required for the documented signatures.

Why

Makes the existing documentation conventions enforceable in local and CI checks, so future API and test-helper changes keep their signatures and docstrings aligned.

Summary by CodeRabbit

  • Documentation
    • Improved API, command-line, helper, and test documentation with clearer parameter, return-value, and type descriptions.
    • Standardized documentation formatting for better consistency and readability.
  • Development Tools
    • Added automated documentation checks to help maintain complete and consistent docstrings.
  • Tests
    • Added clearer type annotations and expanded test documentation without changing test behavior.

Greptile Summary

The PR adds pydoclint to the repository’s prek checks and configures Google-style documentation validation. It updates docstrings and test callback annotations to align documented arguments, returns, yields, and exceptions with their signatures and behavior.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains; the previously reported traffic stream documentation issue is fixed in the current code.

Important Files Changed

Filename Overview
prek.toml Adds the pinned pydoclint hook to the local and CI-oriented prek suite.
pyproject.toml Configures pydoclint to enforce the repository’s Google-style documentation contract.
aiopnsense/traffic.py Clarifies traffic API documentation, including the first-event discard and timing-reset stream semantics identified in the prior review.
aiopnsense/client_transport.py Expands transport and streaming helper documentation without changing executable behavior.
tests/conftest.py Adds callback annotations and clearer fixture documentation while retaining isolated fake credentials and mocked sessions.

Reviews (5): Last reviewed commit: "Clarify docstring descriptions" | Re-trigger Greptile

@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The pull request standardizes Google-style docstrings across production code, scripts, and tests. It adds explicit type documentation and selected test annotations. It also adds pydoclint tooling and project configuration. Runtime behavior remains unchanged.

Changes

Documentation and linting

Layer / File(s) Summary
Production API docstrings
aiopnsense/*.py
Core client, helper, and traffic method docstrings now include consistent parameter and return descriptions.
Docstring lint configuration
prek.toml, pyproject.toml
The project adds the pydoclint hook and Google-style validation settings.
Script and Sphinx documentation
docs/source/conf.py, scripts/*.py
Sphinx configuration and command-line script docstrings now use explicit parameter and return types.
Test documentation and annotations
tests/*.py
Test docstrings now document arguments, returns, and yielded values. Selected fixture and parametrized test parameters now have explicit annotations.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 94.36% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding pydoclint documentation checks.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added documentation Improvements or additions to documentation code-quality labels Aug 8, 2026
@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  aiopnsense
  client.py
  client_endpoint.py
  client_queue.py
  client_transport.py
  helpers.py
  system.py
  traffic.py
  vouchers.py
Project Total  

This report was generated by python-coverage-comment-action

@read-the-docs-community

read-the-docs-community Bot commented Aug 8, 2026

Copy link
Copy Markdown

Comment thread aiopnsense/traffic.py Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 9

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
tests/test_vpn.py (2)

85-93: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Type and rename the unused list-getter parameter.

fake_safe_list_get does not read path, so Ruff reports ARG001. Rename it to _path, add -> list[object], and update the Args section.

🤖 Prompt for 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.

In `@tests/test_vpn.py` around lines 85 - 93, Update the fake_safe_list_get test
helper by renaming its unused path parameter to _path, adding the return
annotation list[object], and revising the Args documentation to use the new
parameter name.

Source: Linters/SAST tools


59-67: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Add return annotations to the nested dictionary fakes.

fake_safe_dict_get has no return annotation at Lines [59], [226], [268], and [447]. Add -> dict[str, Any] to each helper. Ruff reports ANN202.

As per coding guidelines, every Python function must include a return annotation.

Also applies to: 226-234, 268-276, 447-455

🤖 Prompt for 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.

In `@tests/test_vpn.py` around lines 59 - 67, Update each nested
fake_safe_dict_get helper at the four occurrences in tests/test_vpn.py to
declare the return type as dict[str, Any]. Keep their existing behavior and
docstrings unchanged, and ensure all four definitions satisfy the ANN202
requirement.

Sources: Coding guidelines, Linters/SAST tools

🤖 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 `@aiopnsense/client_queue.py`:
- Around line 29-55: Update the docstrings for _do_get and _do_get_from_stream,
including the corresponding _do_post documentation, to describe immediate
transport/HTTP operations rather than queued requests. Keep their parameter and
return descriptions aligned with the underlying transport methods.

In `@aiopnsense/traffic.py`:
- Around line 100-102: Restore behavior-specific Google-style docstrings at all
listed sites: in aiopnsense/traffic.py lines 100-102, document the raw payload,
rate-calculation interval, and include_per_second_rates effect; at lines
203-206, describe interval clamping, endpoint selection, fallback timing, and
normalized samples yielded after the initial timing event; in
aiopnsense/helpers.py line 44, identify self as the instance whose _throw_errors
flag controls propagation; at lines 397-398, describe value normalization and
its expected string representation; and in docs/source/conf.py lines 75-80 and
109, document each Sphinx hook argument, the mutable lines list, and the
application used to register the hook.

In `@pyproject.toml`:
- Around line 175-187: Update the pydoclint configuration by changing
check-return-types from false to true so annotated return types are validated
against documented return types; leave the other [tool.pydoclint] settings
unchanged.

In `@tests/test_client_transport.py`:
- Around line 985-997: Update the _FakeIncrementalDecoder.decode stub to rename
the unused data parameter to _data, and change its docstring Args entry
accordingly; leave the final-based decoding behavior unchanged.

In `@tests/test_firewall.py`:
- Around line 36-41: Replace broad Any annotations across tests/test_firewall.py
(lines 36-41, 72, 286-291, 536-541, 581, and 608), tests/test_speedtest.py
(lines 19-24, 40, 173, 208, 244, 288, 446, 469, and 490), tests/test_vpn.py
(lines 18-24, 59, 85, 114, 209, 226, 256, 268, 436, 447, 537, and 566), and
tests/test_vnstat.py (lines 13-18, 43, 59, 101, 124, 234, 266, 286, and 356)
with precise fixture, factory, path, monkeypatch, payload, ClientType, or
MakeClientFactory annotations matching each test's parameters; retain Any only
where required at a genuine test boundary.

In `@tests/test_scripts_aiopnsense_dump.py`:
- Around line 666-678: Update fake_run_endpoint’s client_arg annotation from Any
to the local FakeClient type, and change the matching docstring type from Any to
FakeClient. Leave the endpoint behavior and other parameter annotations
unchanged.

In `@tests/test_scripts_opnsense_api_call.py`:
- Around line 133-152: Update FakeSession.get and FakeSession.post to annotate
their keyword arguments as **kwargs: object instead of Any, and document
**kwargs (object) in each method’s Args section when required by the project’s
linting configuration.

In `@tests/test_unbound.py`:
- Around line 47-52: Replace the Any annotations in tests/test_unbound.py at
lines 47-52, 85-92, and 370-386 with the shared ClientType and the specified
concrete types: ClientType for make_client; ClientType and object for
make_client and api_response; and ClientType, str, str | None, object, object,
and bool for the six parameters. Update each corresponding docstring type entry
to match, including tests/test_unbound.py line ranges 47-52, 85-92, and 370-386.

In `@tests/test_vpn.py`:
- Around line 114-119: Remove the unused make_client parameter from
test_wireguard_processing_and_updates and delete its corresponding Args
documentation entry, leaving the test behavior unchanged.

---

Outside diff comments:
In `@tests/test_vpn.py`:
- Around line 85-93: Update the fake_safe_list_get test helper by renaming its
unused path parameter to _path, adding the return annotation list[object], and
revising the Args documentation to use the new parameter name.
- Around line 59-67: Update each nested fake_safe_dict_get helper at the four
occurrences in tests/test_vpn.py to declare the return type as dict[str, Any].
Keep their existing behavior and docstrings unchanged, and ensure all four
definitions satisfy the ANN202 requirement.
🪄 Autofix

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: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 8d8cc08c-39dd-476b-b338-d743699a9dc2

📥 Commits

Reviewing files that changed from the base of the PR and between 9a48510 and 797b6dc.

📒 Files selected for processing (35)
  • aiopnsense/client_base.py
  • aiopnsense/client_endpoint.py
  • aiopnsense/client_queue.py
  • aiopnsense/client_transport.py
  • aiopnsense/helpers.py
  • aiopnsense/traffic.py
  • aiopnsense/vnstat.py
  • docs/source/conf.py
  • prek.toml
  • pyproject.toml
  • scripts/_opnsense_live_common.py
  • scripts/aiopnsense_dump.py
  • scripts/opnsense_api_call.py
  • tests/conftest.py
  • tests/test_client_base.py
  • tests/test_client_endpoint.py
  • tests/test_client_queue.py
  • tests/test_client_transport.py
  • tests/test_docs_conf.py
  • tests/test_exceptions.py
  • tests/test_firewall.py
  • tests/test_firmware.py
  • tests/test_helpers.py
  • tests/test_nut.py
  • tests/test_scripts_aiopnsense_dump.py
  • tests/test_scripts_live_common.py
  • tests/test_scripts_opnsense_api_call.py
  • tests/test_smart.py
  • tests/test_speedtest.py
  • tests/test_system.py
  • tests/test_telemetry.py
  • tests/test_traffic.py
  • tests/test_unbound.py
  • tests/test_vnstat.py
  • tests/test_vpn.py
💤 Files with no reviewable changes (3)
  • tests/test_smart.py
  • aiopnsense/vnstat.py
  • tests/test_telemetry.py

Comment thread aiopnsense/client_queue.py Outdated
Comment thread aiopnsense/traffic.py Outdated
Comment thread pyproject.toml
Comment thread tests/test_client_transport.py Outdated
Comment thread tests/test_firewall.py Outdated
Comment thread tests/test_scripts_aiopnsense_dump.py
Comment thread tests/test_scripts_opnsense_api_call.py
Comment thread tests/test_unbound.py Outdated
Comment thread tests/test_vpn.py Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 `@aiopnsense/helpers.py`:
- Around line 398-407: Update the Returns section of the normalized API
comparison function’s docstring to declare the return type as bool:, while
preserving the existing description of the returned value.
🪄 Autofix

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: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: eba0df23-af01-4315-887a-1d2d087a0151

📥 Commits

Reviewing files that changed from the base of the PR and between 797b6dc and a593847.

📒 Files selected for processing (20)
  • aiopnsense/client_queue.py
  • aiopnsense/helpers.py
  • aiopnsense/traffic.py
  • aiopnsense/vnstat.py
  • docs/source/conf.py
  • pyproject.toml
  • tests/conftest.py
  • tests/test_client_endpoint.py
  • tests/test_client_transport.py
  • tests/test_firewall.py
  • tests/test_helpers.py
  • tests/test_scripts_aiopnsense_dump.py
  • tests/test_scripts_live_common.py
  • tests/test_scripts_opnsense_api_call.py
  • tests/test_smart.py
  • tests/test_speedtest.py
  • tests/test_telemetry.py
  • tests/test_unbound.py
  • tests/test_vnstat.py
  • tests/test_vpn.py

Comment thread aiopnsense/helpers.py
@Snuffy2
Snuffy2 merged commit b08bb21 into main Aug 8, 2026
13 checks passed
@Snuffy2
Snuffy2 deleted the Add-pydoclint branch August 8, 2026 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code-quality documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant