Skip to content

docs: complete Google-style docstring coverage (99.2% → 100%)#37

Open
williaby wants to merge 2 commits into
mainfrom
claude/add-library-docstrings-sxMuY
Open

docs: complete Google-style docstring coverage (99.2% → 100%)#37
williaby wants to merge 2 commits into
mainfrom
claude/add-library-docstrings-sxMuY

Conversation

@williaby
Copy link
Copy Markdown
Contributor

Summary

Audited the library against the four-step docstring brief (module / class / function & method / type hints) and filled in the only three items still missing a docstring. Every other public module, class, and function already has a Google-style docstring (Args: / Returns: / Raises:), so the diff is small and surgical — no business logic changes.

Interrogate coverage (before / after)

Measured with uvx interrogate -v src/ packages/*/src/ (interrogate 1.7.0).

Total Missing Coverage
Before 374 3 99.2 %
After 374 0 100.0 %

Items that were missing

The three nodes interrogate flagged as MISSED, all of which are now documented:

  1. src/python_libs/middleware/__init__.py — empty file, no module docstring. Added a module docstring describing the namespace package.
  2. cloudflare_auth.utils.mask_sensitive_data.mask_match (utils.py:224) — inner regex-substitution callback. Added a Google-style docstring and parameter / return type annotations (re.Match[str] -> str, using only the already-imported stdlib re module — no new dependencies).
  3. cloudflare_auth.middleware_enhanced.require_tier.dependency (middleware_enhanced.py:723) — closure returned as a FastAPI dependency. Added a docstring describing the LIMITED < FULL < ADMIN tier ordering and the HTTPException 403 raised when the user's tier is below the required minimum.

Why so few changes?

The library was already heavily documented prior to this PR:

  • All JWT files (cloudflare_auth.validators, models, middleware, middleware_enhanced) already document expected token format, validated claims, exceptions raised, and security assumptions (e.g. RS256 + Cloudflare-issued JWKS, audience/issuer validation, expiration checking).
  • All GCS files (gcs_utilities.client, exceptions) already document the bucket / key contract, the env-var configuration (GCP_SA_KEY, GCS_BUCKET, GCP_PROJECT), and the NotFoundGCSNotFoundError mapping.
  • The existing FastAPI Request parameters in csrf.validate_request and utils.get_client_ip are intentionally left un-annotated with # noqa: ANN001 because fastapi / starlette are optional extras ([project.optional-dependencies].fastapi) — adding a hard import would violate the brief's "Do not introduce new dependencies" rule. These were left as-is.

Verification

  • uvx interrogate src/ packages/*/src/PASSED (minimum: 80.0%, actual: 100.0%)
  • uv run ruff check on the changed files → All checks passed!
  • pytest tests/ in packages/cloudflare-auth111 passed
  • Smoke-tested mask_sensitive_data, sanitize_email, sanitize_for_logging end-to-end — output identical to pre-change behavior.

Test plan

  • Interrogate reports 100 % coverage
  • Ruff clean on changed files
  • cloudflare-auth test suite passes (111/111)
  • No public API surface changes (docstrings + one inner-function type annotation only)

Generated by Claude Code

…coverage

Adds the three docstrings flagged by interrogate as missing:

- src/python_libs/middleware/__init__.py: module docstring for the
  middleware namespace package (file was previously empty).
- cloudflare_auth.utils.mask_sensitive_data.mask_match: docstring and
  type annotations (re.Match[str] -> str) for the inner replacement
  callback used with re.sub.
- cloudflare_auth.middleware_enhanced.require_tier.dependency: docstring
  for the closure returned as a FastAPI dependency, describing tier
  ordering and the HTTPException raised when a user's tier is below
  the required minimum.

No behavior changes. Interrogate coverage: 99.2% -> 100.0%.
Copilot AI review requested due to automatic review settings May 15, 2026 22:43
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 15, 2026

Warning

Rate limit exceeded

@williaby has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 45 minutes and 35 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: d64b314b-9db7-419b-bfd6-988f495dea73

📥 Commits

Reviewing files that changed from the base of the PR and between c0eb24a and 062e9fb.

📒 Files selected for processing (4)
  • CHANGELOG.md
  • packages/cloudflare-auth/src/cloudflare_auth/middleware_enhanced.py
  • packages/cloudflare-auth/src/cloudflare_auth/utils.py
  • src/python_libs/middleware/__init__.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/add-library-docstrings-sxMuY

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 and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR completes docstring coverage across the repo by adding the remaining missing docstrings (and one inner-function type annotation) to reach 100% interrogate coverage, without changing runtime behavior.

Changes:

  • Added a module docstring for python_libs.middleware.
  • Added a docstring + re.Match[str] -> str type hints for the mask_sensitive_data regex callback.
  • Added a docstring for the require_tier() FastAPI dependency closure documenting tier ordering and raised errors.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/python_libs/middleware/__init__.py Adds a new module docstring for the middleware package.
packages/cloudflare-auth/src/cloudflare_auth/utils.py Documents and types the mask_match callback used by mask_sensitive_data.
packages/cloudflare-auth/src/cloudflare_auth/middleware_enhanced.py Documents the require_tier() dependency closure behavior and errors.

Comment thread src/python_libs/middleware/__init__.py Outdated
@@ -0,0 +1,6 @@
"""Middleware components for Python Libs.

This namespace package is reserved for middleware modules (request/response
Comment on lines +227 to +232
For email-like matches (containing ``@``), masks the local and domain
parts separately. For all other matches, replaces every character
with ``*``.

Args:
match: Regex match object produced by :func:`re.sub`.
Comment on lines +724 to +738
"""Validate that the current user meets ``minimum_tier``.

Resolved as a FastAPI dependency by :func:`require_tier`. The user is
loaded from request state via :func:`get_current_user`; tiers are
ordered ``LIMITED < FULL < ADMIN``.

Args:
request: Incoming FastAPI/Starlette request.

Returns:
The authenticated :class:`CloudflareUser`.

Raises:
HTTPException: ``403`` if the user's tier is below
``minimum_tier``; ``401`` (via :func:`get_current_user`) if
- Rephrase middleware/__init__.py docstring: drop the inaccurate
  "namespace package" wording (a directory with __init__.py is a regular
  package per PEP 420 terminology).
- Convert the new docstrings in cloudflare_auth/utils.py and
  cloudflare_auth/middleware_enhanced.py from Sphinx/reST markup (:func:,
  :class:, ``double-backticks``) to plain Google-style prose so they
  match the surrounding docstrings in those files and render cleanly in
  non-Sphinx tooling.
- Add Documentation entry to [Unreleased] in CHANGELOG.md to satisfy
  the Changelog Check.
@sonarqubecloud
Copy link
Copy Markdown

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants