Skip to content

chore(ruff): adopt google docstring convention and enforce DOC102/DOC402#1184

Open
dgarros wants to merge 2 commits into
infrahub-developfrom
dga/brain-doc-validate-jg0v6
Open

chore(ruff): adopt google docstring convention and enforce DOC102/DOC402#1184
dgarros wants to merge 2 commits into
infrahub-developfrom
dga/brain-doc-validate-jg0v6

Conversation

@dgarros

@dgarros dgarros commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Why

The SDK's docstrings aren't verified against the code, so parameters, return/yield
sections, and descriptions can drift out of sync silently. We're turning on ruff's
D/DOC (pydocstyle + pydoclint) rules incrementally — this is the first
enforceable slice, focused on docstring-vs-signature accuracy.

Non-goals: clearing the large "missing docstring" (D10x) backlog — those stay
parked for later phases.

What changed

  • Docstring accuracy is now CI-enforced for two rules: DOC102 (a documented
    parameter that isn't in the signature) and DOC402 (a generator whose yield
    isn't documented).
  • Set the pydocstyle convention to google (matches the codebase). Beyond
    style, this lets the DOC rules correctly parse Args/Returns/Yields
    sections — which cleared ~35 false-positive DOC201 findings and let
    D203/D213/D401/D404 drop from manual ignores.
  • Fixed the violations this surfaced: corrected a stale size param (actually
    prefix_length) and placeholder/incorrect param docs in ConfiguredSettings,
    and documented the yields of the streaming HTTP context managers and two
    generators.
  • D301 intentionally left parked: its fix (raw docstring) would turn Typer's
    \b no-wrap marker into literal text and break CLI --help formatting.

No runtime behavior changes — only docstrings, regenerated CLI/SDK reference docs,
and lint config.

How to test

uv run ruff check                          # clean
uv run ruff check --select DOC102,DOC402   # 0 findings — enforced and clean
uv run invoke docs-validate                # generated docs in sync

Impact & rollout

  • Backward compatibility: none; docstring/lint-only.
  • Config/env changes: ruff convention = "google"; DOC102/DOC402 enforced going forward.

Summary by cubic

Adopts the Google docstring convention in ruff and enforces docstring/signature accuracy with DOC102 and DOC402. Fixes mismatched params and adds missing Yields docs; no runtime changes.

  • Refactors
    • Enable DOC102/DOC402 in CI; keep D301 ignored due to Typer \b.
    • Set [tool.ruff.lint.pydocstyle].convention = "google"; drop manual ignores for D203/D213/D401/D404; trim redundant comments in pyproject.toml.
    • infrahub_sdk.client: rename size to prefix_length in docs; add Yields for streaming (sync/async).
    • infrahub_sdk/ctl/config.py: correct param name to config_file; clarify config_data.
    • Pytest plugin and tests: add Yields docs for generators.
    • Regenerated SDK reference to reflect prefix_length.

Written for commit f176345. Summary will update on new commits.

Review in cubic

Set the pydocstyle convention to google so the DOC (pydoclint) rules parse
Args/Returns/Yields sections correctly, which also cleared a batch of
false-positive DOC201 findings. D203/D213/D401/D404 are now handled by the
convention instead of manual ignores.

Un-park and fix the docstring/signature-consistency rules DOC102 (extraneous
parameter) and DOC402 (missing Yields):
- client.py: document the streaming context managers' yields; rename the
  stale `size` param to the actual `prefix_length`
- ctl/config.py: correct the `config_file` param name and descriptions
- loader.py, test_repository.py: document generator yields

D301 stays parked: converting to a raw string breaks Typer's `\b` no-wrap
marker in CLI command docstrings.
@dgarros dgarros added type/housekeeping Maintenance task ci/skip-changelog Don't include this PR in the changelog labels Jul 15, 2026
@github-actions github-actions Bot added the type/documentation Improvements or additions to documentation label Jul 15, 2026
@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

@@                 Coverage Diff                  @@
##           infrahub-develop    #1184      +/-   ##
====================================================
+ Coverage             82.49%   83.01%   +0.51%     
====================================================
  Files                   139      139              
  Lines                 12210    12365     +155     
  Branches               1823     1846      +23     
====================================================
+ Hits                  10073    10265     +192     
+ Misses                 1576     1532      -44     
- Partials                561      568       +7     
Flag Coverage Δ
integration-tests 40.48% <0.00%> (-0.26%) ⬇️
python-3.10 56.95% <100.00%> (+0.96%) ⬆️
python-3.11 56.95% <100.00%> (+0.94%) ⬆️
python-3.12 56.93% <100.00%> (+0.93%) ⬆️
python-3.13 56.95% <100.00%> (+0.94%) ⬆️
python-3.14 56.94% <100.00%> (+0.94%) ⬆️
python-filler-3.12 22.31% <0.00%> (-0.20%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
infrahub_sdk/client.py 79.59% <100.00%> (+3.05%) ⬆️
infrahub_sdk/ctl/config.py 67.85% <ø> (ø)
infrahub_sdk/pytest_plugin/loader.py 78.72% <ø> (ø)

... and 12 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 6 files

Re-trigger cubic

@dgarros
dgarros marked this pull request as ready for review July 16, 2026 04:23
@dgarros
dgarros requested a review from a team as a code owner July 16, 2026 04:23
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 16, 2026

Copy link
Copy Markdown

Deploying infrahub-sdk-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: f176345
Status: ✅  Deploy successful!
Preview URL: https://a2594ac0.infrahub-sdk-python.pages.dev
Branch Preview URL: https://dga-brain-doc-validate-jg0v6.infrahub-sdk-python.pages.dev

View logs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci/skip-changelog Don't include this PR in the changelog type/documentation Improvements or additions to documentation type/housekeeping Maintenance task

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants