Skip to content

MAINT: make puzzled dispatch exhaustive (P311-03) - #3504

Merged
Roman Lutz (romanlutz) merged 9 commits into
microsoft:mainfrom
huong8373tt-beep:fix/p311-03-puzzle-dispatch
Oct 26, 2026
Merged

Roman Lutz (romanlutz) merged 9 commits into
microsoft:mainfrom
huong8373tt-beep:fix/p311-03-puzzle-dispatch

Conversation

@huong8373tt-beep

@huong8373tt-beep Slai.life (huong8373tt-beep) commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Description

Part of #3166 (P311-03 puzzle-builder dispatch).

Use Python 3.11's typing.assert_never to make the existing closed PuzzleType dispatch exhaustive. Keep the dispatch directly in convert_async, explicitly handle CROSSWORD, and reject unhandled enum extensions during normal type checking.

The simplified patch removes the extracted helper, generic Callable, and source-generating subprocess test. Relative to main, only the import and explicit exhaustive branches remain. Constructor validation, crossword-to-anagram fallback, RNG behavior, Unicode handling, clues, and rendered output are preserved. No public API changes.

Tests and Documentation

Retain the existing runtime tests and rely on normal CI type checking for exhaustiveness. No additional test machinery or documentation changes are needed for this internal dispatch guard.

Validation of commit 5524faada11de4d187891120bdc3a9a32151e63d:

  • uv run --no-sync pytest tests\unit\converter\test_puzzled_converter.py tests\unit\converter\test_puzzled_puzzle_builders.py tests\unit\converter\test_puzzled_keyword_masker.py -q: passed, 289 tests.
  • uv run --no-sync ty check --python-version 3.11 pyrit\converter\puzzled\puzzled_converter.py tests\unit\converter\test_puzzled_converter.py: passed.
  • uv run --no-sync ruff check pyrit\converter\puzzled\puzzled_converter.py tests\unit\converter\test_puzzled_converter.py: passed.
  • uv run --no-sync ruff format --check pyrit\converter\puzzled\puzzled_converter.py tests\unit\converter\test_puzzled_converter.py: passed.
  • git diff --check: passed.

JupyText was not run because no documentation examples changed.

Disclosure

Slai Agent Runtime assisted with analysis, reproduction, implementation, and test execution. The account owner authorized this contribution and is responsible for the submission.

GitHub Copilot assisted with the follow-up simplification and validation at the maintainer's request.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I recommend closing this PR. The current dispatch already handles all three PuzzleType values, so this does not fix a current behavior bug. The new helper, generic Callable, and subprocess test that constructs source code and invokes ty add more maintenance than this change warrants. I would keep the simple dispatch and update it when a real enum extension needs it.

Reviewed with GitHub Copilot.

auto-merge was automatically disabled October 25, 2026 08:28

Pull request was closed

Keep the explicit Crossword branch and Python 3.11 assert_never guard in convert_async. Remove the helper, generic Callable, and source-generating subprocess test; rely on normal type checking and existing runtime tests.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@romanlutz

Copy link
Copy Markdown
Contributor

Richard Lundeen (@richlundeen) The helper, generic Callable, and source-generating subprocess test were removed in 5524faa. The PR now keeps the original dispatch structure and only adds an explicit CROSSWORD branch plus Python 3.11's assert_never guard: one file, 4 additions and 1 deletion relative to main.

The purpose is preventive type checking rather than fixing today's output: if PuzzleType gains a member without a corresponding branch, normal CI type checking will flag it instead of silently selecting the crossword builder. Existing runtime tests are unchanged. After the required main merge, all 292 focused puzzle tests and Python 3.11 type checking passed.

🤖 AI-authored reply via Agency Finish PR.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@romanlutz
Roman Lutz (romanlutz) added this pull request to the merge queue Oct 26, 2026
Merged via the queue into microsoft:main with commit ad71572 Oct 26, 2026
72 of 73 checks passed
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.

3 participants