Skip to content

chore: replace darglint with pydoclint#45

Open
williaby wants to merge 8 commits into
mainfrom
chore/replace-darglint-with-pydoclint
Open

chore: replace darglint with pydoclint#45
williaby wants to merge 8 commits into
mainfrom
chore/replace-darglint-with-pydoclint

Conversation

@williaby
Copy link
Copy Markdown
Contributor

@williaby williaby commented May 31, 2026

Summary

Migrates from the archived darglint library to pydoclint per the updated standards manifest (TOOL-007/PC-006/TOOL-013).

  • Replaces darglint>=1.8.1 with pydoclint>=0.8.4 in dev dependencies
  • Removes [tool.darglint] config block; adds [tool.pydoclint] with google style
  • Removes the local darglint pre-commit hook; adds the upstream pydoclint hook (rev 88d83c94156c5e51a09938e77019f2c58e92ab58 / 0.8.4)
  • Removes darglint from ci: skip: list
  • Removes .darglint config file via git rm
  • Updates uv.lock: removes darglint 1.8.1, adds pydoclint 0.8.4 + docstring-parser-fork 0.0.14

Posture: keep raises checks, require arg type hints, lenient on Returns/Yields missing sections.

Docstring findings (DONE_WITH_CONCERNS)

Running uv run pydoclint src/ packages/ reveals 807 findings across the codebase, exceeding the ~30-finding auto-fix threshold. These require a separate docstring-fix pass and are tracked as follow-on work.

DOC histogram:

  • DOC109/110 (arg type hints missing in docstring): 157 each
  • DOC203 (return type mismatch): 174
  • DOC105 (arg type hint mismatch): 156
  • DOC301 (init docstring should merge with class): 33
  • DOC101/103 (arg count/name mismatch): 28 each
  • DOC503 (exception not in raises section): 19
  • DOC603/605 (class attribute mismatch): 14/11
  • DOC502/602 (excess raises/attributes): 10/8
  • DOC601 (fewer class attrs in docstring): 5
  • DOC501 (exception not documented): 4
  • DOC107/106: 2/1

Test plan

  • CI passes (pre-commit hooks, uv lock valid)
  • grep -rn darglint pyproject.toml .pre-commit-config.yaml returns empty
  • uv run pydoclint --version shows 0.8.4
  • Separate follow-on PR to fix 807 DOC findings in docstrings

Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Updated development tooling configuration, replacing darglint with pydoclint for enhanced docstring validation
    • Standardized code documentation formatting across modules to ensure consistent parameter and return type descriptions throughout the codebase

Migrate from archived darglint to pydoclint per updated standards
manifest. Replaces [tool.darglint] config and local hook with the
upstream pydoclint pre-commit hook. Removes .darglint config file.
Lockfile swaps darglint 1.8.1 for pydoclint 0.8.4.

Posture: keep raises checks, require arg type hints, lenient on
Returns/Yields missing sections.

NOTE: 807 DOC findings exist across src/ and packages/ (histogram
below); these require a separate docstring-fix pass.

DOC histogram: DOC109/110x157, DOC203x174, DOC105x156, DOC301x33,
DOC103/101x28, DOC503x19, DOC603x14, DOC605x11, DOC502x10,
DOC602x8, DOC601x5, DOC501x4, DOC107x2, DOC106x1.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 31, 2026 04:25
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 31, 2026

Review Change Stack

Warning

Review limit reached

@williaby, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 29 minutes and 4 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, 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 include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: c5e022ea-dfb3-4179-a1df-618a43bb2e1b

📥 Commits

Reviewing files that changed from the base of the PR and between 0844183 and 780db9d.

📒 Files selected for processing (16)
  • packages/cloudflare-api/src/cloudflare_api/ip_groups/cli.py
  • packages/cloudflare-api/src/cloudflare_api/ip_groups/config.py
  • packages/cloudflare-api/src/cloudflare_api/ip_groups/fetchers.py
  • packages/cloudflare-api/src/cloudflare_api/ip_groups/manager.py
  • packages/cloudflare-auth/src/cloudflare_auth/config.py
  • packages/cloudflare-auth/src/cloudflare_auth/csrf.py
  • packages/cloudflare-auth/src/cloudflare_auth/middleware.py
  • packages/cloudflare-auth/src/cloudflare_auth/middleware_enhanced.py
  • packages/cloudflare-auth/src/cloudflare_auth/models.py
  • packages/cloudflare-auth/src/cloudflare_auth/rate_limiter.py
  • packages/cloudflare-auth/src/cloudflare_auth/redis_sessions.py
  • packages/cloudflare-auth/src/cloudflare_auth/security_helpers.py
  • packages/cloudflare-auth/src/cloudflare_auth/sessions.py
  • packages/cloudflare-auth/src/cloudflare_auth/utils.py
  • packages/cloudflare-auth/src/cloudflare_auth/validators.py
  • packages/cloudflare-auth/src/cloudflare_auth/whitelist.py

