Repository navigation
Fix unknown options and -- with parse_optionals_as_positionals, and fail on values given both ways - #1009
Conversation
…ail on values given both ways
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1009 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 27 27
Lines 9800 9814 +14
=========================================
+ Hits 9800 9814 +14 ☔ View full report in Codecov by Harness. |
|
|



What does this PR do?
Fixes and changes in how extra positionals are parsed with
parse_optionals_as_positionals=True:name --option value --mistake something, was silently taken as the value of the next optional, or failed with a confusing type error of that optional. Now it fails withunrecognized arguments: --mistake something.--that look like options, e.g.name -- -x, were rejected as unrecognized, and the--itself could be taken as a value. Now the separator is dropped and everything after it is a positional value.val1 val2a --o2=val2b, silently used the positional and ignored the named one. Now it fails with an error that names both, e.g."o2" given both as --o2 and as positional value "val2a". Values from config files, environment variables or defaults are not conflicts, so positionals still override them.--o1, which the user never typed. Now it uses the name shown in the usage, e.g.o1, as for real positionals.Before submitting