Unify -o long option to be --store-dir #59
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
inm7/inm-icf-utilities!59
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "unify-long-opt"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This changes
make_studyvisit_archiveto use-o / --store-dir, consistent with the other three scripts. The--output-dirargument is marked as deprecated but remains supported for the time being. Closes #52Use of both long forms is guarded againist by using a mutually exclusive group. A deprecation warning is issued when --output-dir is used. When the deprecated parameter is removed, both the group and the warning can be done away with.
As a side note, it seems that Python 3.13 will add "deprecated" to argparse's add_argument:
https://docs.python.org/3.13/library/argparse.html#deprecated
@ -198,8 +204,18 @@ if __name__ == '__main__':"directory with the name '<study-id>_<visit_id>' is used "@ -186,1 +189,4 @@"--output-dir", metavar="PATH",help="Deprecated, will be removed in the future; ""use -o/--store-dir instead.")p.add_argument(TIL about https://docs.python.org/3.13/library/argparse.html#argparse.ArgumentParser.add_mutually_exclusive_group - thanks! But I also read in the docs
(ref https://github.com/python/cpython/pull/30098). Maybe it would be more future-proof to not rely on this function?
@ -186,1 +189,4 @@"--output-dir", metavar="PATH",help="Deprecated, will be removed in the future; ""use -o/--store-dir instead.")p.add_argument(Thanks for pointing that comment out - I missed it, so it's a TIL for me, too.
However, If I'm reading it correctly, it only talks about nested groups ("Calling
add_argument_group()oradd_mutually_exclusive_group()on a mutually exclusive group is deprecated"). In which case, it should still be fine to call it directly on theArgumentParser.That being said, I have considered a simpler solution, which would be:
It would assign to
args.store_dirregardless of which long option was used. It's much simpler than the mutually exclusive group, but I could not quickly find a way of introspection (which long option was used) allowing me to raise a deprecation error. It could still at least be noted in the help message.What would you suggest?
@ -186,1 +189,4 @@"--output-dir", metavar="PATH",help="Deprecated, will be removed in the future; ""use -o/--store-dir instead.")p.add_argument(ha, thanks for helping me parse this correctly - I read it wrong. In that case, sorry for the noise, please disregard the comment. I like the exclusive group!
I take the discussion above as an approval. The change does not break backwards compatibility, so I'm merging.