Skip to content

fix: validate configuration contents regardless of filename - #315

Open
the8thbit wants to merge 1 commit into
ReadAlongs:mainfrom
the8thbit:fix/config-json-contents-140
Open

the8thbit wants to merge 1 commit into
ReadAlongs:mainfrom
the8thbit:fix/config-json-contents-140

Conversation

@the8thbit

Copy link
Copy Markdown

PR Goal?

Accept valid JSON configuration files regardless of their filename. Keep BOM support and report malformed JSON through the existing CLI error.

Fixes?

Fixes #140.

Feedback sought?

Review of the filename-independent configuration loading and regression cases.

Priority?

Normal; small CLI reliability fix.

Tests added?

Eight cases cover .json, .JSON, .cfg, and extensionless filenames with UTF-8 and UTF-8 BOM content. The invalid-configuration test now checks the JSON-content diagnostic for both .json and .txt files.

How to test?

pytest tests/test_align_cli.py -q -k 'config_contents_determine_format or invalid_config'

The focused tests fail on the original implementation (7 failures, 2 passes) and pass after the fix (9 passes). Applicable formatting, lint, and type-check hooks pass.

A broader offline run with pytest --disable-socket --allow-unix-socket --ignore=tests/test_audio.py gives 137 passes and the same 9 network-dependent failures seen on the untouched baseline (129 passes). pytest-socket was installed only for this local check; no dependency files changed. The audio module was excluded because its CLI subprocesses do not inherit that network guard. The full network-dependent suite and other supported Python/platform combinations remain for CI.

Confidence?

High for this narrow change. Additional local checks cover malformed JSON, missing files, Unicode filenames, and real alignment with BOM/non-ASCII configuration content.

Version change?

Patch release; no version files changed.

Accept valid JSON config files with any extension or no extension,
while preserving BOM support and malformed-content errors. Add
regression coverage for filenames, encodings, and invalid JSON.

Fixes ReadAlongs#140.
@semanticdiff-com

semanticdiff-com Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Review changes with  SemanticDiff

Changed Files
File Status
  readalongs/cli.py  62% smaller
  tests/test_align_cli.py  5% smaller

@codecov

codecov Bot commented Oct 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.76%. Comparing base (192f8ab) to head (1ee88c3).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #315      +/-   ##
==========================================
- Coverage   93.76%   93.76%   -0.01%     
==========================================
  Files          21       21              
  Lines        1765     1763       -2     
  Branches      295      294       -1     
==========================================
- Hits         1655     1653       -2     
  Misses         73       73              
  Partials       37       37              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@joanise

joanise commented Oct 21, 2026

Copy link
Copy Markdown
Member

Nice. The code looks good, and thanks for adding good unit tests. I'll test interactively before finishing my review.

This branch has not been deployed

No deployments
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.

readalongs -c switch should validate file contents, not extension

2 participants