Repository navigation
style: enforce Google docstrings and type hints - #145
Merged
Merged
Conversation
Give every package and function of `cloud_registry` and the MkDocs hooks a Google-style docstring with a one-line summary, document the keyword arguments that Connexion passes to controllers, and complete the type hints: annotated `**kwargs`, parametrized generic types, and a protocol for the settings of MkDocs that the hooks use, so that they are checked without MkDocs installed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideThis PR applies repository-wide Google-style docstring enforcement and complete static typing by configuring Ruff and mypy, then annotating and documenting production code, MkDocs hooks, fixtures, helpers, and tests. Type-checking exposed and prompted safer typed access to FOCA configuration, MongoDB data, and HTTP JSON responses; suppression comments now explain their rationale, while behavior, API signatures, test coverage, and CI workflows remain unchanged. File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Type the shared fixtures and helpers of `tests/conftest.py` and give them Google-style docstrings; read the collections of the unit test app with FOCA's typed `get_app_config()`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #145 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 9 9
Lines 737 743 +6
=========================================
+ Hits 737 743 +6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Annotate the tests of the Helm chart and the config, and their helpers, and give them Google-style docstrings with one-line summaries. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Annotate the unit tests of the controllers, services, verifications and config models, and their helpers and fakes, and give them Google-style docstrings with one-line summaries. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Annotate the API tests of access control and verifications, and their helpers and fakes, and give them Google-style docstrings with one-line summaries; read response bodies with `get_json()`, which is typed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Annotate the tests of the app, exceptions, utilities, Gunicorn settings, MkDocs hooks and version, and their helpers and fakes, and give them Google-style docstrings with one-line summaries; read response bodies with `get_json()`, which is typed, and the config with FOCA's typed accessors. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Enable ruff's pydocstyle rules with the Google convention for the whole repository, and make mypy reject functions without complete annotations and generic types without parameters; it now also checks the MkDocs hooks. Both run in pre-commit and so in CI. Closes #136 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Give every `type: ignore` and `noqa` comment a reason, restore wording that the shortened summaries lost, document keyword arguments as `**kwargs` as Google style does, and note in `pyproject.toml` why mypy checks the hints instead of ruff's `ANN` rules. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
uniqueg
marked this pull request as ready for review
October 21, 2026 19:30
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #136.
D) withconvention = "google"are enabled for the whole repository (package, tests and the MkDocs hooks indocs/hooks.py), without per-file ignores. Every package, module, class, function and method has a Google-style docstring with a one-line summary, including private helpers and the nested fakes of the tests (which pydocstyle doesn't require); wrapped summaries were rephrased (D205), and the keyword arguments that Connexion passes to controllers are documented (**kwargs).disallow_untyped_defsanddisallow_any_generics, oncloud_registry,docs/hooks.pyandtests. All functions are fully annotated (-> Noneon tests, fixture and parameter types,**kwargs: Anyon controllers), and generic types are parametrized (e.g.,dict[str, Any],Collection[dict[str, Any]],re.Match[str]). Annotating the tests made mypy check their bodies, which it skipped before; the errors that showed were fixed with precise types and asserts, e.g., FOCA's typedget_app_config()andget_custom_config()instead ofapp.config.foca, andget_json()for response bodies (Werkzeug types thejsonproperty as optional).type: ignoreandnoqastates its reason (as a comment above the line fortype: ignore, in parentheses afternoqa), including the ones that were there before.Protocol, so that mypy checks it without MkDocs, which only thedocsextra installs (the static analysis job installs thedevextra, on Python 3.10).The changes are behaviour-neutral: signatures, decorators and defaults of all functions are unchanged; the same 733 tests are collected and pass; test assertions are unchanged or stricter (asserts that documents exist before they are indexed).
Why mypy, not ruff
ANNmypy is already in pre-commit and CI, and with
disallow_untyped_defsit reports every function with a missing parameter or return annotation, including*argsand**kwargs, so it covers whatANN001-ANN206check. It also checks that the hints are correct, and, once functions are annotated, their bodies.disallow_any_genericscatches incomplete hints such as baredictorlist, whichANNdoesn't. AddingANNwould report the same missing annotations a second time, andANN401would rejectAny, which the JSON documents of the API need. Fullstrictmode was not used: with these settings, it reports only 61 errors more, none about missing hints: 42 fromno_implicit_reexport(e.g.,from foca import get_config, as FOCA's__init__.pyhas no__all__, and names thatcloud_registry.exceptionsre-exports from Werkzeug) and 19 fromwarn_return_any(values that areAnybecause Connexion, JSON or PyYAML return them untyped). Fixing those would mean casts or explicit re-exports, which add noise without making the hints more complete.How it was verified
Locally (Python 3.12 venv with pip 24.0, ruff 0.17.1 as in pre-commit, Helm 3.18.6):
ruff check .,ruff format --check .: pass;mypy: no issues in 34 source filescloud_registry,docs/hooks.pyandtests: nonecoverage run --source=cloud_registry -m pytest -W ignore::DeprecationWarning: 733 passed (same test IDs as ondev), coverage 100%ast-grep scan,ast-grep test --skip-snapshot-tests: pass;mkdocs build --strict: passesdev: only the keys of the new config helpers differ (no accidental edits in strings)CI (run 39661644796, head 93cb865): all checks pass, including static code analysis (pre-commit with ruff and mypy, on Python 3.10), tests on Python 3.10 and 3.12, the Helm chart, the Docker Compose smoke test, the docs build, Read the Docs, codecov/patch and codecov/project.
Declined review findings
docs/development.md(quality review): the docs prose is being reworked in parallel (docs: pre-release findings in docs and notes #134, docs: present app generally, use ELIXIR On-Cloud #137, docs: add code of conduct and contributing guide #138); the conventions are stated inpyproject.tomland enforced by the checks._custom_confighelper for the tests (quality review):tests/test_utils.pyreadsmodel_extradirectly on purpose, as it testsget_custom_config()itself; the other helpers are small and local.Docsalias of the chart tests and moving it totests/helm.py(quality review): onlytests/test_chart.pyuses it.get_json()throughout; a typed local is used only where a helper returns the body.Open questions
None.
🤖 Generated with Claude Code
Summary by Sourcery
Standardize repository documentation and static typing with enforced Google docstrings and comprehensive mypy validation while preserving application behavior.
Enhancements:
Tests:
Chores: