daisybio / daisybio/drevalpy

More robust argument handling

Open
#413 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
44
Forks
12
Avg merge
7d 19h
Merged PRs (30d)
10

Description

Typer by requires list options to be provided as `--flag a --flag b --flag c`instead of `--flag a b c` as it was in the old interface. We now circumvented this issue.

Typer inherits this behavior from click, which does it like this to prevent ambiguity (the following section is LLM-generated):

```bash
cmd --items A B output.txt
cmd --items A --other B C
cmd --items -1 -2 --flag
```
Are output.txt, C, or -1 list values, positional args, or malformed options? Argparse allows this style with nargs='+', but it comes with edge cases around ordering, positionals, negative-looking values, and “greedy” consumption.

Click’s design is more conservative:

An option can take one value by default.
An option can take a fixed number of values, e.g. --range 1 10.
An option can be repeated for arbitrary lists, e.g. --model A --model B.
Unlimited space-separated values are reserved for positional arguments, where greediness is expected.
Typer inherits that. It favors unambiguous parsing and shell-like composability over argparse’s nargs='+' option behavior.

---

-> Maybe at some point we might want to make the switch to more robust argument handling

_Originally posted by @nictru in https://github.com/daisybio/drevalpy/issues/411#issuecomment-4590838344_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.