Skip to content

fix: Declare PyYAML, check core-only import in CI, and read cassettes as UTF-8 - #100

Merged
koladefaj merged 2 commits into
mainfrom
fix/pyyaml-core-import-utf8
Nov 5, 2026
Merged

koladefaj merged 2 commits into
mainfrom
fix/pyyaml-core-import-utf8

Conversation

@koladefaj

Copy link
Copy Markdown
Contributor

Summary

  • Added PyYAML~=6.0.3 to the core dependencies. import molto imports yaml through molto.core, molto.adapters.anthropic, and molto.utils.io, so a plain pip install molto failed with ModuleNotFoundError: No module named 'yaml'.
  • CI did not catch the missing dependency because it installs .[test], and the test extra's fastapi[standard] requires uvicorn[standard], which requires pyyaml>=5.1.
  • Added a CI step that installs Molto with core dependencies only and imports it before the test extras are installed, so an undeclared runtime dependency now fails CI instead of being masked by a transitive test dependency.
  • read_yaml, read_json, and dump_yaml now open files as UTF-8. They previously used the platform default encoding, so on Windows (cp1252) 17 replay tests failed with UnicodeDecodeError on curly quotes in UTF-8 cassettes, and the matcher scripts would have written cassettes as cp1252. dump_yaml already accepted encoding="utf-8", but PyYAML ignores that argument for text streams, so it now applies to the opened file.
  • Added regression tests in tests/utils/test_io.py for 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

  • Core-only uv pip install -e . then python -c "import molto" on main (81f0165) in a fresh Python 3.12 venv: failed with ModuleNotFoundError: No module named 'yaml' (exit code 1), confirming the new CI step catches the defect. With this change on c7ea914: passed (exit code 0).
  • python -m pytest tests/utils/test_io.py on Windows without the io.py fix: 3 failed (the new tests). With the fix: 7 passed.
  • python -m pytest on Windows, UTF-8 mode off: 2297 passed (17 failed before the io.py fix). With PYTHONUTF8=1: 2297 passed. Cassettes unchanged.
  • uv run --extra lint ruff check --config pyproject.toml . and ruff format --diff: changed files pass; the only findings are in the untracked local test_molto.py, which is not part of this change.
  • npx prettier@3.8 --check .: passed.
  • CI itself was not run; the workflow change is verified only by running its commands locally.

🤖 Generated with Claude Code

… 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>
@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Coverage

Coverage Report (Python 3.14) •
FileStmtsMissCoverMissing
utils
   io.py681381%55–56, 60–61, 88–90, 164–167, 172–173
TOTAL391352986% 

Tests Skipped Failures Errors Time
2299 0 💤 0 ❌ 0 🔥 28.216s ⏱️

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Coverage

Coverage Report (Python 3.13) •
FileStmtsMissCoverMissing
utils
   io.py681381%55–56, 60–61, 88–90, 164–167, 172–173
TOTAL395852987% 

Tests Skipped Failures Errors Time
2299 0 💤 0 ❌ 0 🔥 57.547s ⏱️

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Coverage

Coverage Report (Python 3.12) •
FileStmtsMissCoverMissing
utils
   io.py681381%55–56, 60–61, 88–90, 164–167, 172–173
TOTAL395852987% 

Tests Skipped Failures Errors Time
2299 0 💤 0 ❌ 0 🔥 58.724s ⏱️

@jiahuei jiahuei left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Comment thread pyproject.toml Resolved
@koladefaj
koladefaj merged commit 70ad86c into main Nov 5, 2026
5 checks passed
@koladefaj
koladefaj deleted the fix/pyyaml-core-import-utf8 branch November 5, 2026 16:28
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.

2 participants