[issue14074] argparse allows nargs>1 for positional arguments but doesn't allow metavar to be a tuple

2021-11-26 Thread Irit Katriel


Irit Katriel  added the comment:

Reproduced on 3.11, with a different error:

% ./python.exe prog.py
Traceback (most recent call last):
  File "/Users/iritkatriel/src/cpython-1/prog.py", line 5, in 
args = parse.parse_args()
   ^^
  File "/Users/iritkatriel/src/cpython-1/Lib/argparse.py", line 1822, in 
parse_args
args, argv = self.parse_known_args(args, namespace)
 ^^
  File "/Users/iritkatriel/src/cpython-1/Lib/argparse.py", line 1855, in 
parse_known_args
namespace, args = self._parse_known_args(args, namespace)
  ^^^
  File "/Users/iritkatriel/src/cpython-1/Lib/argparse.py", line 2093, in 
_parse_known_args
', '.join(required_actions))
^^^
TypeError: sequence item 0: expected str instance, tuple found

--
nosy: +iritkatriel
type:  -> behavior
versions: +Python 3.10, Python 3.11

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14074] argparse allows nargs>1 for positional arguments but doesn't allow metavar to be a tuple

2020-02-03 Thread Cyker Way


Cyker Way  added the comment:

Tuple support is documented:

https://github.com/python/cpython/commit/98047eb806227f11212f6a42c242030a51964e30#diff-9c4a053d29149ba40370fb3e34faR1059

https://docs.python.org/3/library/argparse.html#metavar

>   Providing a tuple to ``metavar`` specifies a different display for each of 
> the arguments:

>From his word here I feel like our professor meant to support tuple metavar 
>but the implementation was not careful. He called for a patch eight years ago. 
>Let's summon him and see if he has changed his mind?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14074] argparse allows nargs>1 for positional arguments but doesn't allow metavar to be a tuple

2020-02-01 Thread hai shi


Change by hai shi :


--
versions: +Python 3.9 -Python 3.5

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14074] argparse allows nargs>1 for positional arguments but doesn't allow metavar to be a tuple

2020-02-01 Thread hai shi


hai shi  added the comment:

> Given that tuple metavars currently doesn't work, there is no backward 
> compatibility issue.  What is being proposed is to give more friendly error 
> messages.

Got it, thanks.

> Paul suggested that it may be a better plan to just disallow tuple metavars 
> and to give a better error message as the OP suggested.  That makes sense to 
> me.

+1

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14074] argparse allows nargs>1 for positional arguments but doesn't allow metavar to be a tuple

2020-02-01 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

> I am not sure disallowing tuple metavars would break backup 
> compatibility or not~

Given that tuple metavars currently doesn't work, there is no backward 
compatibility issue.  What is being proposed is to give more friendly error 
messages.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14074] argparse allows nargs>1 for positional arguments but doesn't allow metavar to be a tuple

2020-01-31 Thread hai shi


hai shi  added the comment:

I am not sure disallowing tuple metavars would break backup compatibility or 
not~

--
nosy: +shihai1991
versions: +Python 3.5 -Python 3.3

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14074] argparse allows nargs>1 for positional arguments but doesn't allow metavar to be a tuple

2020-01-27 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

-0 on going forward with this.  AFAICT, no one has requested tuple support (the 
OP just wanted better error handling).  And more fined grained control can 
already be had just by specifying separate positional arguments.

Paul suggested that it may be a better plan to just disallow tuple metavars and 
to give a better error message as the OP suggested.  That makes sense to me.

--
nosy: +rhettinger
priority: high -> normal

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14074] argparse allows nargs>1 for positional arguments but doesn't allow metavar to be a tuple

2018-12-01 Thread Cyker Way


Cyker Way  added the comment:

Can confirm this bug still exists on master branch, python3.7, python3.6, and 
very likely other versions since it's reported.

It seems only `_format_action_invocation` and `_get_action_name` need to be 
fixed. So we can do it more lightweight (<10 lines).

--
nosy: +cykerway
Added file: https://bugs.python.org/file47965/14074.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14074] argparse allows nargs>1 for positional arguments but doesn't allow metavar to be a tuple

2018-12-01 Thread Roundup Robot


Change by Roundup Robot :


--
pull_requests: +10082
stage:  -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14074] argparse allows nargs>1 for positional arguments but doesn't allow metavar to be a tuple

2017-01-24 Thread paul j3

paul j3 added the comment:

An alternative fix is to disallow tuple metavars for positionals.  

A tuple metavar may look nice in the usage.  But a well selected dest seems 
better in the help line, and error messages.  Using dest in all 3 roles, as we 
do now, is the simplest compromise.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue14074] argparse allows nargs>1 for positional arguments but doesn't allow metavar to be a tuple

2017-01-24 Thread paul j3

Changes by paul j3 :


--
priority: normal -> high

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com