Skip to content

Fix audit findings: bugs B-1..B-11, X-1, dead code, pinning tests, doc drift#202

Merged
lesnik512 merged 44 commits into
mainfrom
audit-fixes-2026-06-12
Jun 13, 2026
Merged

Fix audit findings: bugs B-1..B-11, X-1, dead code, pinning tests, doc drift#202
lesnik512 merged 44 commits into
mainfrom
audit-fixes-2026-06-12

Conversation

@lesnik512

Copy link
Copy Markdown
Member

Summary

Fixes selected findings from the 2026-06-12 code & docs audit (planning/audits/2026-06-12-code-docs-audit-report.md). 24 commits; 179 tests, 100% line coverage, lint/ty clean.

Bugs (B-1…B-11)

  • B-1/B-3 — parameterized-generic and positional-only creator params now raise a clear UnsupportedCreatorParameterError at declaration (B-1 allows a kwargs/default escape hatch) instead of silently degrading to the origin type or dying with a raw TypeError at resolve.
  • B-2get_type_hints TypeError (e.g. functools.partial creators) is caught and warn-skipped with a workaround hint, like the existing NameError path.
  • B-4 — honest ArgumentResolutionError for unannotated params ("has no usable type annotation") and union params (names both members) instead of "of type None".
  • B-5validate() aggregates a dangling-Alias error into ValidationFailedError instead of aborting the whole validation.
  • B-6 — the public Container(parent_container=…) constructor enforces the same scope-ordering check as build_child_container.
  • B-7 — cached instances are finalized in reverse creation order (true LIFO teardown), matching the docs. Closes drift D-1.
  • B-8 — a sync finalizer that returns an awaitable is now awaited in close_async (and rejected in close_sync), instead of leaking an un-awaited coroutine.
  • B-9set_context invalidates compiled kwargs so a later resolve picks up the new value.
  • B-10 — group registration is atomic: a failed registration leaves the shared registry untouched.
  • B-11ProvidersRegistry locks its mutations and iterates snapshots (no "dictionary changed size during iteration" under concurrent registration).

DX (X-1) — resolving from / building a child of a closed container raises ContainerClosedError. Re-entering the context manager (with container:) reopens it; clear_cache=False instances persist across the close→reopen cycle (same object returned), clear_cache=True rebuild. The closed-guard also covers resolution of a parent-scoped provider through an open child.

Internals — removed dead code: unused TypeVars, _UNSET sentinel, a no-op get_origin pass (Q-2, Q-3, Q-4).

Tests (Q-10…Q-15) — pinned previously-untested contracts: static-kwargs precedence, creator-failure (nothing cached / retry / LIFO finalize), context scope-selection, alias chains, child→APP-cache identity, duplicate-type-across-groups.

Docs (D-3, D-6…D-14) — fixed the crashing intro example, wrong scope rendering, the broken alias override walkthrough, three troubleshooting pages that quoted error messages the library never raises, false typing claims, the clear_cache=False migration guidance, and a websocket example that didn't parse; rewrote the context "set before building the child" advice to the correct scope rule (context never propagates between containers); documented the open/close/reopen lifecycle.

Design rulings recorded during the work

  • B-1 → declaration-time error for parameterized generics, with a kwargs/default escape hatch.
  • D-6 → context never propagates parent→child by design (docs + docstring only, no code change).
  • clear_cache=False → precisely defined as persist-across-reopen (same instance returned after re-entering the context manager).

Deferred (not in this round)

Q-1, Q-5…Q-9, X-2…X-6, D-2, D-4, D-5, G-1…G-11.

Test Plan

  • just lint-ci — clean (ruff format/check, ty)
  • just test — 179 passed, 100% line coverage
  • uv run pytest benchmarks/ --benchmark-disable — 22 passed
  • Every fixed doc example executed against the current library
  • Each commit individually reviewed (spec + adversarial quality); full branch reviewed holistically

🤖 Generated with Claude Code

lesnik512 and others added 30 commits June 12, 2026 12:02
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…sign)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… (Q-2, Q-3, Q-4)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…nt (B-2)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…eator params (B-1, B-3)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…r site (B-1 follow-up)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…lve (B-1)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…r (B-5)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…h (B-6)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…own (B-7, closes D-1)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…se (B-8)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
lesnik512 and others added 14 commits June 12, 2026 20:07
…ule (B-9, D-6 ruling)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… untouched (B-10, Q-15)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ontainer (X-1)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ances survive the cycle; guard closed scope-resolved containers (X-1 refinement, issue-1)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…cope-selection, alias chains (Q-10..Q-14)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…D-6)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…rule (D-7)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ses (D-9, D-10, D-11)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ics, fix websocket example, document close/reopen lifecycle (D-12, D-13, D-14)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…D-6 follow-up)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…D-1, D-3, D-6..14)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
get_type_hints(partial) returns {} on 3.14 instead of raising TypeError, so the
real-partial test no longer exercised the warn-skip branch there (CI failure +
coverage drop under --cov=.). Replace with direct TypeError fault injection plus
a version-stable 'partial does not crash' smoke test.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@lesnik512 lesnik512 merged commit 2bafa61 into main Jun 13, 2026
6 checks passed
@lesnik512 lesnik512 deleted the audit-fixes-2026-06-12 branch June 13, 2026 08:00
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.

1 participant