When using the -d (or --debris) flag with the all keyword, the subsequent positional argument (the directory path) is incorrectly parsed as a choice for the -d flag. This results in an invalid choice error.
However, using the assignment syntax (e.g., -d=all) works as expected.
Reproduction Steps
- Install
pyclean (v3.6.0).
- Run the command:
- Observe the error:
pyclean: error: argument -d/--debris: invalid choice: './' (choose from all, cache, coverage, ...)
Expected Behavior
The CLI should recognize all as the argument for -d and ./ as the positional directory argument.
Actual Behavior
The parser attempts to include ./ as a choice for the -d flag's list of topics.
Environment
- pyclean version: 3.6.0
- Python version: 3.12.12
- OS: AlmaLinux 9.7 (Moss Jungle Cat)
- Installation Method: Poetry
Additional Context
The issue seems to be that -d accepts multiple values (nargs='*'). When all is provided without an equals sign, the parser continues to consume following strings.
- Fails:
pyclean -d all ./
- Works:
pyclean -d=all ./
- Works:
pyclean ./ -d all
When using the
-d(or--debris) flag with theallkeyword, the subsequent positional argument (the directory path) is incorrectly parsed as a choice for the-dflag. This results in aninvalid choiceerror.However, using the assignment syntax (e.g.,
-d=all) works as expected.Reproduction Steps
pyclean(v3.6.0).Expected Behavior
The CLI should recognize
allas the argument for-dand./as the positionaldirectoryargument.Actual Behavior
The parser attempts to include
./as a choice for the-dflag's list of topics.Environment
Additional Context
The issue seems to be that
-daccepts multiple values (nargs='*'). Whenallis provided without an equals sign, the parser continues to consume following strings.pyclean -d all ./pyclean -d=all ./pyclean ./ -d all