Handle --frozen flag for Poetry backend via lockfile backup/restore#1773
Conversation
Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/e5f566ae-ea62-4d1d-96a9-1e0a343e008e Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/e5f566ae-ea62-4d1d-96a9-1e0a343e008e Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
--frozen flag for Poetry backend via --lock
@copilot this isn't an acceptable compromise. We should create a dedicated wrapper logic around the poetry subprocess to revert any changes to poetry.lock when |
Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/d87a5a95-cba9-4190-8045-871fb850e40e Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/d87a5a95-cba9-4190-8045-871fb850e40e Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Reworked in |
--frozen flag for Poetry backend via --lock--frozen flag for Poetry backend via lockfile backup/restore
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/a31b7036-cb6c-42d0-8076-7c495da36035 Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
…ager Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/a31b7036-cb6c-42d0-8076-7c495da36035 Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Poetry's CLI has no
--frozenequivalent. Whenfrozen=True,poetry add/removewere running unmodified—resolving, locking, and installing despite the user requesting frozen mode.Changes
call_poetry_subprocess: Whenfrozen=Trueand the command isadd/remove, the function now (1) inserts--lockto skip installation, and (2) uses a_frozen_poetry_lockcontext manager to back uppoetry.lockto a temp directory before the subprocess and restore it afterwards. This ensurespyproject.tomlis updated while the lockfile remains truly frozen—even on subprocess failure._frozen_poetry_lockcontext manager: Encapsulates the backup/restore lifecycle forpoetry.lock. If the lockfile exists beforehand it is backed up and restored on exit; if it did not exist, any lockfile created during the block is removed. The temp directory is always cleaned up._noop_context: No-op context manager used as a fallback when frozen mode is not applicable.call_poetry_subprocess(frozen add/remove, non-applicable commands, frozen=False baseline, lockfile restore on success, lockfile restore on failure, lockfile removal when it didn't previously exist, temp directory cleanup) + 2 integration tests onadd_deps_to_group/remove_deps_from_groupwith Poetry backend under frozen mode. 100% coverage on the changed module.