Skip to content

fix: pass config path to click.edit as a string - #269

Open
Sanjays2402 wants to merge 1 commit into
mkb79:masterfrom
Sanjays2402:fix/config-edit-fspath-248
Open

fix: pass config path to click.edit as a string#269
Sanjays2402 wants to merge 1 commit into
mkb79:masterfrom
Sanjays2402:fix/config-edit-fspath-248

Conversation

@Sanjays2402

Copy link
Copy Markdown

Closes #248

audible manage config edit passed the pathlib.Path from session.config.filename to click.edit(filename=...). Click >= 8.2 hands that value straight to Editor.edit_files(), which iterates it, so the command aborted with TypeError: 'WindowsPath' object is not iterable. Converting with os.fspath() fixes it — this is the approach you outlined on the issue.

Added tests/test_cmd_manage.py, which asserts the filename reaching click.edit is a string; it fails on the current code and passes with the fix. Also added a CHANGELOG entry under Unreleased/Fixed.

This change was prepared with AI assistance; the regression test was run locally and fails without the fix.

`audible manage config edit` called `click.edit(filename=...)` with the
`pathlib.Path` returned by `session.config.filename`. Click >= 8.2 passes
that value straight to `Editor.edit_files()", which iterates it, so the
command aborted with `TypeError: 'WindowsPath' object is not iterable`.

Convert the path with `os.fspath()` before handing it to Click.

Adds a regression test asserting the filename reaching `click.edit` is a
string.
@mkb79

mkb79 commented Jul 30, 2026

Copy link
Copy Markdown
Owner

Thanks for the fix, and for including a regression test.

Could you rebase onto current master? The branch is based on 3c9d834 and GitHub now reports the PR as conflicting. The conflict is only in CHANGELOG.md#266 and #270 have since added entries to the same ### Fixed block — so it should be quick to resolve.

I have reviewed the change itself and reproduced the bug on master; detailed feedback follows in a separate comment.

@mkb79

mkb79 commented Jul 30, 2026

Copy link
Copy Markdown
Owner

Reviewed in detail. The diagnosis is right and the fix is correct — I reproduced the crash on master (TypeError: 'PosixPath' object is not iterable, exit code 3) and confirmed your test goes red when the conversion is removed and green with it. Nice that you included a regression test.

os.fspath() is the right conversion here, and better than str(): it goes through the filesystem-path protocol instead of relying on __str__. I also checked the rest of the codebase for the same pattern — every other Path handed to a library is fine (click.format_filename calls os.fspath itself, aiofiles delegates to built-in open, toml handles PurePath, audible accepts str | Path, and the FFmpeg calls already convert with str()). So this really was the only occurrence.

Two things to change while you rebase:

1. Changelog wording. Click 8.2+ does not require a string — it accepts str | Iterable[str]. The problem is that pathlib.Path is neither. Quoting only WindowsPath also reads as if this were Windows-only; it fails identically on Linux and macOS. Something like:

2. Test docstring at tests/test_cmd_manage.py:12 repeats the same "needs a str" claim — worth correcting for the same reason.

Optional nit: config_file.write_text("[APP]\n") is never read, since both _config and click.edit are mocked. You can drop it, or keep it if you prefer the fixture to look realistic.

One note that is on us, not you: this would be the first real test in the repo. pyproject.toml already anticipates one (testpaths, coverage paths, a Ruff exception for tests/*), but pytest is not a declared dev dependency and no workflow runs it, so the test will not execute in CI yet. That is not a blocker for this PR — I will wire up the test job separately.

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.

audible manage config edit fails on Windows: TypeError: 'WindowsPath' object is not iterable

2 participants