Walkthrough

This PR replaces Darglint with Pydoclint for docstring validation and standardizes docstring formatting across the codebase. The tool migration updates dependencies and configuration, while docstring changes introduce consistent type-annotated parameter and return value documentation throughout multiple packages.

Changes

Docstring Validation Tool Migration and Standardization

Layer / File(s) Summary
Tool migration configuration
pyproject.toml, .pre-commit-config.yaml
Removed Darglint dependency and configuration; added Pydoclint dependency and tool configuration specifying Google style, argument type-hint validation, and return section requirements. Updated CI hook skip list to exclude qlty-full and replace Darglint hook with Pydoclint.
CloudflareAPIClient error handler refactoring
packages/cloudflare-api/src/cloudflare_api/client.py
_handle_api_error method now annotates return type as NoReturn to explicitly declare it always raises; exception handlers across multiple methods simplified to remove redundant raise statements. All public method docstrings updated to use typed parameter and return descriptions (e.g., name (str), IPList | None).
CloudflareAPI exception documentation
packages/cloudflare-api/src/cloudflare_api/exceptions.py
Exception class docstrings standardized to use typed Args: sections documenting constructor parameters, replacing prior Attributes: sections and unstructured descriptions across CloudflareAPIError and subclasses.
CloudflareAPI models and settings documentation
packages/cloudflare-api/src/cloudflare_api/models.py, packages/cloudflare-api/src/cloudflare_api/settings.py
Pydantic model docstrings updated with explicit type annotations for attributes (e.g., id (str | None), ip (str)); settings class documentation expanded to describe configuration options and method return types.
Core framework exception standardization
src/python_libs/core/exceptions.py
Exception class hierarchy standardized with typed Args: sections in all __init__ docstrings across ProjectBaseError and derived classes (ValidationError, ResourceNotFoundError, AuthenticationError, AuthorizationError, ExternalServiceError, APIError, DatabaseError, BusinessLogicError), replacing narrative descriptions.
Utilities and configuration documentation
packages/gcs-utilities/src/gcs_utilities/client.py, src/python_libs/core/config.py, packages/gemini-image/src/gemini_image/generator.py, packages/gemini-image/src/gemini_image/utils.py, src/python_libs/utils/logging.py
All public method and function docstrings reformatted to use consistent typed parameter and return descriptions with explicit type annotations; no functional logic or signatures changed.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

python, documentation, dependencies

🐰 A rabbit's tail twitch of glee,
For docstrings now consistent, you see,
Pydoclint's the way,
No more Darglint's sway,
Type hints dance in harmony!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: migrating from darglint to pydoclint tool for docstring validation.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/replace-darglint-with-pydoclint

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.

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

Migrates docstring argument validation from the archived darglint to the actively maintained pydoclint per updated standards (TOOL-007/PC-006/TOOL-013). The configuration keeps raises checks enabled and remains lenient on Returns/Yields sections, matching the previous darglint posture. The PR description notes 807 existing docstring findings to be addressed in a follow-on PR.

Changes:

  • Swap darglint>=1.8.1 for pydoclint>=0.8.4 in pyproject.toml dev deps and replace [tool.darglint] with [tool.pydoclint] (google style, raises enabled, lenient Returns/Yields).
  • Replace local darglint pre-commit hook with the upstream jsh9/pydoclint hook pinned to 0.8.4, and remove darglint from the CI skip: list.
  • Delete the legacy .darglint file and update uv.lock (remove darglint, add pydoclint + docstring-parser-fork).

Reviewed changes

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

File Description
pyproject.toml Replaces darglint dep and config block with pydoclint equivalent (google style, type-hint checks, lenient returns/yields).
.pre-commit-config.yaml Switches from local darglint hook to upstream pydoclint hook; removes darglint from CI skip list.
.darglint Removes the legacy darglint config file (config now lives in pyproject.toml).
uv.lock Drops darglint 1.8.1; adds pydoclint 0.8.4 and its docstring-parser-fork transitive dep.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 31, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

