Add --no-sync flag to avoid syncing the virtual environment (declare only)#1766
Add --no-sync flag to avoid syncing the virtual environment (declare only)#1766Copilot wants to merge 8 commits into
--no-sync flag to avoid syncing the virtual environment (declare only)#1766Conversation
…e only) Add a --no-sync CLI flag that declares/undeclares dependencies in pyproject.toml without syncing the virtual environment. For uv, this passes --no-sync to uv add/remove. For poetry, this passes --lock to poetry add/remove. When active, an instruction message is shown telling the user to manually install/uninstall. Resolves #1807 Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/7348ebb6-400f-4e8e-b5aa-c25ea2f852c2 Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Tests for call_uv_subprocess, call_poetry_subprocess, add_deps_to_group, and remove_deps_from_group with no_sync=True. Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/7348ebb6-400f-4e8e-b5aa-c25ea2f852c2 Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
Make frozen precedence over no_sync explicit in the elif condition. Add test for remove command with frozen precedence. Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/7348ebb6-400f-4e8e-b5aa-c25ea2f852c2 Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
--no-sync flag to avoid syncing the virtual environment (declare only)
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Merging this PR will degrade performance by 5.37%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Simulation | test_help_flag |
53 ms | 56.1 ms | -5.37% |
Comparing copilot/add-no-sync-flag-to-poetry (0ac0fbc) with main (f84d89d)
| }: | ||
| new_args = ["uv", args[0], "--frozen", *args[1:]] | ||
| elif ( | ||
| not usethis_config.frozen |
There was a problem hiding this comment.
@copilot we should add handle the case of BOTH --frozen and --no-sync...
There was a problem hiding this comment.
Addressed in 7a4549a. UsethisConfig.set() now raises UsethisError("Cannot use both --frozen and --no-sync at the same time.") when both flags are True. Tests added in TestFrozenAndNoSync (test_config.py) and test_frozen_and_no_sync_raises (test_call.py).
There was a problem hiding this comment.
@copilot sorry, I don't understand why this would raise? Why not just accept both args simultaneously?
There was a problem hiding this comment.
You're right — both flags can coexist since --frozen is strictly stronger. Removed the mutual exclusivity check in 816d50c. Now both are accepted simultaneously and --frozen naturally takes precedence via the elif chain in call_uv_subprocess.
Instead of silently having --frozen take precedence, raise a UsethisError when both flags are set simultaneously. These flags are mutually exclusive since --frozen prevents both lockfile updates and syncing, while --no-sync only prevents syncing. Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/bbee573e-012b-4649-8923-7e4e46490fcf Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
…precedence) Remove the mutual exclusivity check that raised UsethisError when both flags were set. Instead, both flags are accepted and --frozen naturally takes precedence via the elif chain in call_uv_subprocess. Agent-Logs-Url: https://github.com/usethis-python/usethis-python/sessions/dd1c1911-7c23-496d-a175-2fac1a83d0e4 Co-authored-by: nathanjmcdougall <18602289+nathanjmcdougall@users.noreply.github.com>
|
Not planned |
Adds a
--no-syncCLI flag that declares/undeclares dependencies inpyproject.tomlwithout touching the virtual environment. Analogous touv add --no-sync.When active, an instruction message tells the user to manually install/uninstall:
Config & CLI
NO_SYNC_DEFAULT,no_syncfield onUsethisConfig, wired throughset()context managerno_sync_opttyper option added to all 11 interface files that already support--frozen--frozenand--no-synccan be used simultaneously;--frozennaturally takes precedence since it is strictly stronger (prevents both lockfile updates and syncing)Backend subprocess wrappers
--no-synctouv add/uv remove; when both--frozenand--no-syncare set,--frozentakes precedence via theelifchain--locktopoetry add/poetry removeDependency messaging (
_deps.py)add_deps_to_group: prints install instruction whenno_sync(same pattern asfrozen)remove_deps_from_group: prints uninstall instruction whenno_syncTests
call_uv_subprocess:--no-syncadded for add/remove,--frozenprecedence over--no-syncverifiedcall_poetry_subprocess:--lockadded for add/remove, not added for other commandsadd_deps_to_group/remove_deps_from_group: output messages verified withno_sync=TrueUsethisConfig:TestFrozenAndNoSyncvalidates both flags can be set simultaneously, and success when only one is set