Repository navigation
fix: Declare PyYAML, check core-only import in CI, and read cassettes as UTF-8 - #100
Merged
Merged
Conversation
… as UTF-8 PyYAML was imported at runtime through molto.utils.io but not declared, so a plain install failed on import. CI hid this because the test extra's fastapi[standard] pulls in PyYAML via uvicorn[standard]. CI now imports Molto with core dependencies only before installing test extras. read_yaml, read_json, and dump_yaml now use UTF-8 instead of the platform default, which made 17 replay tests fail on Windows (cp1252). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jiahuei
reviewed
Nov 5, 2026
jiahuei
left a comment
Member
There was a problem hiding this comment.
The core-only import check is useful. The PyYAML dependency can be scoped to the test extra by deferring the YAML-helper imports, as detailed inline; the UTF-8 fixes should be retained.
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
PyYAML~=6.0.3to the core dependencies.import moltoimportsyamlthroughmolto.core,molto.adapters.anthropic, andmolto.utils.io, so a plainpip install moltofailed withModuleNotFoundError: No module named 'yaml'..[test], and the test extra'sfastapi[standard]requiresuvicorn[standard], which requirespyyaml>=5.1.read_yaml,read_json, anddump_yamlnow open files as UTF-8. They previously used the platform default encoding, so on Windows (cp1252) 17 replay tests failed withUnicodeDecodeErroron curly quotes in UTF-8 cassettes, and the matcher scripts would have written cassettes as cp1252.dump_yamlalready acceptedencoding="utf-8", but PyYAML ignores that argument for text streams, so it now applies to the opened file.tests/utils/test_io.pyfor UTF-8 reads and writes. They fail without the fix on Windows; on Linux, where the default is already UTF-8, they pass either way.Verification
uv pip install -e .thenpython -c "import molto"onmain(81f0165) in a fresh Python 3.12 venv: failed withModuleNotFoundError: No module named 'yaml'(exit code 1), confirming the new CI step catches the defect. With this change onc7ea914: passed (exit code 0).python -m pytest tests/utils/test_io.pyon Windows without theio.pyfix: 3 failed (the new tests). With the fix: 7 passed.python -m pyteston Windows, UTF-8 mode off: 2297 passed (17 failed before theio.pyfix). WithPYTHONUTF8=1: 2297 passed. Cassettes unchanged.uv run --extra lint ruff check --config pyproject.toml .andruff format --diff: changed files pass; the only findings are in the untracked localtest_molto.py, which is not part of this change.npx prettier@3.8 --check .: passed.🤖 Generated with Claude Code