[issue47002] argparse - "expected one argument" when used -: in argument

2022-03-13 Thread Pythass


Pythass  added the comment:

The curious aspect is that for:

import argparse
parser = argparse.ArgumentParser()
parser.add_argument("-u", "--utc", choices=["-1"])
args = parser.parse_args()

it works. But if we use the colon (:) character as:
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("-u", "--utc", choices=["-1:"])
args = parser.parse_args()

it does not work anymore... I could think maybe the issue could be related to 
the presence of ":" character together with "-" character.

For example for:
choices=["-:"] does not work
choices=["-"] works
choices=[":"] works
choices=[":-"] works

So, we get the error if the option start with "-" and has inside also ":" 
character. At this point I don't think it is related strictly to "negative 
numbers".

--

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



[issue47002] argparse - "expected one argument" when used -: in argument

2022-03-13 Thread Pythass


New submission from Pythass :

By using argparse, and by passing a string as argument that has both a dash "-" 
and colon ":", python returns "expected one argument" error, despite it works 
when I use only "-" without ":".

An example of code is attached at the ticket.

Examples of triggering "expected one argument" error:
python test.py -u -1:00
python test.py -u -1:

Examples of NON triggering "expected one argument" error:
python test.py -u -1
python test.py -u=-1:00

--
components: Parser
files: test.py
messages: 415031
nosy: Pythass, lys.nikolaou, pablogsal
priority: normal
severity: normal
status: open
title: argparse - "expected one argument" when used -: in argument
type: compile error
versions: Python 3.10
Added file: https://bugs.python.org/file50668/test.py

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