milestone: complete pattern catalog (32 units) - #9
Merged
Merged
Conversation
- pyproject.toml: hatchling build, ruff (lint+format), mypy --strict, pytest with coverage; legacy flat dirs excluded until catalog migration - Makefile: install / lint / format / typecheck / test / check - GitHub Actions CI on 3.11/3.12/3.13 (push to main/staging + PRs) - MIT LICENSE, real .gitignore (incl. .omc/), docs/ skeleton - src/design_patterns package stub + smoke test Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
- CLAUDE.md / AGENTS.md: repo layout, pattern-unit template, frontmatter schema, verdict vocabulary, branch/gate workflow, prose style - .claude/settings.json: allow the make/uv quality-gate commands - .claude/commands/new-pattern.md: /new-pattern unit scaffolder - .claude/skills/pattern-authoring: variant roles, verdict rubric, test bar Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Nine complete units under patterns/<group>/<slug>/, each with frontmattered README, naive.py (GoF translation), pythonic.py, real_world.py (stdlib sighting), and behavioral tests: - creational: builder, prototype, singleton - structural: composite, decorator, flyweight - behavioral: command, iterator, strategy Legacy flat dirs removed (primary file per unit git mv'd for history). Fixes carried by construction: strategy bulk_item returned inside its loop; singleton __new__ passed args to object.__new__; builder demo printed empty attributes. Gates: ruff, mypy --strict (59 files), pytest (61 tests), all 27 demos run clean. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
src/design_patterns/catalog.py parses and validates every patterns/<group>/<slug>/README.md frontmatter block into frozen Pattern dataclasses: schema keys, verdict vocabulary, id/directory agreement, https guide_url, and at least one shipped example are all enforced with loud CatalogError messages. Catalog.to_json() emits the future catalog://index payload. Adds pyyaml (runtime) and types-pyyaml (dev). 14 new tests cover the real catalog round-trip and every validation failure mode. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
New groups patterns/python/ and patterns/principle/, six new units: - creational/abstract_factory — callables as factories; json parse_float - creational/factory_method — DI, class/instance attribute factories; HTTPConnection.response_class - python/global_object — constants, import-time rules, lazy init; math.pi, calendar.day_name, os.environ - python/prebound_method — bound methods as module API; random.random - python/sentinel_object — object() sentinels, Null Object; dataclasses.MISSING, iter(callable, sentinel) - principle/composition_over_inheritance — subclass explosion vs composed axes; the logging module Catalog at 15 units. 115 tests pass; ruff/mypy --strict clean; all 45 demo scripts run. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
- structural/adapter (pythonic) — function/__getattr__ adapters; io.TextIOWrapper - structural/bridge (prefer-alternative) — composition + DI is the bridge; logging Logger/Handler - structural/facade (pythonic) — module functions as facades; shutil.make_archive - structural/proxy (use-with-care) — LazyProxy, cached_property; weakref.proxy Catalog at 19 units; GoF structural complete. 134 tests, all 57 demos run, ruff/mypy --strict clean. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
- chain_of_responsibility (prefer-alternative) — list+loop; logging propagation - interpreter (prefer-alternative) — tuple trees; safe ast evaluator; re - mediator (use-with-care) — coordinator w/ callables; queue.Queue - memento (use-with-care) — frozen-state snapshots; pickle round-trip - observer (pythonic) — callables + property setter; Future.add_done_callback - state (use-with-care) — Enum transition table + generator machines - template_method (prefer-alternative) — steps as kwargs; JSONEncoder.default - visitor (prefer-alternative) — singledispatch; ast.NodeVisitor Catalog at 27 units: all 23 GoF patterns now covered. 180 tests, 81 demos run, ruff/mypy --strict clean. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
New group patterns/modern/: - dependency_injection (pythonic) — Protocol seams, kwarg defaults; sorted(key=), json.dumps(cls=) - repository (use-with-care) — Protocol + in-memory fake + sqlite impl - context_manager (pythonic) — __enter__/__exit__, @contextmanager, ExitStack - registry (pythonic) — decorator-filled dispatch dict; codecs - async_producer_consumer (use-with-care) — asyncio.Queue + TaskGroup with backpressure and tested shutdown; thread version for contrast Adds pytest-asyncio (auto mode). 211 tests; ruff/mypy --strict clean; all 96 demos run as modules. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
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.
Staging → main milestone. Everything since the scaffold:
🤖 Generated with Claude Code