Repository navigation
Conversation
facundobatista
left a comment
There was a problem hiding this comment.
Awesome, thanks! There's a couple of very small details, commented inline...
aea30e1 to
2424e27
Compare
|
One edge case with With
So the natural "remove the venv for this script" ( Proposal: venv UUIDs are always if isinstance(args.remove, str):
try:
uuid.UUID(args.remove)
except ValueError:
# not a UUID: it's the child program, remove by its dependencies
if args.child_program is not None:
args.child_options.insert(0, args.child_program)
args.child_program = args.remove
args.remove = REMOVE_BY_DEPSThat makes If that's too magic, the conservative alternative is to error out on a non-UUID value, suggesting Happy to push either one; I lean towards the first. Generated by Claude Code |
|
Pushed 76b3571 to fix the
Tests: the existing UUID tests now use a real UUID, and I added tests for Generated by Claude Code |
76b3571 to
b659f69
Compare
'--rm' now takes an optional UUID: when passed a UUID it removes that virtualenv as before, but when given as a bare flag it removes the virtualenv matching the indicated dependencies (e.g. 'fades --rm -d django'), saving the round-trip through '--where' to look up the UUID. Add tests for the '--rm' flow in go() (by UUID and by dependencies), and update the man page and README accordingly. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01M8yxMZWHoMvnGE8biuNrGb
As '--rm' takes an optional UUID, argparse grabs the script as its value. Venv UUIDs are always valid UUIDs, so a value that isn't one is taken as the child program, removing the venv by its dependencies. The bare '--rm' value is now an empty string instead of an object() sentinel, so the value is always None or a str. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
b659f69 to
0be0a06
Compare
facundobatista
left a comment
There was a problem hiding this comment.
We're almost there, thanks!
| if args.child_program is not None: | ||
| args.child_options.insert(0, args.child_program) | ||
| args.child_program = args.remove | ||
| args.remove = '' |
There was a problem hiding this comment.
The logic is ok, but it gets really obscure because args.remove being not None means that the --rm was given, and the "if args.remove" check is to understand if a value was given or just the parameter.
Furthermore, a similar check is done below. Too error prone for the future.
My proposal is the following:
- we should have a
remove_flagvariable or similar, that can have a special value (say,BY_DEPENDENCIES, which is declared asobject()above), or the value indicated by the user - logic here should end up creating
remove_flag, with the value passed by the user or that special one; the outcome being so explicit will help with the logic - the code below would stop using
args.removebut useremove_flag, which will be very clear
What do you think?
There was a problem hiding this comment.
Agreed, done in 0731060:
BY_DEPENDENCIES = object()is declared at module level and is theconstof--rm, so a bare--rmalready arrives as that value.- Right after parsing, a
remove_flagis built:None(no--rm),BY_DEPENDENCIES, or the UUID the user gave. A value that isn't a valid UUID is moved to the child program andremove_flagbecomesBY_DEPENDENCIES. - The removal block only looks at
remove_flag(if remove_flag is BY_DEPENDENCIES: ... else: <by uuid>). Nothing readsargs.removeafter that, and the empty-string meaning is gone.
Generated by Claude Code
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # fades/main.py
What
--rmnow accepts either a UUID or nothing. When given as a bare flag it removes the virtualenv matching the indicated dependencies, so this:fades --rm $(fades --where -d django | awk -F "/" '{print $NF}')becomes simply:
How
--rmusesnargs='?'with aREMOVE_BY_DEPSsentinel asconst, distinguishing "not passed" / "passed with UUID" / "passed bare".get_venv(indicated_deps, interpreter, options=options)— the same matching used to run a venv — otherwise it uses the existing UUID lookup. Both share the destroy + warning logic.fades --rm <uuid>behaves exactly as before.Tests
There were no tests for the
--rmflow ingo(). AddedRemoveVenvTestCasecovering removal by UUID (found / not found / invalid env_path) and by dependencies (found / not found).Docs
Updated
man/fades.1andREADME.rst(usage synopsis + command examples).🤖 Generated with Claude Code