williaby and others added 4 commits May 30, 2026 21:55
Add argument and return type hints to docstrings in src/python_libs to
match function signatures exactly. Move __init__ argument docs into the
class docstring Args sections per pydoclint DOC301 guidance. Document
the pydantic model_config class attribute without a type hint (the
assignment carries no annotation).

src/ now reports zero pydoclint violations.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add argument and return type hints to docstrings to match signatures
exactly. Remove ImportError from generate_image Raises section: it is
raised in the _get_genai helper, not directly in the function body, so
pydoclint does not count it.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add argument and return type hints to docstrings to match signatures
exactly. Move GCSClient.__init__ argument docs into the class docstring.
Remove Raises entries for exceptions raised only in helper methods
(FileNotFoundError via _validate_local_path) and drop the Raises
section from upload_directory which has no direct raise statements.
Document the broad re-raise in _get_or_create_bucket.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add argument and return type hints to docstrings and move __init__
argument docs into class docstrings. Document pydantic model fields with
their annotated types. Refactor CloudflareAPIClient._handle_api_error to
NoReturn (it always raises) and drop the unreachable bare re-raises so
the Raises sections reflect the exceptions actually raised in each body:
delegating methods document none, methods that raise CloudflareConflict-
Error directly keep that entry. Behavior is unchanged; 83 cloudflare-api
tests pass.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai coderabbitai Bot added documentation Improvements or additions to documentation python dependencies labels May 31, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 6

🤖 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 `@packages/gcs-utilities/src/gcs_utilities/client.py`:
- Around line 51-53: Update the GCSClient class docstring to list all exceptions
that __init__ can raise: add GCSConfigError for missing credentials and
GCSNotFoundError for missing bucket when auto-create is false alongside the
existing GCSAuthError; locate the constructor GCSClient.__init__ and ensure the
"Raises:" section mentions GCSAuthError, GCSConfigError, and GCSNotFoundError
with short descriptions matching the actual error conditions.
- Around line 178-179: Update the _get_or_create_bucket docstring to stop
listing a broad Exception: instead document the actual exceptions the function
can raise—explicitly mention that it re-raises GCSNotFoundError (when caught by
the broad handler) and raises GCSAuthError for authentication failures; adjust
the Raises section text to accurately describe those two exception cases and
remove the generic Exception entry so callers know the precise error types to
handle.

In `@packages/gemini-image/src/gemini_image/generator.py`:
- Around line 92-94: The docstring for generate_image currently only documents
ValueError but _get_genai can raise ImportError when the google-genai dependency
is missing; update the generate_image docstring (the Raises section) to include
ImportError with a brief description like "If google-genai is not installed or
cannot be imported" and ensure the wording references the call to _get_genai so
readers know the missing-dependency case is covered.

In `@pyproject.toml`:
- Around line 663-665: The pyproject.toml contains invalid pydoclint option
keys: replace the unsupported keys require-return-section-when-returning-values
and require-yield-section-when-yielding-values with the correct documented keys
require-return-section-when-returning-nothing and
require-yield-section-when-yielding-nothing respectively so the pydoclint
settings take effect; update the entries in the [tool.pydoclint] table (the two
key names shown) to the corrected names and preserve the boolean values you
intended.

In `@src/python_libs/core/config.py`:
- Line 17: Update the Attributes docstring entry for model_config to include an
explicit type annotation; replace the current line "model_config: Pydantic
settings configuration." with something like "model_config (dict): Pydantic
settings configuration." (or "model_config (Mapping[str, Any]): Pydantic
settings configuration." if you prefer a more generic type) so the Attributes
section consistently lists types for all attributes and follows the Google-style
docstring convention.

In `@src/python_libs/utils/logging.py`:
- Around line 44-53: Add missing "Returns" and "Raises" sections to the
Google-style docstrings for setup_logging and log_performance: update the
docstring for setup_logging to include a Returns clause (e.g., returning the
configured logging.Logger or None) and a Raises clause documenting any
exceptions that can be propagated during logger configuration (e.g., ValueError
for invalid level or OSError for handler setup), and update log_performance
docstring similarly to state what it returns (if anything) and which exceptions
it may raise (e.g., KeyError or RuntimeError if context or timer retrieval
fails); ensure the exact function names setup_logging and log_performance are
updated and the wording matches existing Args style and project docstring
policy.
🪄 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: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: d65e5692-9dde-418c-a83a-c83484dad484

