docs: annotate generic Context examples - #428
codeforester wants to merge 6 commits into
Conversation
codeforester
left a comment
There was a problem hiding this comment.
Reviewed head e36e460 against #427 (follow-up to #414). Every bare base_cli.Context in the README and docs/integrations.md is now parameterized. One substantive issue: object makes some of the examples fail strict mypy, which is the thing this PR is meant to fix.
#414 standardized on base_cli.Context[Any, Any, Any] (docs/testing.md, examples/minimal_cli), but this PR uses Context[object, object, object]. That's fine wherever the example only touches ctx.log/ctx.environment/ctx.dry_run. It breaks wherever the example uses the typed config. I ran mypy --strict against this branch on the README factory snippet (make_services → Services(ctx.config), with Services.__init__(self, config: Config)):
Context[object, object, object]: error: Argument 1 to "Services" has incompatible type "object"; expected "Config" [arg-type]
Context[Any, Any, Any]: Success: no issues found
Suggestion: use Context[Any, Any, Any] (with from typing import Any) for consistency with docs/testing.md and the shipped example. For the factory section, use the concrete Context[Config, ApplicationContext, Services] that the README already introduces near line 181.
Nits: the prose change "receive the active base_cli.Context" → "the active Context" loses the namespace for no apparent reason. The cancelled Publish issue branch policy run is a superseded duplicate; the required base/issue-branch-policy status is green.
|
|
||
|
|
||
| def make_services(ctx: base_cli.Context) -> Services: | ||
| def make_services(ctx: base_cli.Context[object, object, object]) -> Services: |
There was a problem hiding this comment.
With Context[object, object, object], ctx.config is object, so Services(ctx.config) fails mypy --strict when Services takes a Config (verified). Context[Config, ApplicationContext, Services] (or Any) type-checks.
There was a problem hiding this comment.
Addressed in commit 96ca879d. The generic examples now use Context[Any, Any, Any] with explicit from typing import Any; the factory example uses the concrete Context[Config, ApplicationContext, Services]; and the prose keeps the public base_cli.Context namespace. Documentation validation, the full test suite, Ruff, and strict mypy (with the declared Typer extra) all pass.
|
Review follow-up complete in |
…61005-docs-annotate-generic-context-examples
|
Also synced the branch with current |
…61005-docs-annotate-generic-context-examples
|
Final branch sync: merged current |
…61005-docs-annotate-generic-context-examples
|
Re-verified at |
…61005-docs-annotate-generic-context-examples
|
Resolved the #428 branch divergence by merging current origin/main (including #423) into the existing documentation branch. The merge completed without textual conflicts; the branch now points to cd04c79 and retains only the intended generic-context documentation changes in README.md and docs/integrations.md. Validation passed:
PR #428 remains open and unmerged while hosted checks complete. |
Summary
Update public README and integration examples to use the three-parameter
base_cli.Context[object, object, object]form required by strict typing. This is the documentation follow-up to merged PR #414.Issue
Fixes #427
Validation
tests/full_validate.sh --gate contractstests/full_validate.sh --gate typingbase_cli.Contextremains in the affected docs.