📥 Commits

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

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock, !**/*.lock
📒 Files selected for processing (13)
  • .darglint
  • .pre-commit-config.yaml
  • packages/cloudflare-api/src/cloudflare_api/client.py
  • packages/cloudflare-api/src/cloudflare_api/exceptions.py
  • packages/cloudflare-api/src/cloudflare_api/models.py
  • packages/cloudflare-api/src/cloudflare_api/settings.py
  • packages/gcs-utilities/src/gcs_utilities/client.py
  • packages/gemini-image/src/gemini_image/generator.py
  • packages/gemini-image/src/gemini_image/utils.py
  • pyproject.toml
  • src/python_libs/core/config.py
  • src/python_libs/core/exceptions.py
  • src/python_libs/utils/logging.py
💤 Files with no reviewable changes (1)
  • .darglint

Comment on lines +51 to +53
Raises:
GCSAuthError: If authentication fails.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Document all constructor exception paths.

GCSClient.__init__ can also surface GCSConfigError (missing credentials) and
GCSNotFoundError (missing bucket when auto-create is off), but the class docstring
currently lists only GCSAuthError.

🤖 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 `@packages/gcs-utilities/src/gcs_utilities/client.py` around lines 51 - 53,
Update the GCSClient class docstring to list all exceptions that __init__ can
raise: add GCSConfigError for missing credentials and GCSNotFoundError for
missing bucket when auto-create is false alongside the existing GCSAuthError;
locate the constructor GCSClient.__init__ and ensure the "Raises:" section
mentions GCSAuthError, GCSConfigError, and GCSNotFoundError with short
descriptions matching the actual error conditions.

Comment on lines +178 to +179
Exception: Re-raised if it is a GCSNotFoundError caught by the
broad handler.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Avoid broad Exception in Raises docstring.

_get_or_create_bucket re-raises GCSNotFoundError and otherwise raises
GCSAuthError; documenting a generic Exception is inaccurate and weakens API clarity.

🤖 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 `@packages/gcs-utilities/src/gcs_utilities/client.py` around lines 178 - 179,
Update the _get_or_create_bucket docstring to stop listing a broad Exception:
instead document the actual exceptions the function can raise—explicitly mention
that it re-raises GCSNotFoundError (when caught by the broad handler) and raises
GCSAuthError for authentication failures; adjust the Raises section text to
accurately describe those two exception cases and remove the generic Exception
entry so callers know the precise error types to handle.

Comment on lines 92 to 94
Raises:
ValueError: If model_key is invalid or API key is missing.
ImportError: If google-genai is not installed.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Document ImportError in generate_image Raises section.

generate_image() calls _get_genai() (Line 96), which raises ImportError when google-genai is unavailable, but the docstring only lists ValueError.

Suggested docstring fix
     Raises:
         ValueError: If model_key is invalid or API key is missing.
+        ImportError: If the google-genai package is not installed.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Raises:
ValueError: If model_key is invalid or API key is missing.
ImportError: If google-genai is not installed.
Raises:
ValueError: If model_key is invalid or API key is missing.
ImportError: If the google-genai package is not installed.
🤖 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 `@packages/gemini-image/src/gemini_image/generator.py` around lines 92 - 94,
The docstring for generate_image currently only documents ValueError but
_get_genai can raise ImportError when the google-genai dependency is missing;
update the generate_image docstring (the Raises section) to include ImportError
with a brief description like "If google-genai is not installed or cannot be
imported" and ensure the wording references the call to _get_genai so readers
know the missing-dependency case is covered.

Comment thread pyproject.toml
Comment on lines +663 to +665
require-return-section-when-returning-nothing = false
require-return-section-when-returning-values = false
require-yield-section-when-yielding-values = false
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

pydoclint 0.8.4 valid pyproject.toml options require-yield-section-when-yielding-nothing behavior on unknown config keys

💡 Result:

  1. pydoclint 0.8.4: valid [tool.pydoclint] options in pyproject.toml pydoclint reads configuration from TOML under a [tool.pydoclint] section (and the default config filename is pyproject.toml when using the --config option) [1][2]. The official “Configuration options” page lists the supported options (i.e., the ones you can set in TOML) [1]. 2) Option require-yield-section-when-yielding-nothing I could not find a page in the official documentation (config options list / violation codes / config how-to) that mentions a configuration key named require-yield-section-when-yielding-nothing for pydoclint 0.8.4. The official yield-related violation code DOC403 explains the policy “Yields section in the docstring, but there are no “yield” statements, or the return annotation is not a Generator/Iterator/Iterable” [3], but this does not map to a config key with that exact name in the config options list [1]. 3) Behavior on unknown config keys The official docs I found explain how to point pydoclint at a config file and that CLI flags take precedence, but they do not describe what happens when the TOML contains unknown keys (e.g., ignore vs warn vs error) [1][2]. So I can’t state the behavior with evidence from the sources I retrieved. What you can do - Verify the correct TOML key name against the official pydoclint configuration options list [1]. - If you need the exact unknown-key behavior, you’ll likely need to confirm it empirically (run pydoclint with a deliberately misspelled option in [tool.pydoclint]) or consult the project’s source/CLI parsing code; it wasn’t documented in the pages retrieved.

Citations:


🌐 Web query:

pydoclint config_options require-return-section-when-returning-none require-return-section-when-returning-nothing

💡 Result:

In pydoclint, the configuration option is --require-return-section-when-returning-nothing (short form: -rrs) [1]. There is no official configuration option named "require-return-section-when-returning-none"; the aforementioned option covers both cases [1][2]. When this option is set to False (the default), a "return" section is not required in the docstring if the function implicitly returns None (e.g., has no return statement or uses -> None as the return annotation) or does not return at all (e.g., has a NoReturn type) [1][2]. Setting this option to True enforces the presence of a "return" section even in these scenarios [2][3].

Citations:


🌐 Web query:

pydoclint config_options require-yield-section-when-yielding-nothing

💡 Result:

The configuration option --require-yield-section-when-yielding-nothing in pydoclint controls whether a Yields section is required in a docstring when a function yields None [1]. Key details include: - Default Value: True [1]. - Short Form: -rys [1]. - Functionality: When set to True (default), pydoclint requires a Yields section in the docstring even if the function only yields None [1]. When set to False, a Yields section is not mandatory in the docstring if the function yields None [1]. This option helps maintain consistent documentation standards for generator functions [1]. If you are using pydoclint via a configuration file (such as pyproject.toml), you can explicitly set this to false if you prefer not to document trivial yields of None [1][2].

Citations:


🌐 Web query:

pydoclint 0.8.4 unknown keys behavior click default_map ignore error

💡 Result:

There is no specific interaction between pydoclint 0.8.4 and Click's default_map regarding "unknown keys." Pydoclint is a docstring linter and does not interact with the command-line argument parsing or context configuration of the CLI applications it may be linting [1][2]. If you are experiencing issues with "unknown keys" in Click's default_map, this behavior is governed by the Click library itself, not pydoclint. In recent versions of Click, there have been updates to how default_map is processed, particularly regarding the handling of internal sentinels like UNSET [3][4][5] and multi-value parameter parsing [6][5]. If your application is failing due to unexpected keys or values in your default_map, consider the following standard Click troubleshooting steps: 1. Ignore Unknown Options: If the "unknown keys" are actually unknown command-line options that you want Click to ignore, you can use the context setting ignore_unknown_options=True [7][8]. context_settings=dict(ignore_unknown_options=True) 2. Verify default_map Structure: Ensure that the structure of your default_map matches the names of the parameters defined in your Click commands. Mismatches or unexpected data types (especially when using nargs > 1) can cause errors [9][6][5]. 3. Update Click: Recent versions of Click (such as 8.4.x) include fixes for edge cases involving UNSET in default_map and parameter processing [5]. Ensure you are using the latest stable version of Click to benefit from these improvements. Pydoclint is primarily concerned with validating docstring content against function signatures [1][2][10] and is unrelated to the runtime CLI argument processing logic.

Citations:


🌐 Web query:

pydoclint default_map [tool.pydoclint] click

💡 Result:

In pydoclint, the configuration key path [tool.pydoclint] is read from your TOML config file (by default, the CLI flag --config points to pyproject.toml), and the relevant options can include the ones you’d like to “map” (e.g., baseline, style, exclude, etc.). The tool does not appear to have a built-in setting named exactly default_map under [tool.pydoclint], nor is there evidence of a click-specific default_map [tool.pydoclint] mechanism in the official docs. What you can do instead (supported by docs): 1) Put options under a [tool.pydoclint] section in pyproject.toml (or another TOML file). 2) If needed, point pydoclint at a different config file using --config=... (command-line options take precedence over the TOML file). Example configuration (from the project’s docs): [tool.pydoclint] style = 'google' exclude = '.git|.tox|tests/data|some_script.py' require-return-section-when-returning-none = true The same docs describe that pydoclint’s CLI uses a --config option (defaulting to pyproject.toml) and that TOML values under [tool.pydoclint] are how you set configuration without passing flags on every run. [1][2][3] If you meant something else by “default_map” (for example, a Click feature named default_map), tell me where you saw the term (link or snippet) and I’ll map it precisely to the pydoclint/Click configuration behavior.

Citations:


🌐 Web query:

pydoclint config_options unknown key handling

💡 Result:

pydoclint config “unknown key” handling: the public documentation for pydoclint’s TOML/pyproject configuration lists specific supported options, but it does not state any explicit policy for what happens when unknown/typo keys are present in the config. The only authoritative, source-backed behavior I could find is that pydoclint loads a TOML config file and may report errors related to configuration loading/parsing, but I did not find a documented “unknown key” mode (e.g., ignore vs error) in the provided sources. What you can conclude from the docs we found: - pydoclint’s configuration is TOML-based and the CLI config path defaults to pyproject.toml; CLI options take precedence over TOML [1]. - pydoclint advertises a fixed set of configuration options (e.g., many --... options are enumerated on the config options page), but the docs do not mention validation/strictness for unexpected keys [1]. If you need a definitive answer for your specific version, the most reliable approach is to test: add a deliberately invalid key under the pydoclint config section in pyproject.toml (e.g., unknown_option = true) and run pydoclint --config=pyproject.toml ... to see whether it errors or silently ignores it—because this behavior is not documented in the sources above. Note: a related GitHub issue log shows pydoclint loading “pyproject.toml” but the captured failure there is an InternalError in AST handling (not an unknown config key), so it doesn’t confirm the unknown-key policy [2].

Citations:


🌐 Web query:

site:jsh9.github.io/pydoclint "unknown" "tool.pydoclint"

💡 Result:

The term tool.pydoclint is not a standard identifier or configuration key. Instead, pydoclint is a Python docstring linter [1]. In the context of Python tooling and configuration, especially within pyproject.toml files or editor integrations like Neovim, references to this tool are typically made via the pydoclint package name or its associated executable pydoclint [1]. If you encountered "tool.pydoclint" in a configuration file or search result, it is likely a reference to the tool's settings within a configuration block (often formatted as [tool.pydoclint] if used in a project's pyproject.toml file) [2]. Key points regarding pydoclint: - Purpose: It is a high-speed Python docstring linter that checks if docstring sections (arguments, return values, raises, etc.) match the function signature or implementation [1]. - Usage: It can be used as a native command-line tool or as a flake8 plugin [1]. - Configuration: Options are typically defined in a.toml configuration file [2]. When integrating the tool into a project, configuration sections in a pyproject.toml are standard practice, which may explain the appearance of the string as [tool.pydoclint] [2]. - Integration: It can be integrated into various environments, such as Neovim (via null-ls) or used with pre-commit hooks [1][3]. If you are trying to configure the tool, you should look for the documentation on how to set options within your pyproject.toml file [2].

Citations:


🌐 Web query:

pydoclint click default_map

💡 Result:

There is no direct relationship between pydoclint and Click's default_map feature; they belong to two different domains of Python development [1][2][3]. Pydoclint is a static analysis tool designed to lint Python docstrings [1][4][5]. It includes a configuration option called --check-arg-defaults (shortform -cad) [6], which checks whether the default values of function arguments are documented, but this is entirely separate from the Click library's mechanism for handling command-line argument defaults [1][7]. Click, on the other hand, uses context.default_map to provide default values for command-line parameters, often sourced from configuration files or environment variables [8][9]. If you are encountering confusion between the two, it may stem from the fact that both tools use Click for their own CLI implementations (pydoclint uses Click to define its own command-line interface) [3][5], or perhaps from a misunderstanding of the term "default_map" in the context of Click versus the "check-arg-defaults" configuration flag in pydoclint [9][6].

Citations:


🌐 Web query:

site:github.com jsh9 pydoclint default_map

💡 Result:

In the jsh9/pydoclint project, there is no configuration option named default_map. The confusion likely stems from the project's internal use of mapping structures to handle argument defaults [1]. Pydoclint does not use a user-facing default_map configuration. Instead, it manages argument defaults internally during AST (Abstract Syntax Tree) parsing, specifically using an internal mapping—often referred to as argToDefaultMapping in the source code—to associate function arguments with their defined default values [1]. This logic is used to support features like the --check-arg-defaults flag [1]. If you are looking for information on configuring pydoclint, official configuration options are managed through CLI flags or configuration files (such as pyproject.toml), which are documented on the project's official configuration page [2][3]. Typical configuration involves options like --style, --check-arg-defaults, or --skip-checking-short-docstrings [1][2][3].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Confirm the exact keys at the referenced lines
if [ -f pyproject.toml ]; then
  echo "== pyproject.toml exists =="
  sed -n '640,690p' pyproject.toml | nl -ba | sed -n '1,120p'
else
  echo "pyproject.toml not found at repo root"
  exit 1
fi

# Check whether the invalid option names appear anywhere else
rg -n "require-return-section-when-returning-values|require-yield-section-when-yielding-values" pyproject.toml || true
rg -n "require-return-section-when-returning-none|require-return-section-when-returning-nothing|require-yield-section-when-yielding-nothing" pyproject.toml || true

Repository: ByronWilliamsCPA/python-libs

Length of output: 161


🏁 Script executed:

#!/bin/bash
set -euo pipefail
# If the repo vendors docs/config or a lockfile pins pydoclint, we can locate it.
# (Best-effort: doesn't assume dependency managers.)
rg -n "pydoclint" pyproject.toml || true
ls -la | head

Repository: ByronWilliamsCPA/python-libs

Length of output: 765


🏁 Script executed:

#!/bin/bash
set -euo pipefail
# Fetch pydoclint's config options list quickly (best-effort, no assumptions).
# Uses curl if available.
if command -v curl >/dev/null 2>&1; then
  echo "== Fetching pydoclint config options page =="
  curl -fsSL "https://jsh9.github.io/pydoclint/config_options.html" | head -n 40
  echo "== Searching within the page for require-return-section keys =="
  curl -fsSL "https://jsh9.github.io/pydoclint/config_options.html" | rg -n "require-return-section|require-yield-section" || true
else
  echo "curl not available"
fi

Repository: ByronWilliamsCPA/python-libs

Length of output: 1984


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Show the relevant [tool.pydoclint] section with line numbers
# (cat -n is available; nl isn't.)
sed -n '640,680p' pyproject.toml | cat -n

Repository: ByronWilliamsCPA/python-libs

Length of output: 1576


🏁 Script executed:

#!/bin/bash
set -euo pipefail

URL="https://jsh9.github.io/pydoclint/config_options.html"

# Extract any require-return / require-yield option keys from the config options page
curl -fsSL "$URL" | rg -o "require-(return|yield)-section-when-[a-zA-Z0-9_-]+" | sort -u

Repository: ByronWilliamsCPA/python-libs

Length of output: 309


🏁 Script executed:

#!/bin/bash
set -euo pipefail

URL="https://jsh9.github.io/pydoclint/config_options.html"

# Explicitly check for the specific (possibly-wrong) "values" keys
curl -fsSL "$URL" | rg -n "require-return-section-when-returning-values|require-yield-section-when-yielding-values" || true

Repository: ByronWilliamsCPA/python-libs

Length of output: 54


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Also search the local pyproject for any variants to ensure we don't miss typos elsewhere.
rg -n "require-return-section-when-|require-yield-section-when-" pyproject.toml

Repository: ByronWilliamsCPA/python-libs

Length of output: 242


🏁 Script executed:

#!/bin/bash
set -euo pipefail

URL="https://jsh9.github.io/pydoclint/config_options.html"
curl -fsSL "$URL" | rg -n "returning-values|yielding-values" || true

Repository: ByronWilliamsCPA/python-libs

Length of output: 54


Fix invalid pydoclint option keys in [tool.pydoclint] (lines 663–665)

pyproject.toml uses unsupported keys:

  • require-return-section-when-returning-values (line 664)
  • require-yield-section-when-yielding-values (line 665)

Pydoclint’s documented options are require-return-section-when-returning-nothing and require-yield-section-when-yielding-nothing—so the current settings won’t apply. In particular, because require-yield-section-when-yielding-nothing isn’t set, it will use the documented default (true), and pydoclint may still require a Yields section when yielding None.

🔧 Proposed fix — use valid option names
 skip-checking-raises = false
 require-return-section-when-returning-nothing = false
-require-return-section-when-returning-values = false
-require-yield-section-when-yielding-values = false
+require-yield-section-when-yielding-nothing = false
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
require-return-section-when-returning-nothing = false
require-return-section-when-returning-values = false
require-yield-section-when-yielding-values = false
require-return-section-when-returning-nothing = false
require-yield-section-when-yielding-nothing = false
🤖 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 `@pyproject.toml` around lines 663 - 665, The pyproject.toml contains invalid
pydoclint option keys: replace the unsupported keys
require-return-section-when-returning-values and
require-yield-section-when-yielding-values with the correct documented keys
require-return-section-when-returning-nothing and
require-yield-section-when-yielding-nothing respectively so the pydoclint
settings take effect; update the entries in the [tool.pydoclint] table (the two
key names shown) to the corrected names and preserve the boolean values you
intended.

log_level: The logging level for the application.
json_logs: Flag to enable or disable JSON formatted logs.
include_timestamp: Flag to include timestamps in logs.
model_config: Pydantic settings configuration.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add explicit type for model_config in the Attributes docstring.

model_config is the only listed attribute without an explicit type, which breaks the
typed-docstring consistency introduced in this PR.

As per coding guidelines, "Use Google-style docstrings with Args, Returns, and Raises sections for all functions and classes".

🤖 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 `@src/python_libs/core/config.py` at line 17, Update the Attributes docstring
entry for model_config to include an explicit type annotation; replace the
current line "model_config: Pydantic settings configuration." with something
like "model_config (dict): Pydantic settings configuration." (or "model_config
(Mapping[str, Any]): Pydantic settings configuration." if you prefer a more
generic type) so the Attributes section consistently lists types for all
attributes and follows the Google-style docstring convention.

Comment on lines 44 to +53
Args:
level: Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL).
level (str): Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL).
Defaults to INFO.
json_logs: If True, output JSON logs (production mode). If False,
json_logs (bool): If True, output JSON logs (production mode). If False,
use rich console formatting (development mode). Defaults to False.
include_timestamp: Whether to include timestamps in log output.
include_timestamp (bool): Whether to include timestamps in log output.
Defaults to True.
include_correlation: Whether to include correlation IDs from request
context in log output. Defaults to True. Requires API framework.
include_correlation (bool): Whether to include correlation IDs from
request context in log output. Defaults to True. Requires API
framework.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

Add missing Returns/Raises sections to satisfy src docstring policy.

For setup_logging and log_performance, the updated docstrings include Args but still omit Returns and Raises, which violates the src-level docstring requirement.

Suggested docstring structure update
 def setup_logging(
@@
     Args:
         level (str): Logging level (DEBUG, INFO, WARNING, ERROR, CRITICAL).
             Defaults to INFO.
@@
             request context in log output. Defaults to True. Requires API
             framework.
+
+    Returns:
+        None: This function configures global logging state.
+
+    Raises:
+        Exception: Propagates configuration/runtime errors from logging handlers.
@@
 def log_performance(
@@
     Args:
         logger (BoundLogger): Structlog logger instance from get_logger().
@@
         **context (object): Additional context key-value pairs to include in
             the log.
+
+    Returns:
+        None: This function emits a structured performance log entry.
+
+    Raises:
+        Exception: Propagates logger backend errors if emission fails.
As per coding guidelines, "Use Google-style docstrings with Args, Returns, and Raises sections for all functions and classes".

Also applies to: 173-179

🤖 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 `@src/python_libs/utils/logging.py` around lines 44 - 53, Add missing "Returns"
and "Raises" sections to the Google-style docstrings for setup_logging and
log_performance: update the docstring for setup_logging to include a Returns
clause (e.g., returning the configured logging.Logger or None) and a Raises
clause documenting any exceptions that can be propagated during logger
configuration (e.g., ValueError for invalid level or OSError for handler setup),
and update log_performance docstring similarly to state what it returns (if
anything) and which exceptions it may raise (e.g., KeyError or RuntimeError if
context or timer retrieval fails); ensure the exact function names setup_logging
and log_performance are updated and the wording matches existing Args style and
project docstring policy.

williaby and others added 3 commits May 30, 2026 22:29
…pydoclint

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…request params

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@sonarqubecloud
Copy link
Copy Markdown

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

Labels

dependencies documentation Improvements or additions to documentation python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants